diff options
| author | Kevin Cantu <me@kevincantu.org> | 2012-02-11 03:20:45 -0800 |
|---|---|---|
| committer | Kevin Cantu <me@kevincantu.org> | 2012-02-11 16:39:39 -0800 |
| commit | 27161f4415e484680cf404b9819bf37d66c26783 (patch) | |
| tree | 95d6b672323ae58ecac7bd2adea14a2b4391beb6 /src/comp | |
| parent | 14baf88f89241f1384e4d12b4751910fe16c947c (diff) | |
| download | rust-27161f4415e484680cf404b9819bf37d66c26783.tar.gz rust-27161f4415e484680cf404b9819bf37d66c26783.zip | |
using str::index...
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/back/link.rs | 14 | ||||
| -rw-r--r-- | src/comp/syntax/codemap.rs | 7 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 4f32ad4a31f..5fa7841c972 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -109,14 +109,16 @@ 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 unsafe { - let dot_pos = str::index_byte(output_path, '.' as u8); - let stem; - if dot_pos < 0 { - stem = output_path; - } else { stem = str::unsafe::slice_bytes(output_path, 0u, - dot_pos as uint); } + let stem = alt str::index(output_path, '.') { + option::some(dot_pos) { + str::slice(output_path, 0u, dot_pos) + } + option::none { output_path } + }; + ret stem + "." + extension; } + fn run_passes(sess: session, llmod: ModuleRef, output: str) { let opts = sess.opts; if opts.time_llvm_passes { llvm::LLVMRustEnableTimePasses(); } diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs index 27f968b1156..cb2590e1951 100644 --- a/src/comp/syntax/codemap.rs +++ b/src/comp/syntax/codemap.rs @@ -119,16 +119,13 @@ fn get_line(fm: filemap, line: int) -> str unsafe { let end: uint; if line as uint < vec::len(fm.lines) - 1u { end = fm.lines[line + 1].byte - fm.start_pos.byte; + ret str::unsafe::slice_bytes(*fm.src, begin, end); } else { // If we're not done parsing the file, we're at the limit of what's // parsed. If we just slice the rest of the string, we'll print out // the remainder of the file, which is undesirable. - end = str::byte_len(*fm.src); - let rest = str::unsafe::slice_bytes(*fm.src, begin, end); - let newline = str::index_byte(rest, '\n' as u8); - if newline != -1 { end = begin + (newline as uint); } + ret str::splitn_char(*fm.src, '\n', 1u)[0]; } - ret str::unsafe::slice_bytes(*fm.src, begin, end); } fn lookup_byte_offset(cm: codemap::codemap, chpos: uint) |
