Skip to content

Commit 850c27d

Browse files
killerswanbrson
authored andcommitted
---
yaml --- r: 7992 b: refs/heads/snap-stage3 c: 8f367eb h: refs/heads/master v: v3
1 parent 50cc30d commit 850c27d

File tree

20 files changed

+40
-87
lines changed

20 files changed

+40
-87
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 01c01f68afc58bc9a7a4d4b85805925d45a39ec7
4+
refs/heads/snap-stage3: 8f367ebfeb4f0b897b386f5c74c4f329fb8cbd54
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/cargo/cargo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ fn cmd_install(c: cargo, argv: [str]) unsafe {
596596
let uuid = rest(target, 5u);
597597
let idx = str::index(uuid, '/' as u8);
598598
if idx != -1 {
599-
let source = str::unsafe::slice(uuid, 0u, idx as uint);
600-
uuid = str::unsafe::slice(uuid, idx as uint + 1u,
599+
let source = str::unsafe::slice_bytes(uuid, 0u, idx as uint);
600+
uuid = str::unsafe::slice_bytes(uuid, idx as uint + 1u,
601601
str::byte_len(uuid));
602602
install_uuid_specific(c, wd, source, uuid);
603603
} else {
@@ -607,8 +607,8 @@ fn cmd_install(c: cargo, argv: [str]) unsafe {
607607
let name = target;
608608
let idx = str::index(name, '/' as u8);
609609
if idx != -1 {
610-
let source = str::unsafe::slice(name, 0u, idx as uint);
611-
name = str::unsafe::slice(name, idx as uint + 1u,
610+
let source = str::unsafe::slice_bytes(name, 0u, idx as uint);
611+
name = str::unsafe::slice_bytes(name, idx as uint + 1u,
612612
str::byte_len(name));
613613
install_named_specific(c, wd, source, name);
614614
} else {

branches/snap-stage3/src/comp/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ fn link_binary(sess: session,
570570
(config.os == session::os_linux ||
571571
config.os == session::os_freebsd) &&
572572
str::find(filename, "lib") == 0 {
573-
ret str::unsafe::slice(filename, 3u,
573+
ret str::unsafe::slice_bytes(filename, 3u,
574574
str::byte_len(filename));
575575
} else { ret filename; }
576576
};

branches/snap-stage3/src/comp/middle/debuginfo.rs

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

169169
let work_dir = cx.sess.working_dir;
170170
let file_path = if str::starts_with(full_path, work_dir) {
171-
str::unsafe::slice(full_path, str::byte_len(work_dir),
171+
str::unsafe::slice_bytes(full_path, str::byte_len(work_dir),
172172
str::byte_len(full_path))
173173
} else {
174174
full_path

branches/snap-stage3/src/comp/syntax/codemap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ fn get_line(fm: filemap, line: int) -> str unsafe {
118118
// parsed. If we just slice the rest of the string, we'll print out
119119
// the remainder of the file, which is undesirable.
120120
end = str::byte_len(*fm.src);
121-
let rest = str::unsafe::slice(*fm.src, begin, end);
121+
let rest = str::unsafe::slice_bytes(*fm.src, begin, end);
122122
let newline = str::index(rest, '\n' as u8);
123123
if newline != -1 { end = begin + (newline as uint); }
124124
}
125-
ret str::unsafe::slice(*fm.src, begin, end);
125+
ret str::unsafe::slice_bytes(*fm.src, begin, end);
126126
}
127127

128128
fn get_filemap(cm: codemap, filename: str) -> filemap {

branches/snap-stage3/src/comp/syntax/parse/lexer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl reader for reader {
2727
fn get_str_from(start: uint) -> str unsafe {
2828
// I'm pretty skeptical about this subtraction. What if there's a
2929
// multi-byte character before the mark?
30-
ret str::unsafe::slice(*self.src, start - 1u, self.pos - 1u);
30+
ret str::unsafe::slice_bytes(*self.src, start - 1u, self.pos - 1u);
3131
}
3232
fn next() -> char {
3333
if self.pos < self.len {
@@ -584,7 +584,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: [str],
584584
let s1;
585585
if all_whitespace(s, 0u, col) {
586586
if col < str::byte_len(s) {
587-
s1 = str::unsafe::slice(s, col, str::byte_len(s));
587+
s1 = str::unsafe::slice_bytes(s, col, str::byte_len(s));
588588
} else { s1 = ""; }
589589
} else { s1 = s; }
590590
log(debug, "pushing line: " + s1);

branches/snap-stage3/src/compiletest/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ fn parse_expected(line_num: uint, line: str) -> [expected_error] unsafe {
4141
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
4242
let start_kind = idx;
4343
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
44-
let kind = str::to_lower(str::unsafe::slice(line, start_kind, idx));
44+
let kind = str::to_lower(str::unsafe::slice_bytes(line, start_kind, idx));
4545

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

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

branches/snap-stage3/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn parse_name_value_directive(line: str,
109109
if str::find(line, keycolon) >= 0 {
110110
let colon = str::find(line, keycolon) as uint;
111111
let value =
112-
str::unsafe::slice(line, colon + str::byte_len(keycolon),
112+
str::unsafe::slice_bytes(line, colon + str::byte_len(keycolon),
113113
str::byte_len(line));
114114
#debug("%s: %s", directive, value);
115115
option::some(value)

branches/snap-stage3/src/fuzzer/fuzzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ fn check_variants_T<T: copy>(
286286
fn last_part(filename: str) -> str unsafe {
287287
let ix = str::rindex(filename, 47u8 /* '/' */);
288288
assert ix >= 0;
289-
str::unsafe::slice(filename, ix as uint + 1u, str::byte_len(filename) - 3u)
289+
str::unsafe::slice_bytes(filename, ix as uint + 1u, str::byte_len(filename) - 3u)
290290
}
291291

292292
enum happiness { passed, cleanly_rejected(str), known_bug(str), failed(str), }

branches/snap-stage3/src/libcore/str.rs

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ export
3838
chars,
3939
substr,
4040
char_slice,
41-
//slice,
42-
//safe_slice,
4341
split,
4442
splitn,
4543
split_str,
@@ -425,7 +423,7 @@ Failure:
425423
If `begin` + `len` is is greater than the byte length of the string
426424
*/
427425
fn substr(s: str, begin: uint, len: uint) -> str unsafe {
428-
ret unsafe::slice(s, begin, begin + len);
426+
ret unsafe::slice_bytes(s, begin, begin + len);
429427
}
430428

431429
/*
@@ -446,48 +444,6 @@ fn char_slice(s: str, begin: uint, end: uint) -> str {
446444
from_chars(vec::slice(chars(s), begin, end))
447445
}
448446

449-
/*
450-
Function: slice
451-
452-
Takes a bytewise slice from a string. Returns the substring from
453-
[`begin`..`end`).
454-
455-
This function is not unicode-safe.
456-
457-
Failure:
458-
459-
- If begin is greater than end.
460-
- If end is greater than the length of the string.
461-
462-
FIXME: rename to slice_byte or slice_byte_unsafe
463-
*/
464-
fn slice(s: str, begin: uint, end: uint) -> str unsafe {
465-
// FIXME: Typestate precondition
466-
assert (begin <= end);
467-
assert (end <= byte_len(s));
468-
469-
let v: [u8] = ::unsafe::reinterpret_cast(s);
470-
let v2 = vec::slice(v, begin, end);
471-
::unsafe::leak(v);
472-
v2 += [0u8];
473-
let s2: str = ::unsafe::reinterpret_cast(v2);
474-
::unsafe::leak(v2);
475-
ret s2;
476-
}
477-
478-
/*
479-
Function: safe_slice
480-
481-
FIXME: make sure char_slice / slice / byte_slice
482-
have these preconditions and assertions
483-
FIXME: this shouldn't be mistaken for a UTF-8 safe slice
484-
*/
485-
fn safe_slice(s: str, begin: uint, end: uint) : uint::le(begin, end) -> str {
486-
// would need some magic to make this a precondition
487-
assert (end <= byte_len(s));
488-
ret slice(s, begin, end);
489-
}
490-
491447
/*
492448
Function: split
493449
@@ -712,7 +668,7 @@ fn replace(s: str, from: str, to: str) : is_not_empty(from) -> str unsafe {
712668
if byte_len(s) == 0u {
713669
ret "";
714670
} else if starts_with(s, from) {
715-
ret to + replace(unsafe::slice(s, byte_len(from), byte_len(s)),
671+
ret to + replace(unsafe::slice_bytes(s, byte_len(from), byte_len(s)),
716672
from, to);
717673
} else {
718674
let idx = find(s, from);
@@ -1348,8 +1304,8 @@ mod unsafe {
13481304
// UNSAFE
13491305
from_bytes,
13501306
from_byte,
1351-
slice,
1352-
safe_slice;
1307+
slice_bytes,
1308+
slice_bytes_safe_range;
13531309

13541310
// Function: unsafe::from_bytes
13551311
//
@@ -1371,19 +1327,15 @@ mod unsafe {
13711327
/*
13721328
Function: slice
13731329
1374-
Takes a bytewise slice from a string. Returns the substring from
1375-
[`begin`..`end`).
1376-
1377-
This function is not unicode-safe.
1330+
Takes a bytewise (not UTF-8) slice from a string.
1331+
Returns the substring from [`begin`..`end`).
13781332
13791333
Failure:
13801334
13811335
- If begin is greater than end.
13821336
- If end is greater than the length of the string.
1383-
1384-
FIXME: rename to byte_slice
13851337
*/
1386-
unsafe fn slice(s: str, begin: uint, end: uint) -> str unsafe {
1338+
unsafe fn slice_bytes(s: str, begin: uint, end: uint) -> str unsafe {
13871339
// FIXME: Typestate precondition
13881340
assert (begin <= end);
13891341
assert (end <= byte_len(s));
@@ -1398,15 +1350,15 @@ mod unsafe {
13981350
}
13991351

14001352
/*
1401-
Function: safe_slice
1353+
Function: slice_bytes_safe_range
14021354
1403-
FIXME: rename to safe_range_byte_slice
1355+
Like slice_bytes, with a precondition
14041356
*/
1405-
unsafe fn safe_slice(s: str, begin: uint, end: uint)
1357+
unsafe fn slice_bytes_safe_range(s: str, begin: uint, end: uint)
14061358
: uint::le(begin, end) -> str {
14071359
// would need some magic to make this a precondition
14081360
assert (end <= byte_len(s));
1409-
ret slice(s, begin, end);
1361+
ret slice_bytes(s, begin, end);
14101362
}
14111363

14121364
}
@@ -1653,7 +1605,7 @@ mod tests {
16531605
ret rs;
16541606
}
16551607
assert (eq(half_a_million_letter_a(),
1656-
unsafe::slice(a_million_letter_a(), 0u, 500000u)));
1608+
unsafe::slice_bytes(a_million_letter_a(), 0u, 500000u)));
16571609
}
16581610

16591611
#[test]

branches/snap-stage3/src/libstd/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn basename(p: path) -> path unsafe {
7171
}
7272
let len = str::byte_len(p);
7373
if i + 1 as uint >= len { ret p; }
74-
ret str::unsafe::slice(p, i + 1 as uint, len);
74+
ret str::unsafe::slice_bytes(p, i + 1 as uint, len);
7575
}
7676

7777

branches/snap-stage3/src/libstd/getopts.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,15 @@ 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(cur, 2u, curlen);
232+
let tail = str::unsafe::slice_bytes(cur, 2u, curlen);
233233
let eq = str::index(tail, '=' as u8);
234234
if eq == -1 {
235235
names = [long(tail)];
236236
} else {
237-
names = [long(str::unsafe::slice(tail, 0u, eq as uint))];
237+
names =
238+
[long(str::unsafe::slice_bytes(tail,0u,eq as uint))];
238239
i_arg =
239-
option::some::<str>(str::unsafe::slice(tail,
240+
option::some::<str>(str::unsafe::slice_bytes(tail,
240241
(eq as uint) + 1u,
241242
curlen - 2u));
242243
}

branches/snap-stage3/src/test/compile-fail/fn-constraint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import str::*;
55
fn main() unsafe {
66
let a: uint = 4u;
77
let b: uint = 1u;
8-
log(error, str::unsafe::safe_slice("kitties", a, b));
8+
log(error, str::unsafe::slice_bytes_safe_range("kitties", a, b));
99
}

branches/snap-stage3/src/test/compile-fail/no-constraint-prop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ fn main() unsafe {
1616
// the next statement, since it's not true in the
1717
// prestate.
1818
let d <- a;
19-
log(debug, str::unsafe::safe_slice("kitties", b, d));
19+
log(debug, str::unsafe::slice_bytes_safe_range("kitties", b, d));
2020
}

branches/snap-stage3/src/test/run-fail/fn-constraint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ fn main() unsafe {
77
let a: uint = 4u;
88
let b: uint = 1u;
99
check (le(a, b));
10-
log(error, str::unsafe::safe_slice("kitties", a, b));
10+
log(error, str::unsafe::slice_bytes_safe_range("kitties", a, b));
1111
}

branches/snap-stage3/src/test/run-pass/constraint-prop-expr-move.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ fn main() unsafe {
88
let c: uint = 17u;
99
check (le(a, b));
1010
c <- a;
11-
log(debug, str::unsafe::safe_slice("kitties", c, b));
11+
log(debug, str::unsafe::slice_bytes_safe_range("kitties", c, b));
1212
}

branches/snap-stage3/src/test/run-pass/constraint-prop-move.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ fn main() unsafe {
77
let b: uint = 4u;
88
check (le(a, b));
99
let c <- a;
10-
log(debug, str::unsafe::safe_slice("kitties", c, b));
10+
log(debug, str::unsafe::slice_bytes_safe_range("kitties", c, b));
1111
}

branches/snap-stage3/src/test/run-pass/constraint-prop-swap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ fn main() unsafe {
77
let b: uint = 1u;
88
check (le(b, a));
99
b <-> a;
10-
log(debug, str::unsafe::safe_slice("kitties", a, b));
10+
log(debug, str::unsafe::slice_bytes_safe_range("kitties", a, b));
1111
}

branches/snap-stage3/src/test/run-pass/constraint-prop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ fn main() unsafe {
77
let b: uint = 4u;
88
check (le(a, b));
99
let c = b;
10-
log(debug, str::unsafe::safe_slice("kitties", a, c));
10+
log(debug, str::unsafe::slice_bytes_safe_range("kitties", a, c));
1111
}

branches/snap-stage3/src/test/run-pass/fn-constraint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ fn main() unsafe {
66
let a: uint = 1u;
77
let b: uint = 4u;
88
check (le(a, b));
9-
log(debug, str::unsafe::safe_slice("kitties", a, b));
9+
log(debug, str::unsafe::slice_bytes_safe_range("kitties", a, b));
1010
}

0 commit comments

Comments
 (0)