Skip to content

Commit bd72d7c

Browse files
committed
---
yaml --- r: 53980 b: refs/heads/dist-snap c: 4b0f29a h: refs/heads/master v: v3
1 parent 3897322 commit bd72d7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2115
-2380
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: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 63a292fd8686f56efe7836aef46709a063efab4e
10+
refs/heads/dist-snap: 4b0f29a4669491348e963f86de7f6ccc9d666e60
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,9 @@ pub mod funcs {
12211221
#[nolink]
12221222
#[abi = "cdecl"]
12231223
pub mod fcntl {
1224-
use libc::types::os::arch::c95::{c_int, c_char};
12251224
pub extern {
1225+
use libc::types::os::arch::c95::{c_int, c_char};
1226+
12261227
#[link_name = "_open"]
12271228
unsafe fn open(path: *c_char, oflag: c_int, mode: c_int)
12281229
-> c_int;
@@ -1561,11 +1562,11 @@ pub mod funcs {
15611562
#[cfg(target_os = "macos")]
15621563
#[cfg(target_os = "freebsd")]
15631564
pub mod bsd44 {
1564-
use libc::types::common::c95::{c_void};
1565-
use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
1566-
15671565
#[abi = "cdecl"]
15681566
pub extern {
1567+
use libc::types::common::c95::{c_void};
1568+
use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
1569+
15691570
unsafe fn sysctl(name: *c_int, namelen: c_uint,
15701571
oldp: *mut c_void, oldlenp: *mut size_t,
15711572
newp: *c_void, newlen: size_t) -> c_int;

branches/dist-snap/src/libcore/rt/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ pub fn get() -> &Environment {
4444

4545
extern {
4646
fn rust_get_rt_env() -> &Environment;
47-
}
47+
}

branches/dist-snap/src/libcore/rt/sched.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ enum CleanupJob {
7070

7171
pub impl Scheduler {
7272

73-
static pub fn new(event_loop: ~EventLoopObject) -> Scheduler {
73+
static fn new(event_loop: ~EventLoopObject) -> Scheduler {
7474
Scheduler {
7575
event_loop: event_loop,
7676
task_queue: WorkQueue::new(),
@@ -296,7 +296,7 @@ pub struct Task {
296296
}
297297

298298
impl Task {
299-
static pub fn new(stack_pool: &mut StackPool, start: ~fn()) -> Task {
299+
static fn new(stack_pool: &mut StackPool, start: ~fn()) -> Task {
300300
// XXX: Putting main into a ~ so it's a thin pointer and can
301301
// be passed to the spawn function. Another unfortunate
302302
// allocation

branches/dist-snap/src/libcore/rt/stack.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ pub impl StackSegment {
3737
pub struct StackPool(());
3838

3939
impl StackPool {
40-
static pub fn new() -> StackPool { StackPool(()) }
40+
41+
static fn new() -> StackPool { StackPool(()) }
4142

4243
fn take_segment(&self, min_size: uint) -> StackSegment {
4344
StackSegment::new(min_size)

branches/dist-snap/src/libcore/rt/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Thread {
2020
}
2121

2222
impl Thread {
23-
static pub fn start(main: ~fn()) -> Thread {
23+
static fn start(main: ~fn()) -> Thread {
2424
fn substart(main: &fn()) -> *raw_thread {
2525
unsafe { rust_raw_thread_start(&main) }
2626
}

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,7 @@ pub pure fn char_range_at(s: &str, i: uint) -> CharRange {
17691769
return CharRange {ch: val as char, next: i};
17701770
}
17711771

1772-
/// Pluck a character out of a string
1772+
/// Plucks the `n`th character from the beginning of a string
17731773
pub pure fn char_at(s: &str, i: uint) -> char {
17741774
return char_range_at(s, i).ch;
17751775
}
@@ -1799,6 +1799,11 @@ pure fn char_range_at_reverse(ss: &str, start: uint) -> CharRange {
17991799
return CharRange {ch:ch, next:prev};
18001800
}
18011801

1802+
/// Plucks the `n`th character from the end of a string
1803+
pub pure fn char_at_reverse(s: &str, i: uint) -> char {
1804+
char_range_at_reverse(s, i).ch
1805+
}
1806+
18021807
/**
18031808
* Loop through a substring, char by char
18041809
*
@@ -2274,6 +2279,7 @@ pub trait StrSlice {
22742279
pure fn to_owned(&self) -> ~str;
22752280
pure fn to_managed(&self) -> @str;
22762281
pure fn char_at(&self, i: uint) -> char;
2282+
pure fn char_at_reverse(&self, i: uint) -> char;
22772283
fn to_bytes(&self) -> ~[u8];
22782284
}
22792285
@@ -2419,6 +2425,11 @@ impl StrSlice for &'self str {
24192425
#[inline]
24202426
pure fn char_at(&self, i: uint) -> char { char_at(*self, i) }
24212427
2428+
#[inline]
2429+
pure fn char_at_reverse(&self, i: uint) -> char {
2430+
char_at_reverse(*self, i)
2431+
}
2432+
24222433
fn to_bytes(&self) -> ~[u8] { to_bytes(*self) }
24232434
}
24242435
@@ -3426,6 +3437,28 @@ mod tests {
34263437
}
34273438
}
34283439

3440+
#[test]
3441+
fn test_char_at() {
3442+
let s = ~"ศไทย中华Việt Nam";
3443+
let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
3444+
let mut pos = 0;
3445+
for v.each |ch| {
3446+
fail_unless!(s.char_at(pos) == *ch);
3447+
pos += from_char(*ch).len();
3448+
}
3449+
}
3450+
3451+
#[test]
3452+
fn test_char_at_reverse() {
3453+
let s = ~"ศไทย中华Việt Nam";
3454+
let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
3455+
let mut pos = s.len();
3456+
for v.each_reverse |ch| {
3457+
fail_unless!(s.char_at_reverse(pos) == *ch);
3458+
pos -= from_char(*ch).len();
3459+
}
3460+
}
3461+
34293462
#[test]
34303463
fn test_each_char() {
34313464
let s = ~"abc";

branches/dist-snap/src/libcore/task/rt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub type rust_task = libc::c_void;
3030
#[allow(non_camel_case_types)] // runtime type
3131
pub type rust_closure = libc::c_void;
3232

33-
pub extern {
33+
extern {
3434
#[rust_stack]
3535
fn rust_task_yield(task: *rust_task) -> bool;
3636

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

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ pub pure fn foldl<T, U>(z: T, v: &[U], p: &fn(t: T, u: &U) -> T) -> T {
10051005
*/
10061006
pub pure fn foldr<T, U: Copy>(v: &[T], z: U, p: &fn(t: &T, u: U) -> U) -> U {
10071007
let mut accum = z;
1008-
for rev_each(v) |elt| {
1008+
for v.each_reverse |elt| {
10091009
accum = p(elt, accum);
10101010
}
10111011
accum
@@ -1411,8 +1411,8 @@ pub pure fn eachi<T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) {
14111411
* Return true to continue, false to break.
14121412
*/
14131413
#[inline(always)]
1414-
pub pure fn rev_each<T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) {
1415-
rev_eachi(v, |_i, v| blk(v))
1414+
pub pure fn each_reverse<T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) {
1415+
eachi_reverse(v, |_i, v| blk(v))
14161416
}
14171417

14181418
/**
@@ -1421,7 +1421,7 @@ pub pure fn rev_each<T>(v: &'r [T], blk: &fn(v: &'r T) -> bool) {
14211421
* Return true to continue, false to break.
14221422
*/
14231423
#[inline(always)]
1424-
pub pure fn rev_eachi<T>(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) {
1424+
pub pure fn eachi_reverse<T>(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) {
14251425
let mut i = v.len();
14261426
while i > 0 {
14271427
i -= 1;
@@ -1736,6 +1736,8 @@ pub trait ImmutableVector<T> {
17361736
pure fn initn(&self, n: uint) -> &'self [T];
17371737
pure fn last(&self) -> &'self T;
17381738
pure fn last_opt(&self) -> Option<&'self T>;
1739+
pure fn each_reverse(&self, blk: &fn(&T) -> bool);
1740+
pure fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool);
17391741
pure fn foldr<U: Copy>(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U;
17401742
pure fn map<U>(&self, f: &fn(t: &T) -> U) -> ~[U];
17411743
pure fn mapi<U>(&self, f: &fn(uint, t: &T) -> U) -> ~[U];
@@ -1785,6 +1787,18 @@ impl<T> ImmutableVector<T> for &'self [T] {
17851787
#[inline]
17861788
pure fn last_opt(&self) -> Option<&'self T> { last_opt(*self) }
17871789

1790+
/// Iterates over a vector's elements in reverse.
1791+
#[inline]
1792+
pure fn each_reverse(&self, blk: &fn(&T) -> bool) {
1793+
each_reverse(*self, blk)
1794+
}
1795+
1796+
/// Iterates over a vector's elements and indices in reverse.
1797+
#[inline]
1798+
pure fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) {
1799+
eachi_reverse(*self, blk)
1800+
}
1801+
17881802
/// Reduce a vector from right to left
17891803
#[inline]
17901804
pure fn foldr<U:Copy>(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U {
@@ -3131,33 +3145,42 @@ mod tests {
31313145
}
31323146

31333147
#[test]
3134-
fn test_reach_empty() {
3135-
for rev_each::<int>(~[]) |_v| {
3148+
fn test_each_reverse_empty() {
3149+
let v: ~[int] = ~[];
3150+
for v.each_reverse |_v| {
31363151
fail!(); // should never execute
31373152
}
31383153
}
31393154

31403155
#[test]
3141-
fn test_reach_nonempty() {
3156+
fn test_each_reverse_nonempty() {
31423157
let mut i = 0;
3143-
for rev_each(~[1, 2, 3]) |v| {
3158+
for each_reverse(~[1, 2, 3]) |v| {
31443159
if i == 0 { fail_unless!(*v == 3); }
31453160
i += *v
31463161
}
31473162
fail_unless!(i == 6);
31483163
}
31493164

31503165
#[test]
3151-
fn test_reachi() {
3166+
fn test_eachi_reverse() {
31523167
let mut i = 0;
3153-
for rev_eachi(~[0, 1, 2]) |j, v| {
3168+
for eachi_reverse(~[0, 1, 2]) |j, v| {
31543169
if i == 0 { fail_unless!(*v == 2); }
31553170
fail_unless!(j == *v as uint);
31563171
i += *v;
31573172
}
31583173
fail_unless!(i == 3);
31593174
}
31603175

3176+
#[test]
3177+
fn test_eachi_reverse_empty() {
3178+
let v: ~[int] = ~[];
3179+
for v.eachi_reverse |_i, _v| {
3180+
fail!(); // should never execute
3181+
}
3182+
}
3183+
31613184
#[test]
31623185
fn test_each_permutation() {
31633186
let mut results: ~[~[int]];

0 commit comments

Comments
 (0)