Skip to content

Commit 0358fc3

Browse files
committed
---
yaml --- r: 5077 b: refs/heads/master c: 53a9d5a h: refs/heads/master i: 5075: 581942d v: v3
1 parent 81ba995 commit 0358fc3

25 files changed

+399
-722
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: cb55ef6e12f72f88ea9f05c84c290dfa95849f03
2+
refs/heads/master: 53a9d5a1d21c101f1bf6a00655309a37497cca23

trunk/src/lib/dbg.rs

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ fn debug_fn<T>(x: &T) { rustrt::debug_fn::<T>(x); }
4949
fn ptr_cast<T, U>(x: @T) -> @U { ret rustrt::debug_ptrcast::<T, U>(x); }
5050

5151
fn trap(s: str) { rustrt::debug_trap(s); }
52+
53+
fn refcount<T>(a: &@T) -> uint {
54+
let p: *uint = unsafe::reinterpret_cast(a);
55+
ret *p;
56+
}
57+
5258
// Local Variables:
5359
// mode: rust;
5460
// fill-column: 78;

trunk/src/lib/io.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ obj new_reader(rdr: buf_reader) {
8787

8888
}
8989
let b0 = c0 as u8;
90-
let w = str::utf8_char_width(b0);
90+
let w = istr::utf8_char_width(b0);
9191
assert (w > 0u);
9292
if w == 1u { ret b0 as char; }
9393
let val = 0u;

trunk/src/lib/istr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ concat, connect, to_upper, replace, char_slice, trim_left, trim_right, trim,
44
unshift_char, shift_char, pop_char, push_char, is_utf8, from_chars, to_chars,
55
char_len, char_at, bytes, is_ascii, shift_byte, pop_byte, unsafe_from_byte,
66
unsafe_from_bytes, from_char, char_range_at, str_from_cstr, sbuf,
7-
as_buf, push_byte;
7+
as_buf, push_byte, utf8_char_width, safe_slice;
88

99
export from_estr, to_estr, from_estrs, to_estrs;
1010

trunk/src/lib/str.rs

+46-47
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,57 @@
22
import rustrt::sbuf;
33
import uint::le;
44
export sbuf;
5-
export rustrt;
5+
// export rustrt;
66
export eq;
77
export lteq;
8-
export hash;
9-
export is_utf8;
10-
export is_ascii;
11-
export alloc;
8+
// export hash;
9+
// export is_utf8;
10+
// export is_ascii;
11+
// export alloc;
1212
export byte_len;
1313
export buf;
14-
export bytes;
15-
export unsafe_from_byte;
16-
export str_from_cstr;
17-
export str_from_buf;
18-
export push_utf8_bytes;
14+
// export bytes;
15+
// export unsafe_from_byte;
16+
// export str_from_cstr;
17+
// export str_from_buf;
18+
// export push_utf8_bytes;
1919
export from_char;
20-
export from_chars;
21-
export utf8_char_width;
22-
export char_range_at;
20+
// export from_chars;
21+
// export utf8_char_width;
22+
// export char_range_at;
2323
export char_at;
2424
export char_len;
25-
export to_chars;
26-
export push_char;
27-
export pop_char;
28-
export shift_char;
29-
export unshift_char;
30-
export refcount;
31-
export index;
32-
export rindex;
25+
// export to_chars;
26+
// export push_char;
27+
// export pop_char;
28+
// export shift_char;
29+
// export unshift_char;
30+
// export refcount;
31+
// export index;
32+
// export rindex;
3333
export find;
34-
export starts_with;
35-
export ends_with;
34+
// export starts_with;
35+
// export ends_with;
3636
export substr;
37-
export slice;
38-
export shift_byte;
39-
export pop_byte;
40-
export push_byte;
41-
export unshift_byte;
42-
export split;
43-
export concat;
44-
export connect;
37+
// export slice;
38+
// export shift_byte;
39+
// export pop_byte;
40+
// export push_byte;
41+
// export unshift_byte;
42+
// export split;
43+
// export concat;
44+
// export connect;
4545
export to_upper;
46-
export safe_slice;
46+
// export safe_slice;
4747
export unsafe_from_bytes;
48-
export is_empty;
49-
export is_not_empty;
50-
export is_whitespace;
51-
export replace;
52-
export char_slice;
53-
export trim_left;
54-
export trim_right;
55-
export trim;
48+
// export is_empty;
49+
// export is_not_empty;
50+
// export is_whitespace;
51+
// export replace;
52+
// export char_slice;
53+
// export trim_left;
54+
// export trim_right;
55+
// export trim;
5656

5757
native "rust" mod rustrt {
5858
type sbuf;
@@ -339,7 +339,7 @@ fn index(s: str, c: u8) -> int {
339339
}
340340

341341
fn rindex(s: str, c: u8) -> int {
342-
let n: int = str::byte_len(s) as int;
342+
let n: int = byte_len(s) as int;
343343
while n >= 0 { if s[n] == c { ret n; } n -= 1; }
344344
ret n;
345345
}
@@ -390,15 +390,14 @@ fn slice(s: str, begin: uint, end: uint) -> str {
390390
// FIXME: Typestate precondition
391391

392392
assert (begin <= end);
393-
assert (end <= str::byte_len(s));
393+
assert (end <= byte_len(s));
394394
ret rustrt::str_slice(s, begin, end);
395395
}
396396

397397
fn safe_slice(s: str, begin: uint, end: uint) : le(begin, end) -> str {
398-
assert (end <=
399-
str::byte_len(s)); // would need some magic to
400-
// make this a precondition
401-
398+
// would need some magic to
399+
// make this a precondition
400+
assert (end <= byte_len(s));
402401

403402
ret rustrt::str_slice(s, begin, end);
404403
}
@@ -441,7 +440,7 @@ fn split(s: str, sep: u8) -> [str] {
441440
ends_with_sep = true;
442441
} else { accum += unsafe_from_byte(c); ends_with_sep = false; }
443442
}
444-
if str::byte_len(accum) != 0u || ends_with_sep { v += [accum]; }
443+
if byte_len(accum) != 0u || ends_with_sep { v += [accum]; }
445444
ret v;
446445
}
447446

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// error-pattern: Unsatisfied precondition constraint (for example, le(a, b)
1+
// error-pattern:precondition constraint (for example, uint::le(a, b)
22
use std;
3-
import std::str::*;
3+
import std::istr::*;
44

55
fn main() {
66
let a: uint = 4u;
77
let b: uint = 1u;
8-
log_err safe_slice("kitties", a, b);
8+
log_err safe_slice(~"kitties", a, b);
99
}

trunk/src/test/compile-fail/no-constraint-prop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// error-pattern:Unsatisfied precondition constraint (for example, le(b, d
22
use std;
3-
import std::str::*;
3+
import std::istr::*;
44
import std::uint::*;
55

66
fn main() {
@@ -16,5 +16,5 @@ fn main() {
1616
// the next statement, since it's not true in the
1717
// prestate.
1818
let d <- a;
19-
log safe_slice("kitties", b, d);
19+
log safe_slice(~"kitties", b, d);
2020
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// error-pattern:Predicate le(a, b) failed
22
use std;
3-
import std::str::*;
3+
import std::istr::*;
44
import std::uint::le;
55

66
fn main() {
77
let a: uint = 4u;
88
let b: uint = 1u;
99
check (le(a, b));
10-
log_err safe_slice("kitties", a, b);
10+
log_err safe_slice(~"kitties", a, b);
1111
}

trunk/src/test/run-pass/alt-pattern-drop.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
// -*- rust -*-
44
use std;
5-
import std::str;
65

6+
import std::dbg;
77

88
// FIXME: import std::dbg.const_refcount. Currently
99
// cross-crate const references don't work.
1010
const const_refcount: uint = 0x7bad_face_u;
1111

12-
tag t { make_t(str); clam; }
12+
tag t { make_t(@int); clam; }
1313

14-
fn foo(s: str) {
14+
fn foo(s: @int) {
15+
let count = dbg::refcount(s);
1516
let x: t = make_t(s); // ref up
1617

1718
alt x {
@@ -21,15 +22,15 @@ fn foo(s: str) {
2122
}
2223
_ { log "?"; fail; }
2324
}
24-
log str::refcount(s);
25-
assert (str::refcount(s) == const_refcount);
25+
log dbg::refcount(s);
26+
assert (dbg::refcount(s) == count + 1u);
2627
}
2728

2829
fn main() {
29-
let s: str = "hi"; // ref up
30+
let s: @int = @0; // ref up
3031

3132
foo(s); // ref up then down
3233

33-
log str::refcount(s);
34-
assert (str::refcount(s) == const_refcount);
34+
log dbg::refcount(s);
35+
assert (dbg::refcount(s) == 1u);
3536
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std;
2-
import std::str::*;
2+
import std::istr::*;
33
import std::uint::*;
44

55
fn main() {
@@ -8,5 +8,5 @@ fn main() {
88
let c: uint = 17u;
99
check (le(a, b));
1010
c <- a;
11-
log safe_slice("kitties", c, b);
11+
log safe_slice(~"kitties", c, b);
1212
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std;
2-
import std::str::*;
2+
import std::istr::*;
33
import std::uint::*;
44

55
fn main() {
66
let a: uint = 1u;
77
let b: uint = 4u;
88
check (le(a, b));
99
let c <- a;
10-
log safe_slice("kitties", c, b);
10+
log safe_slice(~"kitties", c, b);
1111
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std;
2-
import std::str::*;
2+
import std::istr::*;
33
import std::uint::*;
44

55
fn main() {
66
let a: uint = 4u;
77
let b: uint = 1u;
88
check (le(b, a));
99
b <-> a;
10-
log safe_slice("kitties", a, b);
10+
log safe_slice(~"kitties", a, b);
1111
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std;
2-
import std::str::*;
2+
import std::istr::*;
33
import std::uint::*;
44

55
fn main() {
66
let a: uint = 1u;
77
let b: uint = 4u;
88
check (le(a, b));
99
let c = b;
10-
log safe_slice("kitties", a, c);
10+
log safe_slice(~"kitties", a, c);
1111
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std;
2-
import std::str::*;
2+
import std::istr::*;
33
import std::uint::*;
44

55
fn main() {
66
let a: uint = 1u;
77
let b: uint = 4u;
88
check (le(a, b));
9-
log safe_slice("kitties", a, b);
9+
log safe_slice(~"kitties", a, b);
1010
}

0 commit comments

Comments
 (0)