Skip to content

Commit 8d6e575

Browse files
committed
---
yaml --- r: 71990 b: refs/heads/dist-snap c: 59e69aa h: refs/heads/master v: v3
1 parent 41a017a commit 8d6e575

Some content is hidden

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

77 files changed

+1615
-2224
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: 685c4d0b76b26439905b0676069818e757913319
10+
refs/heads/dist-snap: 59e69aa0e79302887abcb4b6bf3613c84b48e5d7
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/compiletest/errors.rs

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,34 @@ pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
3030
}
3131

3232
fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {
33-
unsafe {
34-
let error_tag = ~"//~";
35-
let mut idx;
36-
match str::find_str(line, error_tag) {
37-
None => return ~[],
38-
Some(nn) => { idx = (nn as uint) + str::len(error_tag); }
39-
}
33+
let error_tag = ~"//~";
34+
let mut idx;
35+
match str::find_str(line, error_tag) {
36+
None => return ~[],
37+
Some(nn) => { idx = (nn as uint) + str::len(error_tag); }
38+
}
4039

41-
// "//~^^^ kind msg" denotes a message expected
42-
// three lines above current line:
43-
let mut adjust_line = 0u;
44-
let len = str::len(line);
45-
while idx < len && line[idx] == ('^' as u8) {
46-
adjust_line += 1u;
47-
idx += 1u;
48-
}
40+
// "//~^^^ kind msg" denotes a message expected
41+
// three lines above current line:
42+
let mut adjust_line = 0u;
43+
let len = str::len(line);
44+
while idx < len && line[idx] == ('^' as u8) {
45+
adjust_line += 1u;
46+
idx += 1u;
47+
}
4948

50-
// Extract kind:
51-
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
52-
let start_kind = idx;
53-
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
54-
let kind = str::to_lower(str::slice(line, start_kind, idx).to_owned());
49+
// Extract kind:
50+
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
51+
let start_kind = idx;
52+
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
53+
let kind = str::to_lower(str::slice(line, start_kind, idx).to_owned());
5554

56-
// Extract msg:
57-
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
58-
let msg = str::slice(line, idx, len).to_owned();
55+
// Extract msg:
56+
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
57+
let msg = str::slice(line, idx, len).to_owned();
5958

60-
debug!("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
59+
debug!("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
6160

62-
return ~[ExpectedError{line: line_num - adjust_line, kind: kind,
63-
msg: msg}];
64-
}
61+
return ~[ExpectedError{line: line_num - adjust_line, kind: kind,
62+
msg: msg}];
6563
}

branches/dist-snap/src/compiletest/header.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,14 @@ fn parse_name_directive(line: ~str, directive: ~str) -> bool {
171171

172172
fn parse_name_value_directive(line: ~str,
173173
directive: ~str) -> Option<~str> {
174-
unsafe {
175-
let keycolon = directive + ~":";
176-
match str::find_str(line, keycolon) {
177-
Some(colon) => {
178-
let value = str::slice(line, colon + str::len(keycolon),
179-
str::len(line)).to_owned();
180-
debug!("%s: %s", directive, value);
181-
Some(value)
182-
}
183-
None => None
174+
let keycolon = directive + ~":";
175+
match str::find_str(line, keycolon) {
176+
Some(colon) => {
177+
let value = str::slice(line, colon + str::len(keycolon),
178+
str::len(line)).to_owned();
179+
debug!("%s: %s", directive, value);
180+
Some(value)
184181
}
182+
None => None
185183
}
186184
}

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,14 @@ impl<T: Owned> Peekable<T> for Port<T> {
188188
189189
#[inline(always)]
190190
fn port_peek<T:Owned>(self: &Port<T>) -> bool {
191-
unsafe {
192-
let mut endp = None;
193-
endp <-> self.endp;
194-
let peek = match &endp {
195-
&Some(ref endp) => peek(endp),
196-
&None => fail!(~"peeking empty stream")
197-
};
198-
self.endp <-> endp;
199-
peek
200-
}
191+
let mut endp = None;
192+
endp <-> self.endp;
193+
let peek = match &endp {
194+
&Some(ref endp) => peek(endp),
195+
&None => fail!(~"peeking empty stream")
196+
};
197+
self.endp <-> endp;
198+
peek
201199
}
202200
203201
impl<T: Owned> Selectable for Port<T> {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub use vec::{OwnedVector, OwnedCopyableVector};
9999
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
100100
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
101101

102-
pub use num::NumCast;
102+
pub use num::{Num, NumCast};
103103
pub use ptr::Ptr;
104104
pub use to_str::ToStr;
105105
pub use clone::Clone;
@@ -176,6 +176,7 @@ pub mod from_str;
176176
#[path = "num/num.rs"]
177177
pub mod num;
178178
pub mod iter;
179+
pub mod iterator;
179180
pub mod to_str;
180181
pub mod to_bytes;
181182
pub mod clone;

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,11 +1536,8 @@ pub fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] {
15361536
pub fn with_str_writer(f: &fn(@Writer)) -> ~str {
15371537
let mut v = with_bytes_writer(f);
15381538
1539-
// FIXME (#3758): This should not be needed.
1540-
unsafe {
1541-
// Make sure the vector has a trailing null and is proper utf8.
1542-
v.push(0);
1543-
}
1539+
// Make sure the vector has a trailing null and is proper utf8.
1540+
v.push(0);
15441541
assert!(str::is_utf8(v));
15451542
15461543
unsafe { ::cast::transmute(v) }
@@ -1640,16 +1637,14 @@ pub mod fsync {
16401637
// outer res
16411638
pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>,
16421639
blk: &fn(v: Res<*libc::FILE>)) {
1643-
unsafe {
1644-
blk(Res(Arg {
1645-
val: file.f, opt_level: opt_level,
1646-
fsync_fn: |file, l| {
1647-
unsafe {
1648-
os::fsync_fd(libc::fileno(file), l) as int
1649-
}
1640+
blk(Res(Arg {
1641+
val: file.f, opt_level: opt_level,
1642+
fsync_fn: |file, l| {
1643+
unsafe {
1644+
os::fsync_fd(libc::fileno(file), l) as int
16501645
}
1651-
}));
1652-
}
1646+
}
1647+
}));
16531648
}
16541649

16551650
// fsync fd after executing blk

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B, blk: &fn(&B, &A) -> B)
161161

162162
#[inline(always)]
163163
pub fn to_vec<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] {
164-
foldl::<A,~[A],IA>(self, ~[], |r, a| vec::append(copy (*r), ~[*a]))
164+
map_to_vec(self, |&x| x)
165165
}
166166

167167
#[inline(always)]
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Composable iterator objects
12+
13+
use prelude::*;
14+
15+
pub trait Iterator<T> {
16+
/// Advance the iterator and return the next value. Return `None` when the end is reached.
17+
fn next(&mut self) -> Option<T>;
18+
}
19+
20+
/// A shim implementing the `for` loop iteration protocol for iterator objects
21+
#[inline]
22+
pub fn advance<T, U: Iterator<T>>(iter: &mut U, f: &fn(T) -> bool) {
23+
loop {
24+
match iter.next() {
25+
Some(x) => {
26+
if !f(x) { return }
27+
}
28+
None => return
29+
}
30+
}
31+
}
32+
33+
pub struct ZipIterator<T, U> {
34+
priv a: T,
35+
priv b: U
36+
}
37+
38+
pub impl<A, B, T: Iterator<A>, U: Iterator<B>> ZipIterator<T, U> {
39+
#[inline(always)]
40+
fn new(a: T, b: U) -> ZipIterator<T, U> {
41+
ZipIterator{a: a, b: b}
42+
}
43+
}
44+
45+
impl<A, B, T: Iterator<A>, U: Iterator<B>> Iterator<(A, B)> for ZipIterator<T, U> {
46+
#[inline]
47+
fn next(&mut self) -> Option<(A, B)> {
48+
match (self.a.next(), self.b.next()) {
49+
(Some(x), Some(y)) => Some((x, y)),
50+
_ => None
51+
}
52+
}
53+
}
54+
55+
pub struct FilterIterator<'self, A, T> {
56+
priv iter: T,
57+
priv predicate: &'self fn(&A) -> bool
58+
}
59+
60+
pub impl<'self, A, T: Iterator<A>> FilterIterator<'self, A, T> {
61+
#[inline(always)]
62+
fn new(iter: T, predicate: &'self fn(&A) -> bool) -> FilterIterator<'self, A, T> {
63+
FilterIterator{iter: iter, predicate: predicate}
64+
}
65+
}
66+
67+
impl<'self, A, T: Iterator<A>> Iterator<A> for FilterIterator<'self, A, T> {
68+
#[inline]
69+
fn next(&mut self) -> Option<A> {
70+
for advance(self) |x| {
71+
if (self.predicate)(&x) {
72+
return Some(x);
73+
} else {
74+
loop
75+
}
76+
}
77+
None
78+
}
79+
}
80+
81+
pub struct MapIterator<'self, A, B, T> {
82+
priv iter: T,
83+
priv f: &'self fn(A) -> B
84+
}
85+
86+
pub impl<'self, A, B, T: Iterator<A>> MapIterator<'self, A, B, T> {
87+
#[inline(always)]
88+
fn new(iter: T, f: &'self fn(A) -> B) -> MapIterator<'self, A, B, T> {
89+
MapIterator{iter: iter, f: f}
90+
}
91+
}
92+
93+
impl<'self, A, B, T: Iterator<A>> Iterator<B> for MapIterator<'self, A, B, T> {
94+
#[inline]
95+
fn next(&mut self) -> Option<B> {
96+
match self.iter.next() {
97+
Some(a) => Some((self.f)(a)),
98+
_ => None
99+
}
100+
}
101+
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,8 @@ pub mod consts {
863863
pub static F_TEST : int = 3;
864864
pub static F_TLOCK : int = 2;
865865
pub static F_ULOCK : int = 0;
866+
pub static SIGKILL : int = 9;
867+
pub static SIGTERM : int = 15;
866868
}
867869
pub mod posix01 {
868870
}
@@ -930,6 +932,8 @@ pub mod consts {
930932
pub static F_TEST : int = 3;
931933
pub static F_TLOCK : int = 2;
932934
pub static F_ULOCK : int = 0;
935+
pub static SIGKILL : int = 9;
936+
pub static SIGTERM : int = 15;
933937
}
934938
pub mod posix01 {
935939
}
@@ -998,6 +1002,8 @@ pub mod consts {
9981002
pub static F_TEST : int = 3;
9991003
pub static F_TLOCK : int = 2;
10001004
pub static F_ULOCK : int = 0;
1005+
pub static SIGKILL : int = 9;
1006+
pub static SIGTERM : int = 15;
10011007
}
10021008
pub mod posix01 {
10031009
}
@@ -1482,6 +1488,17 @@ pub mod funcs {
14821488
-> ssize_t;
14831489
}
14841490
}
1491+
1492+
#[nolink]
1493+
#[abi = "cdecl"]
1494+
pub mod signal {
1495+
use libc::types::os::arch::c95::{c_int};
1496+
use libc::types::os::arch::posix88::{pid_t};
1497+
1498+
pub extern {
1499+
unsafe fn kill(pid: pid_t, sig: c_int) -> c_int;
1500+
}
1501+
}
14851502
}
14861503

14871504
#[cfg(target_os = "linux")]
@@ -1623,6 +1640,7 @@ pub mod funcs {
16231640
pub mod extra {
16241641

16251642
pub mod kernel32 {
1643+
use libc::types::os::arch::c95::{c_uint};
16261644
use libc::types::os::arch::extra::{BOOL, DWORD, HMODULE};
16271645
use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPTCH};
16281646
use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES};
@@ -1663,6 +1681,7 @@ pub mod funcs {
16631681
findFileData: HANDLE)
16641682
-> BOOL;
16651683
unsafe fn FindClose(findFile: HANDLE) -> BOOL;
1684+
unsafe fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) -> BOOL;
16661685
}
16671686
}
16681687

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ pub mod raw {
3838
#[inline(always)]
3939
pub fn ptr_eq<T>(a: @T, b: @T) -> bool {
4040
//! Determine if two shared boxes point to the same object
41-
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
41+
ptr::addr_of(&(*a)) == ptr::addr_of(&(*b))
4242
}
4343

4444
#[inline(always)]
4545
pub fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
4646
//! Determine if two mutable shared boxes point to the same object
47-
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
47+
ptr::addr_of(&(*a)) == ptr::addr_of(&(*b))
4848
}
4949

5050
#[cfg(notest)]

0 commit comments

Comments
 (0)