about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKevin Cantu <me@kevincantu.org>2012-02-22 23:46:45 -0800
committerMarijn Haverbeke <marijnh@gmail.com>2012-02-23 17:00:19 +0100
commit6ea3d7935efba59d0b9d81f233e66ea69f1e1016 (patch)
tree9a0b15de841f729a811fe8b5dedab0f94b6cba87 /src
parent280633a7283c21c6d95a556816bfb698845c34d8 (diff)
downloadrust-6ea3d7935efba59d0b9d81f233e66ea69f1e1016.tar.gz
rust-6ea3d7935efba59d0b9d81f233e66ea69f1e1016.zip
(core::str) replace byte_index[_from] with index[_from]
Diffstat (limited to 'src')
-rw-r--r--src/cargo/cargo.rs16
-rw-r--r--src/comp/syntax/codemap.rs2
-rw-r--r--src/libcore/str.rs6
-rw-r--r--src/libstd/json.rs20
4 files changed, 23 insertions, 21 deletions
diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs
index 879d4bf8a61..caaedab97c9 100644
--- a/src/cargo/cargo.rs
+++ b/src/cargo/cargo.rs
@@ -174,10 +174,10 @@ fn print(s: str) {
 }
 
 fn rest(s: str, start: uint) -> str {
-    if (start >= str::len_chars(s)) {
+    if (start >= str::len_bytes(s)) {
         ""
     } else {
-        str::slice_chars(s, start, str::len_chars(s))
+        str::slice(s, start, str::len_bytes(s))
     }
 }
 
@@ -686,10 +686,10 @@ fn cmd_install(c: cargo) unsafe {
 
     if str::starts_with(target, "uuid:") {
         let uuid = rest(target, 5u);
-        alt str::index_chars(uuid, '/') {
+        alt str::index(uuid, '/') {
             option::some(idx) {
-               let source = str::slice_chars(uuid, 0u, idx);
-               uuid = str::slice_chars(uuid, idx + 1u, str::len_chars(uuid));
+               let source = str::slice(uuid, 0u, idx);
+               uuid = str::slice(uuid, idx + 1u, str::len_bytes(uuid));
                install_uuid_specific(c, wd, source, uuid);
             }
             option::none {
@@ -698,10 +698,10 @@ fn cmd_install(c: cargo) unsafe {
         }
     } else {
         let name = target;
-        alt str::index_chars(name, '/') {
+        alt str::index(name, '/') {
             option::some(idx) {
-               let source = str::slice_chars(name, 0u, idx);
-               name = str::slice_chars(name, idx + 1u, str::len_chars(name));
+               let source = str::slice(name, 0u, idx);
+               name = str::slice(name, idx + 1u, str::len_bytes(name));
                install_named_specific(c, wd, source, name);
             }
             option::none {
diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs
index 74dbade09c1..abe5a242261 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::byte_index_from(*fm.src, '\n' as u8, begin,
+    let end = alt str::index_from(*fm.src, '\n', begin,
                                   str::len_bytes(*fm.src)) {
       some(e) { e }
       none { str::len_bytes(*fm.src) }
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 4f315541da2..8760403a77a 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -71,8 +71,10 @@ export
 
    // Searching
    index_chars,
-   byte_index,
-   byte_index_from,
+   index,
+   index_from,
+   //byte_index,
+   //byte_index_from,
    rindex,
    //rindex_chars,
    find_chars,
diff --git a/src/libstd/json.rs b/src/libstd/json.rs
index 70b16758e1d..32294f38fb9 100644
--- a/src/libstd/json.rs
+++ b/src/libstd/json.rs
@@ -70,8 +70,8 @@ fn to_str(j: json) -> str {
 }
 
 fn rest(s: str) -> str {
-    assert(str::len_chars(s) >= 1u);
-    str::slice_chars(s, 1u, str::len_chars(s))
+    assert(str::len_bytes(s) >= 1u);
+    str::slice(s, 1u, str::len_bytes(s))
 }
 
 fn from_str_str(s: str) -> (option<json>, str) {
@@ -99,7 +99,7 @@ fn from_str_str(s: str) -> (option<json>, str) {
             cont;
         } else if (c == '"') {
             ret (some(string(res)),
-                 str::slice_chars(s, pos, str::len_chars(s)));
+                 str::slice(s, pos, str::len_bytes(s)));
         }
         res = res + str::from_char(c);
     }
@@ -200,13 +200,13 @@ fn from_str_float(s: str) -> (option<json>, str) {
             }
             '.' { break; }
             _ { ret (some(num(neg * res)),
-                     str::slice_chars(s, opos, str::len_chars(s))); }
+                     str::slice(s, opos, str::len_bytes(s))); }
         }
     }
 
     if pos == len {
         ret (some(num(neg * res)),
-             str::slice_chars(s, pos, str::len_chars(s)));
+             str::slice(s, pos, str::len_bytes(s)));
     }
 
     let dec = 1f;
@@ -221,17 +221,17 @@ fn from_str_float(s: str) -> (option<json>, str) {
                 res += (((c as int) - ('0' as int)) as float) * dec;
             }
             _ { ret (some(num(neg * res)),
-                     str::slice_chars(s, opos, str::len_chars(s))); }
+                     str::slice(s, opos, str::len_bytes(s))); }
         }
     }
-    ret (some(num(neg * res)), str::slice_chars(s, pos, str::len_chars(s)));
+    ret (some(num(neg * res)), str::slice(s, pos, str::len_bytes(s)));
 }
 
 fn from_str_bool(s: str) -> (option<json>, str) {
     if (str::starts_with(s, "true")) {
-        (some(boolean(true)), str::slice_chars(s, 4u, str::len_chars(s)))
+        (some(boolean(true)), str::slice(s, 4u, str::len_bytes(s)))
     } else if (str::starts_with(s, "false")) {
-        (some(boolean(false)), str::slice_chars(s, 5u, str::len_chars(s)))
+        (some(boolean(false)), str::slice(s, 5u, str::len_bytes(s)))
     } else {
         (none, s)
     }
@@ -239,7 +239,7 @@ fn from_str_bool(s: str) -> (option<json>, str) {
 
 fn from_str_null(s: str) -> (option<json>, str) {
     if (str::starts_with(s, "null")) {
-        (some(null), str::slice_chars(s, 4u, str::len_chars(s)))
+        (some(null), str::slice(s, 4u, str::len_bytes(s)))
     } else {
         (none, s)
     }