Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just testing bots #18503

Closed
wants to merge 14 commits into from
Closed
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ fn _arm_exec_compiled_test(config: &Config,

let mut exitcode: int = 0;
for c in exitcode_out.as_slice().chars() {
if !c.is_digit() { break; }
if !c.is_numeric() { break; }
exitcode = exitcode * 10 + match c {
'0' ... '9' => c as int - ('0' as int),
_ => 101,
Expand Down
14 changes: 9 additions & 5 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,9 @@ pub trait StrAllocating: Str {
let me = self.as_slice();
let mut out = String::with_capacity(me.len());
for c in me.chars() {
c.escape_default(|c| out.push(c));
for c in c.escape_default() {
out.push(c);
}
}
out
}
Expand All @@ -708,7 +710,9 @@ pub trait StrAllocating: Str {
let me = self.as_slice();
let mut out = String::with_capacity(me.len());
for c in me.chars() {
c.escape_unicode(|c| out.push(c));
for c in c.escape_unicode() {
out.push(c);
}
}
out
}
Expand Down Expand Up @@ -1273,7 +1277,7 @@ mod tests {
assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11");
let chars: &[char] = &['1', '2'];
assert_eq!("12foo1bar12".trim_left_chars(chars), "foo1bar12");
assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_digit()), "foo1bar123");
assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_numeric()), "foo1bar123");
}

#[test]
Expand All @@ -1288,7 +1292,7 @@ mod tests {
assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar");
let chars: &[char] = &['1', '2'];
assert_eq!("12foo1bar12".trim_right_chars(chars), "12foo1bar");
assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_digit()), "123foo1bar");
assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_numeric()), "123foo1bar");
}

#[test]
Expand All @@ -1303,7 +1307,7 @@ mod tests {
assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar");
let chars: &[char] = &['1', '2'];
assert_eq!("12foo1bar12".trim_chars(chars), "foo1bar");
assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_digit()), "foo1bar");
assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_numeric()), "foo1bar");
}

#[test]
Expand Down
24 changes: 11 additions & 13 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ use core::fmt;
use core::mem;
use core::ptr;
use core::ops;
// FIXME: ICE's abound if you import the `Slice` type while importing `Slice` trait
use core::raw::Slice as RawSlice;

use {Mutable, MutableSeq};
use hash;
Expand Down Expand Up @@ -540,12 +538,13 @@ impl String {
unsafe {
// Attempt to not use an intermediate buffer by just pushing bytes
// directly onto this string.
let slice = RawSlice {
data: self.vec.as_ptr().offset(cur_len as int),
len: 4,
};
let used = ch.encode_utf8(mem::transmute(slice)).unwrap_or(0);
self.vec.set_len(cur_len + used);
let buf = self.vec.as_mut_ptr().offset(cur_len as int);
let mut used = 0;
for byte in ch.encode_utf8() {
*buf.offset(used) = byte;
used += 1;
}
self.vec.set_len(cur_len + (used as uint));
}
}

Expand Down Expand Up @@ -798,16 +797,15 @@ impl String {
assert!(idx <= len);
assert!(self.as_slice().is_char_boundary(idx));
self.vec.reserve_additional(4);
let mut bits = [0, ..4];
let amt = ch.encode_utf8(bits).unwrap();
let amt = ch.len_utf8();

unsafe {
ptr::copy_memory(self.vec.as_mut_ptr().offset((idx + amt) as int),
self.vec.as_ptr().offset(idx as int),
len - idx);
ptr::copy_memory(self.vec.as_mut_ptr().offset(idx as int),
bits.as_ptr(),
amt);
for (i, byte) in ch.encode_utf8().enumerate() {
*self.vec.as_mut_ptr().offset((idx + i) as int) = byte
}
self.vec.set_len(len + amt);
}
}
Expand Down
Loading