diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-23 16:59:30 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-23 17:00:19 +0100 |
| commit | 780f8277f44bb2eddaf6c516d60b0a6b9b557a5b (patch) | |
| tree | f8b30650ab8b26c27f384e422bcff3cd8cbcab79 /src/comp | |
| parent | 1d2b4b97edd7c4038f96c81d8945e294442092a2 (diff) | |
Finish cleanup of core::str
Closes #1849
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/back/link.rs | 13 | ||||
| -rw-r--r-- | src/comp/syntax/codemap.rs | 12 | ||||
| -rw-r--r-- | src/comp/syntax/ext/qquote.rs | 2 |
3 files changed, 11 insertions, 16 deletions
diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index fd966b40884..c2cc106b3e2 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -109,13 +109,10 @@ 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 stem = alt str::index(output_path, '.') { - option::some(dot_pos) { - str::slice(output_path, 0u, dot_pos) - } - option::none { output_path } - }; - + let stem = alt str::find_char(output_path, '.') { + some(dot_pos) { str::slice(output_path, 0u, dot_pos) } + none { output_path } + }; ret stem + "." + extension; } @@ -566,7 +563,7 @@ fn link_binary(sess: session, // Converts a library file name into a cc -l argument fn unlib(config: @session::config, filename: str) -> str unsafe { let rmlib = fn@(filename: str) -> str { - let found = str::find(filename, "lib"); + let found = str::find_str(filename, "lib"); if config.os == session::os_macos || (config.os == session::os_linux || config.os == session::os_freebsd) && diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs index 9520d9fd341..a7dbe574717 100644 --- a/src/comp/syntax/codemap.rs +++ b/src/comp/syntax/codemap.rs @@ -157,7 +157,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { fn get_line(fm: filemap, line: int) -> str unsafe { let begin: uint = fm.lines[line].byte - fm.start_pos.byte; - let end = alt str::index_from(*fm.src, '\n', begin, str::len(*fm.src)) { + let end = alt str::find_char_from(*fm.src, '\n', begin) { some(e) { e } none { str::len(*fm.src) } }; @@ -165,14 +165,12 @@ fn get_line(fm: filemap, line: int) -> str unsafe { } fn lookup_byte_offset(cm: codemap::codemap, chpos: uint) - -> {fm: filemap, pos: uint} -{ - fn lookup(pos: file_pos) -> uint { ret pos.ch; } - let {fm,line} = lookup_line(cm,chpos,lookup); + -> {fm: filemap, pos: uint} { + let {fm, line} = lookup_line(cm, chpos, {|pos| pos.ch}); let line_offset = fm.lines[line].byte - fm.start_pos.byte; let col = chpos - fm.lines[line].ch; - let col_offset = str::substr_len(*fm.src, line_offset, col); - ret {fm: fm, pos: line_offset + col_offset}; + let col_offset = str::count_bytes(*fm.src, line_offset, col); + {fm: fm, pos: line_offset + col_offset} } fn span_to_snippet(sp: span, cm: codemap::codemap) -> str { diff --git a/src/comp/syntax/ext/qquote.rs b/src/comp/syntax/ext/qquote.rs index e53307b474a..7f7d5a387f0 100644 --- a/src/comp/syntax/ext/qquote.rs +++ b/src/comp/syntax/ext/qquote.rs @@ -214,7 +214,7 @@ fn finish<T: qq_helper> if (j < g_len && i == cx.gather[j].lo) { assert ch == '$'; let repl = #fmt("$%u ", j); - state = skip(str::len_chars(repl)); + state = skip(str::char_len(repl)); str2 += repl; } alt state { |
