Skip to content

Commit 7a6a6fd

Browse files
killerswanmarijnh
authored andcommitted
---
yaml --- r: 14447 b: refs/heads/try c: 1b957c0 h: refs/heads/master i: 14445: d535f25 14443: bc0f64d 14439: 45bd07f 14431: de65559 v: v3
1 parent 431ec35 commit 7a6a6fd

File tree

14 files changed

+65
-65
lines changed

14 files changed

+65
-65
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: cec053487c84e8b5406e24d6f9f72966cdcfd0da
5+
refs/heads/try: 1b957c0942007e60ec9ea6773c964ea7bdc199af
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/comp/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
478478
}
479479

480480
fn truncated_sha1_result(sha: sha1) -> str unsafe {
481-
ret str::unsafe::slice_bytes(sha.result_str(), 0u, 16u);
481+
ret str::slice(sha.result_str(), 0u, 16u);
482482
}
483483

484484

@@ -567,12 +567,12 @@ fn link_binary(sess: session,
567567
// Converts a library file name into a cc -l argument
568568
fn unlib(config: @session::config, filename: str) -> str unsafe {
569569
let rmlib = fn@(filename: str) -> str {
570-
let found = str::find_bytes(filename, "lib");
570+
let found = str::find(filename, "lib");
571571
if config.os == session::os_macos ||
572572
(config.os == session::os_linux ||
573573
config.os == session::os_freebsd) &&
574574
option::is_some(found) && option::get(found) == 0u {
575-
ret str::unsafe::slice_bytes(filename, 3u,
575+
ret str::slice(filename, 3u,
576576
str::len_bytes(filename));
577577
} else { ret filename; }
578578
};

branches/try/src/comp/middle/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn create_compile_unit(cx: crate_ctxt, full_path: str)
167167

168168
let work_dir = cx.sess.working_dir;
169169
let file_path = if str::starts_with(full_path, work_dir) {
170-
str::unsafe::slice_bytes(full_path, str::len_bytes(work_dir),
170+
str::slice(full_path, str::len_bytes(work_dir),
171171
str::len_bytes(full_path))
172172
} else {
173173
full_path

branches/try/src/comp/syntax/codemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn get_line(fm: filemap, line: int) -> str unsafe {
162162
some(e) { e }
163163
none { str::len_bytes(*fm.src) }
164164
};
165-
str::unsafe::slice_bytes(*fm.src, begin, end)
165+
str::slice(*fm.src, begin, end)
166166
}
167167

168168
fn lookup_byte_offset(cm: codemap::codemap, chpos: uint)

branches/try/src/comp/syntax/parse/lexer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl reader for reader {
2424
fn get_str_from(start: uint) -> str unsafe {
2525
// I'm pretty skeptical about this subtraction. What if there's a
2626
// multi-byte character before the mark?
27-
ret str::unsafe::slice_bytes(*self.src, start - 1u, self.pos - 1u);
27+
ret str::slice(*self.src, start - 1u, self.pos - 1u);
2828
}
2929
fn next() -> char {
3030
if self.pos < self.len {
@@ -611,7 +611,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: [str],
611611
let s1;
612612
if all_whitespace(s, 0u, col) {
613613
if col < str::len_bytes(s) {
614-
s1 = str::unsafe::slice_bytes(s, col, str::len_bytes(s));
614+
s1 = str::slice(s, col, str::len_bytes(s));
615615
} else { s1 = ""; }
616616
} else { s1 = s; }
617617
log(debug, "pushing line: " + s1);

branches/try/src/comp/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
131131

132132
fn ty_to_short_str(cx: ctxt, typ: t) -> str unsafe {
133133
let s = encoder::encoded_ty(cx, typ);
134-
if str::len_bytes(s) >= 32u { s = str::unsafe::slice_bytes(s, 0u, 32u); }
134+
if str::len_bytes(s) >= 32u { s = str::slice(s, 0u, 32u); }
135135
ret s;
136136
}
137137

branches/try/src/compiletest/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn load_errors(testfile: str) -> [expected_error] {
2525
fn parse_expected(line_num: uint, line: str) -> [expected_error] unsafe {
2626
let error_tag = "//!";
2727
let idx;
28-
alt str::find_bytes(line, error_tag) {
28+
alt str::find(line, error_tag) {
2929
option::none { ret []; }
3030
option::some(nn) { idx = (nn as uint) + str::len_bytes(error_tag); }
3131
}
@@ -43,11 +43,11 @@ fn parse_expected(line_num: uint, line: str) -> [expected_error] unsafe {
4343
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
4444
let start_kind = idx;
4545
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
46-
let kind = str::to_lower(str::unsafe::slice_bytes(line, start_kind, idx));
46+
let kind = str::to_lower(str::slice(line, start_kind, idx));
4747

4848
// Extract msg:
4949
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
50-
let msg = str::unsafe::slice_bytes(line, idx, len);
50+
let msg = str::slice(line, idx, len);
5151

5252
#debug("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
5353

branches/try/src/compiletest/header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ fn parse_name_directive(line: str, directive: str) -> bool {
106106
fn parse_name_value_directive(line: str,
107107
directive: str) -> option<str> unsafe {
108108
let keycolon = directive + ":";
109-
alt str::find_bytes(line, keycolon) {
109+
alt str::find(line, keycolon) {
110110
option::some(colon) {
111111
let value =
112-
str::unsafe::slice_bytes(line,
112+
str::slice(line,
113113
colon + str::len_bytes(keycolon),
114114
str::len_bytes(line));
115115
#debug("%s: %s", directive, value);

branches/try/src/libcore/extfmt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ mod ct {
9393
}
9494
let i = 0u;
9595
while i < lim {
96-
let curr = str::unsafe::slice_bytes(s, i, i+1u);
96+
let curr = str::slice(s, i, i+1u);
9797
if str::eq(curr, "%") {
9898
i += 1u;
9999
if i >= lim {
100100
error("unterminated conversion at end of string");
101101
}
102-
let curr2 = str::unsafe::slice_bytes(s, i, i+1u);
102+
let curr2 = str::slice(s, i, i+1u);
103103
if str::eq(curr2, "%") {
104104
buf += curr2;
105105
i += 1u;
@@ -225,7 +225,7 @@ mod ct {
225225
fn parse_type(s: str, i: uint, lim: uint, error: error_fn) ->
226226
{ty: ty, next: uint} unsafe {
227227
if i >= lim { error("missing type in conversion"); }
228-
let tstr = str::unsafe::slice_bytes(s, i, i+1u);
228+
let tstr = str::slice(s, i, i+1u);
229229
// TODO: Do we really want two signed types here?
230230
// How important is it to be printf compatible?
231231
let t =
@@ -439,7 +439,7 @@ mod rt {
439439
let headstr = str::from_bytes([head]);
440440
// FIXME: not UTF-8 safe
441441
let bytelen = str::len_bytes(s);
442-
let numpart = str::unsafe::slice_bytes(s, 1u, bytelen);
442+
let numpart = str::slice(s, 1u, bytelen);
443443
ret headstr + padstr + numpart;
444444
}
445445
}

branches/try/src/libcore/str.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ export
7575
index_from,
7676
rindex,
7777
//rindex_chars,
78+
find,
79+
find_from,
7880
find_chars,
79-
find_bytes,
80-
find_from_bytes,
8181
contains,
8282
starts_with,
8383
ends_with,
@@ -385,15 +385,15 @@ fn chars(s: str) -> [char] {
385385
/*
386386
Function: substr
387387
388-
Take a substring of another. Returns a string containing `len` chars
388+
Take a substring of another. Returns a string containing `len` bytes
389389
starting at char offset `begin`.
390390
391391
Failure:
392392
393393
If `begin` + `len` is is greater than the char length of the string
394394
*/
395395
fn substr(s: str, begin: uint, len: uint) -> str {
396-
ret slice_chars(s, begin, begin + len);
396+
ret slice(s, begin, begin + len);
397397
}
398398

399399
// Function: slice
@@ -696,7 +696,7 @@ fn replace(s: str, from: str, to: str) -> str unsafe {
696696
from, to);
697697
} else {
698698
let idx;
699-
alt find_bytes(s, from) {
699+
alt find(s, from) {
700700
some(x) { idx = x; }
701701
none { ret s; }
702702
}
@@ -977,21 +977,21 @@ fn rindex_chars(ss: str, cc: char) -> option<uint> {
977977
ret none;
978978
}
979979

980-
//Function: find_bytes
980+
//Function: find
981981
//
982982
// Find the byte position of the first instance of one string
983983
// within another, or return option::none
984-
fn find_bytes(haystack: str, needle: str) -> option<uint> {
985-
find_from_bytes(haystack, needle, 0u, len_bytes(haystack))
984+
fn find(haystack: str, needle: str) -> option<uint> {
985+
find_from(haystack, needle, 0u, len_bytes(haystack))
986986
}
987987

988-
//Function: find_from_bytes
988+
//Function: find_from
989989
//
990990
// Find the byte position of the first instance of one string
991991
// within another, or return option::none
992992
//
993993
// FIXME: Boyer-Moore should be significantly faster
994-
fn find_from_bytes(haystack: str, needle: str, start: uint, end:uint)
994+
fn find_from(haystack: str, needle: str, start: uint, end:uint)
995995
-> option<uint> {
996996
assert end <= len_bytes(haystack);
997997

@@ -1020,7 +1020,7 @@ fn find_from_bytes(haystack: str, needle: str, start: uint, end:uint)
10201020
// Find the char position of the first instance of one string
10211021
// within another, or return option::none
10221022
fn find_chars(haystack: str, needle: str) -> option<uint> {
1023-
alt find_bytes(haystack, needle) {
1023+
alt find(haystack, needle) {
10241024
none { ret none; }
10251025
some(nn) { ret some(b2c_pos(haystack, nn)); }
10261026
}
@@ -1056,7 +1056,7 @@ haystack - The string to look in
10561056
needle - The string to look for
10571057
*/
10581058
fn contains(haystack: str, needle: str) -> bool {
1059-
option::is_some(find_bytes(haystack, needle))
1059+
option::is_some(find(haystack, needle))
10601060
}
10611061

10621062
/*
@@ -1479,8 +1479,8 @@ mod unsafe {
14791479
export
14801480
from_bytes,
14811481
from_byte,
1482-
slice_bytes,
1483-
slice_bytes_safe_range,
1482+
slice_bytes, // FIXME: stop exporting
1483+
slice_bytes_safe_range, // FIXME: stop exporting
14841484
push_byte,
14851485
push_bytes, // note: wasn't exported
14861486
pop_byte,
@@ -1840,45 +1840,45 @@ mod tests {
18401840
}
18411841

18421842
#[test]
1843-
fn test_find_bytes() {
1843+
fn test_find() {
18441844
// byte positions
1845-
assert (find_bytes("banana", "apple pie") == none);
1846-
assert (find_bytes("", "") == some(0u));
1845+
assert (find("banana", "apple pie") == none);
1846+
assert (find("", "") == some(0u));
18471847

18481848
let data = "ประเทศไทย中华Việt Nam";
1849-
assert (find_bytes(data, "") == some(0u));
1850-
assert (find_bytes(data, "ประเ") == some( 0u));
1851-
assert (find_bytes(data, "ะเ") == some( 6u));
1852-
assert (find_bytes(data, "中华") == some(27u));
1853-
assert (find_bytes(data, "ไท华") == none);
1849+
assert (find(data, "") == some(0u));
1850+
assert (find(data, "ประเ") == some( 0u));
1851+
assert (find(data, "ะเ") == some( 6u));
1852+
assert (find(data, "中华") == some(27u));
1853+
assert (find(data, "ไท华") == none);
18541854
}
18551855

18561856
#[test]
1857-
fn test_find_from_bytes() {
1857+
fn test_find_from() {
18581858
// byte positions
1859-
assert (find_from_bytes("", "", 0u, 0u) == some(0u));
1859+
assert (find_from("", "", 0u, 0u) == some(0u));
18601860

18611861
let data = "abcabc";
1862-
assert find_from_bytes(data, "ab", 0u, 6u) == some(0u);
1863-
assert find_from_bytes(data, "ab", 2u, 6u) == some(3u);
1864-
assert find_from_bytes(data, "ab", 2u, 4u) == none;
1862+
assert find_from(data, "ab", 0u, 6u) == some(0u);
1863+
assert find_from(data, "ab", 2u, 6u) == some(3u);
1864+
assert find_from(data, "ab", 2u, 4u) == none;
18651865

18661866
let data = "ประเทศไทย中华Việt Nam";
18671867
data += data;
1868-
assert find_from_bytes(data, "", 0u, 43u) == some(0u);
1869-
assert find_from_bytes(data, "", 6u, 43u) == some(6u);
1868+
assert find_from(data, "", 0u, 43u) == some(0u);
1869+
assert find_from(data, "", 6u, 43u) == some(6u);
18701870

1871-
assert find_from_bytes(data, "ประ", 0u, 43u) == some( 0u);
1872-
assert find_from_bytes(data, "ทศไ", 0u, 43u) == some(12u);
1873-
assert find_from_bytes(data, "ย中", 0u, 43u) == some(24u);
1874-
assert find_from_bytes(data, "iệt", 0u, 43u) == some(34u);
1875-
assert find_from_bytes(data, "Nam", 0u, 43u) == some(40u);
1871+
assert find_from(data, "ประ", 0u, 43u) == some( 0u);
1872+
assert find_from(data, "ทศไ", 0u, 43u) == some(12u);
1873+
assert find_from(data, "ย中", 0u, 43u) == some(24u);
1874+
assert find_from(data, "iệt", 0u, 43u) == some(34u);
1875+
assert find_from(data, "Nam", 0u, 43u) == some(40u);
18761876

1877-
assert find_from_bytes(data, "ประ", 43u, 86u) == some(43u);
1878-
assert find_from_bytes(data, "ทศไ", 43u, 86u) == some(55u);
1879-
assert find_from_bytes(data, "ย中", 43u, 86u) == some(67u);
1880-
assert find_from_bytes(data, "iệt", 43u, 86u) == some(77u);
1881-
assert find_from_bytes(data, "Nam", 43u, 86u) == some(83u);
1877+
assert find_from(data, "ประ", 43u, 86u) == some(43u);
1878+
assert find_from(data, "ทศไ", 43u, 86u) == some(55u);
1879+
assert find_from(data, "ย中", 43u, 86u) == some(67u);
1880+
assert find_from(data, "iệt", 43u, 86u) == some(77u);
1881+
assert find_from(data, "Nam", 43u, 86u) == some(83u);
18821882
}
18831883

18841884
#[test]
@@ -1912,7 +1912,7 @@ mod tests {
19121912
t("hello", "el", 1);
19131913

19141914
assert "ะเทศไท"
1915-
== substr("ประเทศไทย中华Việt Nam", 2u, 6u);
1915+
== substr("ประเทศไทย中华Việt Nam", 6u, 18u);
19161916
}
19171917

19181918
#[test]

branches/try/src/libstd/getopts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn getopts(args: [str], opts: [opt]) -> result unsafe {
229229
let names;
230230
let i_arg = option::none::<str>;
231231
if cur[1] == '-' as u8 {
232-
let tail = str::unsafe::slice_bytes(cur, 2u, curlen);
232+
let tail = str::slice(cur, 2u, curlen);
233233
let tail_eq = str::splitn_char(tail, '=', 1u);
234234
if vec::len(tail_eq) <= 1u {
235235
names = [long(tail)];

branches/try/src/libstd/rope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ mod tests {
13451345
fn aux(str: @mutable str, node: @node::node) unsafe {
13461346
alt(*node) {
13471347
node::leaf(x) {
1348-
*str += str::unsafe::slice_bytes(
1348+
*str += str::slice(
13491349
*x.content, x.byte_offset,
13501350
x.byte_offset + x.byte_len);
13511351
}

branches/try/src/libstd/sha1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ mod tests {
372372
let left = len;
373373
while left > 0u {
374374
let take = (left + 1u) / 2u;
375-
sh.input_str(str::unsafe::slice_bytes(t.input, len - left,
375+
sh.input_str(str::slice(t.input, len - left,
376376
take + len - left));
377377
left = left - take;
378378
}

branches/try/src/rustdoc/markdown_pass.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ fn should_write_modules_last() {
5656
fn d() { }"
5757
);
5858

59-
let idx_a = option::get(str::find_bytes(markdown, "# Module `a`"));
60-
let idx_b = option::get(str::find_bytes(markdown, "## Function `b`"));
61-
let idx_c = option::get(str::find_bytes(markdown, "# Module `c`"));
62-
let idx_d = option::get(str::find_bytes(markdown, "## Function `d`"));
59+
let idx_a = option::get(str::find(markdown, "# Module `a`"));
60+
let idx_b = option::get(str::find(markdown, "## Function `b`"));
61+
let idx_c = option::get(str::find(markdown, "# Module `c`"));
62+
let idx_d = option::get(str::find(markdown, "## Function `d`"));
6363

6464
assert idx_b < idx_d;
6565
assert idx_d < idx_a;

0 commit comments

Comments
 (0)