Skip to content

Commit ab37e61

Browse files
committed
---
yaml --- r: 56214 b: refs/heads/auto c: c967f2b h: refs/heads/master v: v3
1 parent 414d4f2 commit ab37e61

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 938ddeeed672078a63f620d1408370539d49b2bf
17+
refs/heads/auto: c967f2bb1e564cb4344ac3df87c9b52399f65d7d
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libcore/str.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use clone::Clone;
2424
use cmp::{TotalOrd, Ordering, Less, Equal, Greater};
2525
use libc;
2626
use option::{None, Option, Some};
27+
use iterator::Iterator;
2728
use ptr;
2829
use str;
2930
use u8;
@@ -2358,6 +2359,10 @@ pub trait StrSlice<'self> {
23582359
fn any(&self, it: &fn(char) -> bool) -> bool;
23592360
fn contains<'a>(&self, needle: &'a str) -> bool;
23602361
fn contains_char(&self, needle: char) -> bool;
2362+
#[cfg(stage1)]
2363+
#[cfg(stage2)]
2364+
#[cfg(stage3)]
2365+
fn char_iter(&self) -> StrCharIterator<'self>;
23612366
fn each(&self, it: &fn(u8) -> bool);
23622367
fn eachi(&self, it: &fn(uint, u8) -> bool);
23632368
fn each_reverse(&self, it: &fn(u8) -> bool);
@@ -2419,6 +2424,18 @@ impl<'self> StrSlice<'self> for &'self str {
24192424
fn contains_char(&self, needle: char) -> bool {
24202425
contains_char(*self, needle)
24212426
}
2427+
2428+
#[cfg(stage1)]
2429+
#[cfg(stage2)]
2430+
#[cfg(stage3)]
2431+
#[inline]
2432+
fn char_iter(&self) -> StrCharIterator<'self> {
2433+
StrCharIterator {
2434+
index: 0,
2435+
string: *self
2436+
}
2437+
}
2438+
24222439
/// Iterate over the bytes in a string
24232440
#[inline]
24242441
fn each(&self, it: &fn(u8) -> bool) { each(*self, it) }
@@ -2609,6 +2626,30 @@ impl Clone for ~str {
26092626
}
26102627
}
26112628
2629+
#[cfg(stage1)]
2630+
#[cfg(stage2)]
2631+
#[cfg(stage3)]
2632+
pub struct StrCharIterator<'self> {
2633+
priv index: uint,
2634+
priv string: &'self str,
2635+
}
2636+
2637+
#[cfg(stage1)]
2638+
#[cfg(stage2)]
2639+
#[cfg(stage3)]
2640+
impl<'self> Iterator<char> for StrCharIterator<'self> {
2641+
#[inline]
2642+
fn next(&mut self) -> Option<char> {
2643+
if self.index < self.string.len() {
2644+
let CharRange {ch, next} = char_range_at(self.string, self.index);
2645+
self.index = next;
2646+
Some(ch)
2647+
} else {
2648+
None
2649+
}
2650+
}
2651+
}
2652+
26122653
#[cfg(test)]
26132654
mod tests {
26142655
use char;
@@ -3901,4 +3942,19 @@ mod tests {
39013942
assert!(char_range_at_reverse("abc", 0).next == 0);
39023943
}
39033944
3945+
#[test]
3946+
fn test_iterator() {
3947+
use iterator::*;
3948+
let s = ~"ศไทย中华Việt Nam";
3949+
let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
3950+
3951+
let mut pos = 0;
3952+
let mut it = s.char_iter();
3953+
3954+
for it.advance |c| {
3955+
assert_eq!(c, v[pos]);
3956+
pos += 1;
3957+
}
3958+
assert_eq!(pos, v.len());
3959+
}
39043960
}

branches/auto/src/libcore/task/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,8 @@ pub fn spawn_unlinked(f: ~fn()) {
466466
467467
pub fn spawn_supervised(f: ~fn()) {
468468
/*!
469-
* Creates a child task supervised by the current one. If the child
470-
* task fails, the parent will not be killed, but if the parent fails,
471-
* the child will be killed.
469+
* Creates a child task unlinked from the current one. If either this
470+
* task or the child task fails, the other will not be killed.
472471
*/
473472
474473
task().supervised().spawn(f)

branches/auto/src/rt/rust_exchange_alloc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ rust_get_exchange_count_ptr() {
4848
void
4949
rust_check_exchange_count_on_exit() {
5050
if (exchange_count != 0) {
51-
printf("exchange heap not empty on exit\n");
52-
printf("%d dangling allocations\n", (int)exchange_count);
51+
printf("exchange heap not empty on on exit");
52+
printf("%d dangling allocations", (int)exchange_count);
5353
abort();
5454
}
5555
}

0 commit comments

Comments
 (0)