diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index a7c3c4e0d0a..664f2940ec7 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -16,7 +16,7 @@ export is_nonpositive, is_nonnegative; export range; export compl; export abs; -export parse_buf, from_str, to_str, to_str_bytes, str; +export parse_bytes, from_str, to_str, to_str_bytes, str; export num, ord, eq, times, timesi; export bits, bytes; @@ -137,7 +137,7 @@ impl T: iter::TimesIx { * * buf - A byte buffer * * radix - The base of the number */ -fn parse_buf(buf: &[u8], radix: uint) -> Option { +fn parse_bytes(buf: &[u8], radix: uint) -> Option { if vec::len(buf) == 0u { return None; } let mut i = vec::len(buf) - 1u; let mut start = 0u; @@ -160,7 +160,7 @@ fn parse_buf(buf: &[u8], radix: uint) -> Option { } /// Parse a string to an int -fn from_str(s: &str) -> Option { parse_buf(str::to_bytes(s), 10u) } +fn from_str(s: &str) -> Option { parse_bytes(str::to_bytes(s), 10u) } impl T : FromStr { static fn from_str(s: &str) -> Option { from_str(s) } @@ -209,28 +209,28 @@ fn test_from_str() { // FIXME: Has alignment issues on windows and 32-bit linux (#2609) #[test] #[ignore] -fn test_parse_buf() { +fn test_parse_bytes() { use str::to_bytes; - assert parse_buf(to_bytes(~"123"), 10u) == Some(123 as T); - assert parse_buf(to_bytes(~"1001"), 2u) == Some(9 as T); - assert parse_buf(to_bytes(~"123"), 8u) == Some(83 as T); - assert parse_buf(to_bytes(~"123"), 16u) == Some(291 as T); - assert parse_buf(to_bytes(~"ffff"), 16u) == Some(65535 as T); - assert parse_buf(to_bytes(~"FFFF"), 16u) == Some(65535 as T); - assert parse_buf(to_bytes(~"z"), 36u) == Some(35 as T); - assert parse_buf(to_bytes(~"Z"), 36u) == Some(35 as T); + assert parse_bytes(to_bytes(~"123"), 10u) == Some(123 as T); + assert parse_bytes(to_bytes(~"1001"), 2u) == Some(9 as T); + assert parse_bytes(to_bytes(~"123"), 8u) == Some(83 as T); + assert parse_bytes(to_bytes(~"123"), 16u) == Some(291 as T); + assert parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535 as T); + assert parse_bytes(to_bytes(~"FFFF"), 16u) == Some(65535 as T); + assert parse_bytes(to_bytes(~"z"), 36u) == Some(35 as T); + assert parse_bytes(to_bytes(~"Z"), 36u) == Some(35 as T); - assert parse_buf(to_bytes(~"-123"), 10u) == Some(-123 as T); - assert parse_buf(to_bytes(~"-1001"), 2u) == Some(-9 as T); - assert parse_buf(to_bytes(~"-123"), 8u) == Some(-83 as T); - assert parse_buf(to_bytes(~"-123"), 16u) == Some(-291 as T); - assert parse_buf(to_bytes(~"-ffff"), 16u) == Some(-65535 as T); - assert parse_buf(to_bytes(~"-FFFF"), 16u) == Some(-65535 as T); - assert parse_buf(to_bytes(~"-z"), 36u) == Some(-35 as T); - assert parse_buf(to_bytes(~"-Z"), 36u) == Some(-35 as T); + assert parse_bytes(to_bytes(~"-123"), 10u) == Some(-123 as T); + assert parse_bytes(to_bytes(~"-1001"), 2u) == Some(-9 as T); + assert parse_bytes(to_bytes(~"-123"), 8u) == Some(-83 as T); + assert parse_bytes(to_bytes(~"-123"), 16u) == Some(-291 as T); + assert parse_bytes(to_bytes(~"-ffff"), 16u) == Some(-65535 as T); + assert parse_bytes(to_bytes(~"-FFFF"), 16u) == Some(-65535 as T); + assert parse_bytes(to_bytes(~"-z"), 36u) == Some(-35 as T); + assert parse_bytes(to_bytes(~"-Z"), 36u) == Some(-35 as T); - assert parse_buf(to_bytes(~"Z"), 35u).is_none(); - assert parse_buf(to_bytes(~"-9"), 2u).is_none(); + assert parse_bytes(to_bytes(~"Z"), 35u).is_none(); + assert parse_bytes(to_bytes(~"-9"), 2u).is_none(); } #[test] diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 7330d3520f6..cdd8ab11658 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -94,7 +94,7 @@ pure fn to_either(res: Result) -> Either { * Example: * * let res = chain(read_file(file)) { |buf| - * ok(parse_buf(buf)) + * ok(parse_bytes(buf)) * } */ fn chain(res: Result, op: fn(T) -> Result) @@ -170,7 +170,7 @@ fn iter_err(res: Result, f: fn(E)) { * Example: * * let res = map(read_file(file)) { |buf| - * parse_buf(buf) + * parse_bytes(buf) * } */ fn map(res: Result, op: fn(T) -> U) diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 80617fba844..02faf9255ef 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -15,7 +15,7 @@ export is_nonpositive, is_nonnegative; export range; export compl; export to_str, to_str_bytes; -export from_str, from_str_radix, str, parse_buf; +export from_str, from_str_radix, str, parse_bytes; export num, ord, eq, times, timesi; export bits, bytes; @@ -126,7 +126,7 @@ impl T: iter::TimesIx { * * `buf` must not be empty */ -fn parse_buf(buf: &[const u8], radix: uint) -> Option { +fn parse_bytes(buf: &[const u8], radix: uint) -> Option { if vec::len(buf) == 0u { return None; } let mut i = vec::len(buf) - 1u; let mut power = 1u as T; @@ -143,7 +143,7 @@ fn parse_buf(buf: &[const u8], radix: uint) -> Option { } /// Parse a string to an int -fn from_str(s: &str) -> Option { parse_buf(str::to_bytes(s), 10u) } +fn from_str(s: &str) -> Option { parse_bytes(str::to_bytes(s), 10u) } impl T : FromStr { static fn from_str(s: &str) -> Option { from_str(s) } @@ -275,17 +275,17 @@ fn test_from_str() { #[test] #[ignore] -fn test_parse_buf() { +fn test_parse_bytes() { use str::to_bytes; - assert parse_buf(to_bytes(~"123"), 10u) == Some(123u as T); - assert parse_buf(to_bytes(~"1001"), 2u) == Some(9u as T); - assert parse_buf(to_bytes(~"123"), 8u) == Some(83u as T); - assert parse_buf(to_bytes(~"123"), 16u) == Some(291u as T); - assert parse_buf(to_bytes(~"ffff"), 16u) == Some(65535u as T); - assert parse_buf(to_bytes(~"z"), 36u) == Some(35u as T); + assert parse_bytes(to_bytes(~"123"), 10u) == Some(123u as T); + assert parse_bytes(to_bytes(~"1001"), 2u) == Some(9u as T); + assert parse_bytes(to_bytes(~"123"), 8u) == Some(83u as T); + assert parse_bytes(to_bytes(~"123"), 16u) == Some(291u as T); + assert parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535u as T); + assert parse_bytes(to_bytes(~"z"), 36u) == Some(35u as T); - assert parse_buf(to_bytes(~"Z"), 10u).is_none(); - assert parse_buf(to_bytes(~"_"), 2u).is_none(); + assert parse_bytes(to_bytes(~"Z"), 10u).is_none(); + assert parse_bytes(to_bytes(~"_"), 2u).is_none(); } #[test] diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 0e422aa1eeb..b8f11adf2e1 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -116,7 +116,7 @@ fn decode_inner(s: &str, full_url: bool) -> ~str { match rdr.read_char() { '%' => { let bytes = rdr.read_bytes(2u); - let ch = uint::parse_buf(bytes, 16u).get() as char; + let ch = uint::parse_bytes(bytes, 16u).get() as char; if full_url { // Only decode some characters: @@ -241,7 +241,7 @@ fn decode_form_urlencoded(s: ~[u8]) -> ch => { let ch = match ch { '%' => { - uint::parse_buf(rdr.read_bytes(2u), 16u).get() as char + uint::parse_bytes(rdr.read_bytes(2u), 16u).get() as char } '+' => ' ', ch => ch diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index ed6835b6f8b..a0b6912cd6d 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -205,7 +205,7 @@ fn field_mutability(d: ebml::Doc) -> ast::class_mutability { fn variant_disr_val(d: ebml::Doc) -> Option { do option::chain(ebml::maybe_get_doc(d, tag_disr_val)) |val_doc| { - int::parse_buf(ebml::doc_data(val_doc), 10u) + int::parse_bytes(ebml::doc_data(val_doc), 10u) } } diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index 9b723c5d9eb..5cf24aef558 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -440,12 +440,12 @@ fn parse_def_id(buf: &[u8]) -> ast::def_id { let crate_part = vec::view(buf, 0u, colon_idx); let def_part = vec::view(buf, colon_idx + 1u, len); - let crate_num = match uint::parse_buf(crate_part, 10u) { + let crate_num = match uint::parse_bytes(crate_part, 10u) { Some(cn) => cn as int, None => fail (fmt!("internal error: parse_def_id: crate number \ expected, but found %?", crate_part)) }; - let def_num = match uint::parse_buf(def_part, 10u) { + let def_num = match uint::parse_bytes(def_part, 10u) { Some(dn) => dn as int, None => fail (fmt!("internal error: parse_def_id: id expected, but \ found %?", def_part)) diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 1b8158aef0a..e929690ccfa 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -93,8 +93,8 @@ fn main(args: ~[~str]) { if opts.stress { stress(2); } else { - let max = option::get(uint::parse_buf(str::to_bytes(args[1]), - 10u)) as int; + let max = option::get(uint::parse_bytes(str::to_bytes(args[1]), + 10u)) as int; let num_trials = 10;