diff options
| author | Kevin Cantu <me@kevincantu.org> | 2012-02-06 23:06:21 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-02-07 16:25:35 -0800 |
| commit | 2b0396c34adc95efc0451536554a6f7c928c1e61 (patch) | |
| tree | 326155a285f14f21bc1a7ab351d133c20cd212b5 /src/comp | |
| parent | a3f5626ad1b5bc47ceddfb0d600cf6fd8a6dad8c (diff) | |
| download | rust-2b0396c34adc95efc0451536554a6f7c928c1e61.tar.gz rust-2b0396c34adc95efc0451536554a6f7c928c1e61.zip | |
core: make str::substr use char positions (and replace other uses)
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/back/link.rs | 9 | ||||
| -rw-r--r-- | src/comp/util/ppaux.rs | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 68810fcd81b..714ed3c865a 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -113,12 +113,13 @@ mod write { // Decides what to call an intermediate file, given the name of the output // and the extension to use. - fn mk_intermediate_name(output_path: str, extension: str) -> str { + fn mk_intermediate_name(output_path: str, extension: str) -> str unsafe { let dot_pos = str::index(output_path, '.' as u8); let stem; if dot_pos < 0 { stem = output_path; - } else { stem = str::substr(output_path, 0u, dot_pos as uint); } + } else { stem = str::unsafe::slice_bytes(output_path, 0u, + dot_pos as uint); } ret stem + "." + extension; } fn run_passes(sess: session, llmod: ModuleRef, output: str) { @@ -480,8 +481,8 @@ fn build_link_meta(sess: session, c: ast::crate, output: str, ret {name: name, vers: vers, extras_hash: extras_hash}; } -fn truncated_sha1_result(sha: sha1) -> str { - ret str::substr(sha.result_str(), 0u, 16u); +fn truncated_sha1_result(sha: sha1) -> str unsafe { + ret str::unsafe::slice_bytes(sha.result_str(), 0u, 16u); } diff --git a/src/comp/util/ppaux.rs b/src/comp/util/ppaux.rs index 3b2cf157e32..db7d6de5f8b 100644 --- a/src/comp/util/ppaux.rs +++ b/src/comp/util/ppaux.rs @@ -116,9 +116,9 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { } } -fn ty_to_short_str(cx: ctxt, typ: t) -> str { +fn ty_to_short_str(cx: ctxt, typ: t) -> str unsafe { let s = encoder::encoded_ty(cx, typ); - if str::byte_len(s) >= 32u { s = str::substr(s, 0u, 32u); } + if str::byte_len(s) >= 32u { s = str::unsafe::slice_bytes(s, 0u, 32u); } ret s; } |
