Skip to content

Just testing bots #18503

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

Closed
wants to merge 14 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
@@ -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,
14 changes: 9 additions & 5 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
@@ -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
}
@@ -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
}
@@ -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]
@@ -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]
@@ -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]
24 changes: 11 additions & 13 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
@@ -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;
@@ -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));
}
}

@@ -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);
}
}
Loading