Skip to content

Commit d6c2625

Browse files
committed
---
yaml --- r: 71899 b: refs/heads/dist-snap c: 9a16179 h: refs/heads/master i: 71897: 525bedc 71895: 57c0b27 v: v3
1 parent c109693 commit d6c2625

File tree

18 files changed

+175
-55
lines changed

18 files changed

+175
-55
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 23e44a529b3a7bccb3db125012d76273ccc06c72
10+
refs/heads/dist-snap: 9a16179fd3ec18e8f3bc4ca68054981f6628fdcd
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/compiletest/compiletest.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#[allow(deprecated_mode)];
1818
#[allow(deprecated_pattern)];
1919

20-
extern mod core(vers = "0.7-pre");
21-
extern mod std(vers = "0.7-pre");
20+
extern mod core(vers = "0.7-rc");
21+
extern mod std(vers = "0.7-rc");
2222

2323
use core::*;
2424

branches/dist-snap/src/driver/driver.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
// except according to those terms.
1010

1111
#[no_core];
12-
extern mod core(vers = "0.7-pre");
12+
extern mod core(vers = "0.7-rc");
1313

1414
#[cfg(rustpkg)]
15-
extern mod this(name = "rustpkg", vers = "0.7-pre");
15+
extern mod this(name = "rustpkg", vers = "0.7-rc");
1616

1717
#[cfg(fuzzer)]
18-
extern mod this(name = "fuzzer", vers = "0.7-pre");
18+
extern mod this(name = "fuzzer", vers = "0.7-rc");
1919

2020
#[cfg(rustdoc)]
21-
extern mod this(name = "rustdoc", vers = "0.7-pre");
21+
extern mod this(name = "rustdoc", vers = "0.7-rc");
2222

2323
#[cfg(rusti)]
24-
extern mod this(name = "rusti", vers = "0.7-pre");
24+
extern mod this(name = "rusti", vers = "0.7-rc");
2525

2626
#[cfg(rust)]
27-
extern mod this(name = "rust", vers = "0.7-pre");
27+
extern mod this(name = "rust", vers = "0.7-rc");
2828

2929
#[cfg(rustc)]
30-
extern mod this(name = "rustc", vers = "0.7-pre");
30+
extern mod this(name = "rustc", vers = "0.7-rc");
3131

3232
fn main() { this::main() }

branches/dist-snap/src/etc/kate/rust.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*">
88
<!ENTITY rustIntSuf "([iu](8|16|32|64)?)?">
99
]>
10-
<language name="Rust" version="0.7-pre" kateversion="2.4" section="Sources" extensions="*.rs;*.rc" mimetype="text/x-rust" priority="15">
10+
<language name="Rust" version="0.7-rc" kateversion="2.4" section="Sources" extensions="*.rs;*.rc" mimetype="text/x-rust" priority="15">
1111
<highlighting>
1212
<list name="fn">
1313
<item> fn </item>

branches/dist-snap/src/libcore/core.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ they contained the following prologue:
4848

4949

5050
#[link(name = "core",
51-
vers = "0.7-pre",
51+
vers = "0.7-rc",
5252
uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
5353
url = "https://github.com/mozilla/rust/tree/master/src/libcore")];
5454

@@ -66,7 +66,7 @@ they contained the following prologue:
6666
#[allow(deprecated_drop)];
6767

6868
// Make core testable by not duplicating lang items. See #2912
69-
#[cfg(test)] extern mod realcore(name = "core", vers = "0.7-pre");
69+
#[cfg(test)] extern mod realcore(name = "core", vers = "0.7-rc");
7070
#[cfg(test)] pub use kinds = realcore::kinds;
7171
#[cfg(test)] pub use ops = realcore::ops;
7272
#[cfg(test)] pub use cmp = realcore::cmp;

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

Lines changed: 128 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Section: Creating a string
3838
*/
3939

4040
/**
41-
* Convert a vector of bytes to a UTF-8 string
41+
* Convert a vector of bytes to a new UTF-8 string
4242
*
4343
* # Failure
4444
*
@@ -49,9 +49,26 @@ pub fn from_bytes(vv: &const [u8]) -> ~str {
4949
return unsafe { raw::from_bytes(vv) };
5050
}
5151

52+
/**
53+
* Convert a vector of bytes to a UTF-8 string.
54+
* The vector needs to be one byte longer than the string, and end with a 0 byte.
55+
*
56+
* Compared to `from_bytes()`, this fn doesn't need to allocate a new owned str.
57+
*
58+
* # Failure
59+
*
60+
* Fails if invalid UTF-8
61+
* Fails if not null terminated
62+
*/
63+
pub fn from_bytes_with_null<'a>(vv: &'a [u8]) -> &'a str {
64+
assert!(vv[vv.len() - 1] == 0);
65+
assert!(is_utf8(vv));
66+
return unsafe { raw::from_bytes_with_null(vv) };
67+
}
68+
5269
/// Copy a slice into a new unique str
5370
pub fn from_slice(s: &str) -> ~str {
54-
unsafe { raw::slice_bytes_unique(s, 0, len(s)) }
71+
unsafe { raw::slice_bytes_owned(s, 0, len(s)) }
5572
}
5673

5774
impl ToStr for ~str {
@@ -279,7 +296,7 @@ pub fn pop_char(s: &mut ~str) -> char {
279296
*/
280297
pub fn shift_char(s: &mut ~str) -> char {
281298
let CharRange {ch, next} = char_range_at(*s, 0u);
282-
*s = unsafe { raw::slice_bytes_unique(*s, next, len(*s)) };
299+
*s = unsafe { raw::slice_bytes_owned(*s, next, len(*s)) };
283300
return ch;
284301
}
285302

@@ -784,9 +801,9 @@ pub fn replace(s: &str, from: &str, to: &str) -> ~str {
784801
if first {
785802
first = false;
786803
} else {
787-
unsafe { push_str(&mut result, to); }
804+
push_str(&mut result, to);
788805
}
789-
unsafe { push_str(&mut result, raw::slice_bytes_unique(s, start, end)); }
806+
push_str(&mut result, unsafe{raw::slice_bytes(s, start, end)});
790807
}
791808
result
792809
}
@@ -2037,6 +2054,25 @@ pub fn as_buf<T>(s: &str, f: &fn(*u8, uint) -> T) -> T {
20372054
}
20382055
}
20392056

2057+
/**
2058+
* Returns the byte offset of an inner slice relative to an enclosing outer slice
2059+
*/
2060+
#[inline(always)]
2061+
pub fn subslice_offset(outer: &str, inner: &str) -> uint {
2062+
do as_buf(outer) |a, a_len| {
2063+
do as_buf(inner) |b, b_len| {
2064+
let a_start: uint, a_end: uint, b_start: uint, b_end: uint;
2065+
unsafe {
2066+
a_start = cast::transmute(a); a_end = a_len + cast::transmute(a);
2067+
b_start = cast::transmute(b); b_end = b_len + cast::transmute(b);
2068+
}
2069+
assert!(a_start <= b_start);
2070+
assert!(b_end <= a_end);
2071+
b_start - a_start
2072+
}
2073+
}
2074+
}
2075+
20402076
/**
20412077
* Reserves capacity for exactly `n` bytes in the given string, not including
20422078
* the null terminator.
@@ -2158,13 +2194,20 @@ pub mod raw {
21582194
from_buf_len(::cast::reinterpret_cast(&c_str), len)
21592195
}
21602196

2161-
/// Converts a vector of bytes to a string.
2197+
/// Converts a vector of bytes to a new owned string.
21622198
pub unsafe fn from_bytes(v: &const [u8]) -> ~str {
21632199
do vec::as_const_buf(v) |buf, len| {
21642200
from_buf_len(buf, len)
21652201
}
21662202
}
21672203

2204+
/// Converts a vector of bytes to a string.
2205+
/// The byte slice needs to contain valid utf8 and needs to be one byte longer than
2206+
/// the string, if possible ending in a 0 byte.
2207+
pub unsafe fn from_bytes_with_null<'a>(v: &'a [u8]) -> &'a str {
2208+
cast::transmute(v)
2209+
}
2210+
21682211
/// Converts a byte to a string.
21692212
pub unsafe fn from_byte(u: u8) -> ~str { raw::from_bytes([u]) }
21702213

@@ -2186,7 +2229,7 @@ pub mod raw {
21862229
* If begin is greater than end.
21872230
* If end is greater than the length of the string.
21882231
*/
2189-
pub unsafe fn slice_bytes_unique(s: &str, begin: uint, end: uint) -> ~str {
2232+
pub unsafe fn slice_bytes_owned(s: &str, begin: uint, end: uint) -> ~str {
21902233
do as_buf(s) |sbuf, n| {
21912234
assert!((begin <= end));
21922235
assert!((end <= n));
@@ -2258,7 +2301,7 @@ pub mod raw {
22582301
let len = len(*s);
22592302
assert!((len > 0u));
22602303
let b = s[0];
2261-
*s = unsafe { raw::slice_bytes_unique(*s, 1u, len) };
2304+
*s = unsafe { raw::slice_bytes_owned(*s, 1u, len) };
22622305
return b;
22632306
}
22642307

@@ -3289,6 +3332,66 @@ mod tests {
32893332
let _x = from_bytes(bb);
32903333
}
32913334
3335+
#[test]
3336+
fn test_unsafe_from_bytes_with_null() {
3337+
let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
3338+
let b = unsafe { raw::from_bytes_with_null(a) };
3339+
assert_eq!(b, "AAAAAAA");
3340+
}
3341+
3342+
#[test]
3343+
fn test_from_bytes_with_null() {
3344+
let ss = "ศไทย中华Việt Nam";
3345+
let bb = [0xe0_u8, 0xb8_u8, 0xa8_u8,
3346+
0xe0_u8, 0xb9_u8, 0x84_u8,
3347+
0xe0_u8, 0xb8_u8, 0x97_u8,
3348+
0xe0_u8, 0xb8_u8, 0xa2_u8,
3349+
0xe4_u8, 0xb8_u8, 0xad_u8,
3350+
0xe5_u8, 0x8d_u8, 0x8e_u8,
3351+
0x56_u8, 0x69_u8, 0xe1_u8,
3352+
0xbb_u8, 0x87_u8, 0x74_u8,
3353+
0x20_u8, 0x4e_u8, 0x61_u8,
3354+
0x6d_u8, 0x0_u8];
3355+
3356+
assert_eq!(ss, from_bytes_with_null(bb));
3357+
}
3358+
3359+
#[test]
3360+
#[should_fail]
3361+
#[ignore(cfg(windows))]
3362+
fn test_from_bytes_with_null_fail() {
3363+
let bb = [0xff_u8, 0xb8_u8, 0xa8_u8,
3364+
0xe0_u8, 0xb9_u8, 0x84_u8,
3365+
0xe0_u8, 0xb8_u8, 0x97_u8,
3366+
0xe0_u8, 0xb8_u8, 0xa2_u8,
3367+
0xe4_u8, 0xb8_u8, 0xad_u8,
3368+
0xe5_u8, 0x8d_u8, 0x8e_u8,
3369+
0x56_u8, 0x69_u8, 0xe1_u8,
3370+
0xbb_u8, 0x87_u8, 0x74_u8,
3371+
0x20_u8, 0x4e_u8, 0x61_u8,
3372+
0x6d_u8, 0x0_u8];
3373+
3374+
let _x = from_bytes_with_null(bb);
3375+
}
3376+
3377+
#[test]
3378+
#[should_fail]
3379+
#[ignore(cfg(windows))]
3380+
fn test_from_bytes_with_null_fail_2() {
3381+
let bb = [0xff_u8, 0xb8_u8, 0xa8_u8,
3382+
0xe0_u8, 0xb9_u8, 0x84_u8,
3383+
0xe0_u8, 0xb8_u8, 0x97_u8,
3384+
0xe0_u8, 0xb8_u8, 0xa2_u8,
3385+
0xe4_u8, 0xb8_u8, 0xad_u8,
3386+
0xe5_u8, 0x8d_u8, 0x8e_u8,
3387+
0x56_u8, 0x69_u8, 0xe1_u8,
3388+
0xbb_u8, 0x87_u8, 0x74_u8,
3389+
0x20_u8, 0x4e_u8, 0x61_u8,
3390+
0x6d_u8, 0x60_u8];
3391+
3392+
let _x = from_bytes_with_null(bb);
3393+
}
3394+
32923395
#[test]
32933396
fn test_from_buf() {
32943397
unsafe {
@@ -3351,6 +3454,23 @@ mod tests {
33513454
}
33523455
}
33533456
3457+
#[test]
3458+
fn test_subslice_offset() {
3459+
let a = "kernelsprite";
3460+
let b = slice(a, 7, len(a));
3461+
let c = slice(a, 0, len(a) - 6);
3462+
assert!(subslice_offset(a, b) == 7);
3463+
assert!(subslice_offset(a, c) == 0);
3464+
}
3465+
3466+
#[test]
3467+
#[should_fail]
3468+
fn test_subslice_offset_2() {
3469+
let a = "alchemiter";
3470+
let b = "cruxtruder";
3471+
subslice_offset(a, b);
3472+
}
3473+
33543474
#[test]
33553475
fn vec_str_conversions() {
33563476
let s1: ~str = ~"All mimsy were the borogoves";

branches/dist-snap/src/libfuzzer/fuzzer.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
#[link(name = "fuzzer",
13-
vers = "0.7-pre",
13+
vers = "0.7-rc",
1414
uuid = "d6418797-2736-4833-bd82-d3c684b7c1b0",
1515
url = "https://github.com/mozilla/rust/tree/master/src/libfuzzer")];
1616

@@ -26,9 +26,9 @@
2626
#[allow(deprecated_mode)];
2727
#[allow(deprecated_pattern)];
2828

29-
extern mod core(vers = "0.7-pre");
30-
extern mod std(vers = "0.7-pre");
31-
extern mod syntax(vers = "0.7-pre");
29+
extern mod core(vers = "0.7-rc");
30+
extern mod std(vers = "0.7-rc");
31+
extern mod syntax(vers = "0.7-rc");
3232

3333
use core::*;
3434
use core::io::WriterUtil;

branches/dist-snap/src/librust/rust.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
// FIXME #2238 Make run only accept source that emits an executable
1414

1515
#[link(name = "rust",
16-
vers = "0.7-pre",
16+
vers = "0.7-rc",
1717
uuid = "4a24da33-5cc8-4037-9352-2cbe9bd9d27c",
1818
url = "https://github.com/mozilla/rust/tree/master/src/rust")];
1919

2020
#[license = "MIT/ASL2"];
2121
#[crate_type = "lib"];
2222

23-
extern mod core(vers = "0.7-pre");
23+
extern mod core(vers = "0.7-rc");
2424

2525
use core::run;
2626

branches/dist-snap/src/librustc/front/core_inject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use syntax::codemap;
1919
use syntax::codemap::dummy_sp;
2020
use syntax::fold;
2121

22-
static CORE_VERSION: &'static str = "0.7-pre";
22+
static CORE_VERSION: &'static str = "0.7-rc";
2323

2424
pub fn maybe_inject_libcore_ref(sess: Session,
2525
crate: @ast::crate) -> @ast::crate {

branches/dist-snap/src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ mod __test {
265265
*/
266266

267267
fn mk_std(cx: &TestCtxt) -> @ast::view_item {
268-
let vers = ast::lit_str(@~"0.7-pre");
268+
let vers = ast::lit_str(@~"0.7-rc");
269269
let vers = nospan(vers);
270270
let mi = ast::meta_name_value(@~"vers", vers);
271271
let mi = nospan(mi);

branches/dist-snap/src/librustc/rustc.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
#[link(name = "rustc",
13-
vers = "0.7-pre",
13+
vers = "0.7-rc",
1414
uuid = "0ce89b41-2f92-459e-bbc1-8f5fe32f16cf",
1515
url = "https://github.com/mozilla/rust/tree/master/src/rustc")];
1616

@@ -27,9 +27,9 @@
2727

2828
#[no_core];
2929

30-
extern mod core(vers = "0.7-pre");
31-
extern mod std(vers = "0.7-pre");
32-
extern mod syntax(vers = "0.7-pre");
30+
extern mod core(vers = "0.7-rc");
31+
extern mod std(vers = "0.7-rc");
32+
extern mod syntax(vers = "0.7-rc");
3333

3434
use core::prelude::*;
3535

branches/dist-snap/src/librustdoc/rustdoc.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Rustdoc - The Rust documentation generator
1212

1313
#[link(name = "rustdoc",
14-
vers = "0.7-pre",
14+
vers = "0.7-rc",
1515
uuid = "f8abd014-b281-484d-a0c3-26e3de8e2412",
1616
url = "https://github.com/mozilla/rust/tree/master/src/rustdoc")];
1717

@@ -23,10 +23,10 @@
2323

2424
#[allow(non_implicitly_copyable_typarams)];
2525

26-
extern mod core(vers = "0.7-pre");
27-
extern mod std(vers = "0.7-pre");
28-
extern mod rustc(vers = "0.7-pre");
29-
extern mod syntax(vers = "0.7-pre");
26+
extern mod core(vers = "0.7-rc");
27+
extern mod std(vers = "0.7-rc");
28+
extern mod rustc(vers = "0.7-rc");
29+
extern mod syntax(vers = "0.7-rc");
3030

3131
use config::Config;
3232
use doc::Item;

0 commit comments

Comments
 (0)