Skip to content

Commit b3610bd

Browse files
committed
---
yaml --- r: 80799 b: refs/heads/try c: a7e49d6 h: refs/heads/master i: 80797: 1afdabc 80795: fa9b277 80791: fb3d9d0 80783: 2b5e242 80767: 3493960 v: v3
1 parent cab68a4 commit b3610bd

File tree

13 files changed

+448
-87
lines changed

13 files changed

+448
-87
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cbd1eefbd350797b783df119fed7956d7e1c74ad
5-
refs/heads/try: 6e3d5c62e79026920d09833889ea837b19b0a9d0
5+
refs/heads/try: a7e49d6e83f61989b2456c213daeb7461d9ee606
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libextra/crypto/md5.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::iter::range_step;
11+
use std::uint;
1212

1313
use cryptoutil::{write_u32_le, read_u32v_le, FixedBuffer, FixedBuffer64, StandardPadding};
1414
use digest::Digest;
@@ -86,42 +86,46 @@ impl Md5State {
8686
read_u32v_le(data, input);
8787

8888
// round 1
89-
for i in range_step(0u, 16, 4) {
89+
do uint::range_step(0, 16, 4) |i| {
9090
a = op_f(a, b, c, d, data[i] + C1[i], 7);
9191
d = op_f(d, a, b, c, data[i + 1] + C1[i + 1], 12);
9292
c = op_f(c, d, a, b, data[i + 2] + C1[i + 2], 17);
9393
b = op_f(b, c, d, a, data[i + 3] + C1[i + 3], 22);
94-
}
94+
true
95+
};
9596

9697
// round 2
9798
let mut t = 1;
98-
for i in range_step(0u, 16, 4) {
99+
do uint::range_step(0, 16, 4) |i| {
99100
a = op_g(a, b, c, d, data[t & 0x0f] + C2[i], 5);
100101
d = op_g(d, a, b, c, data[(t + 5) & 0x0f] + C2[i + 1], 9);
101102
c = op_g(c, d, a, b, data[(t + 10) & 0x0f] + C2[i + 2], 14);
102103
b = op_g(b, c, d, a, data[(t + 15) & 0x0f] + C2[i + 3], 20);
103104
t += 20;
104-
}
105+
true
106+
};
105107

106108
// round 3
107109
t = 5;
108-
for i in range_step(0u, 16, 4) {
110+
do uint::range_step(0, 16, 4) |i| {
109111
a = op_h(a, b, c, d, data[t & 0x0f] + C3[i], 4);
110112
d = op_h(d, a, b, c, data[(t + 3) & 0x0f] + C3[i + 1], 11);
111113
c = op_h(c, d, a, b, data[(t + 6) & 0x0f] + C3[i + 2], 16);
112114
b = op_h(b, c, d, a, data[(t + 9) & 0x0f] + C3[i + 3], 23);
113115
t += 12;
114-
}
116+
true
117+
};
115118

116119
// round 4
117120
t = 0;
118-
for i in range_step(0u, 16, 4) {
121+
do uint::range_step(0, 16, 4) |i| {
119122
a = op_i(a, b, c, d, data[t & 0x0f] + C4[i], 6);
120123
d = op_i(d, a, b, c, data[(t + 7) & 0x0f] + C4[i + 1], 10);
121124
c = op_i(c, d, a, b, data[(t + 14) & 0x0f] + C4[i + 2], 15);
122125
b = op_i(b, c, d, a, data[(t + 21) & 0x0f] + C4[i + 3], 21);
123126
t += 28;
124-
}
127+
true
128+
};
125129

126130
self.s0 += a;
127131
self.s1 += b;

branches/try/src/libextra/crypto/sha2.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::iter::range_step;
11+
use std::uint;
1212

1313
use cryptoutil::{write_u64_be, write_u32_be, read_u64v_be, read_u32v_be, add_bytes_to_bits,
1414
add_bytes_to_bits_tuple, FixedBuffer, FixedBuffer128, FixedBuffer64, StandardPadding};
@@ -111,7 +111,7 @@ impl Engine512State {
111111

112112
// Putting the message schedule inside the same loop as the round calculations allows for
113113
// the compiler to generate better code.
114-
for t in range_step(0u, 64, 8) {
114+
do uint::range_step(0, 64, 8) |t| {
115115
schedule_round!(t + 16);
116116
schedule_round!(t + 17);
117117
schedule_round!(t + 18);
@@ -129,9 +129,10 @@ impl Engine512State {
129129
sha2_round!(d, e, f, g, h, a, b, c, K64, t + 5);
130130
sha2_round!(c, d, e, f, g, h, a, b, K64, t + 6);
131131
sha2_round!(b, c, d, e, f, g, h, a, K64, t + 7);
132-
}
132+
true
133+
};
133134

134-
for t in range_step(64u, 80, 8) {
135+
do uint::range_step(64, 80, 8) |t| {
135136
sha2_round!(a, b, c, d, e, f, g, h, K64, t);
136137
sha2_round!(h, a, b, c, d, e, f, g, K64, t + 1);
137138
sha2_round!(g, h, a, b, c, d, e, f, K64, t + 2);
@@ -140,7 +141,8 @@ impl Engine512State {
140141
sha2_round!(d, e, f, g, h, a, b, c, K64, t + 5);
141142
sha2_round!(c, d, e, f, g, h, a, b, K64, t + 6);
142143
sha2_round!(b, c, d, e, f, g, h, a, K64, t + 7);
143-
}
144+
true
145+
};
144146

145147
self.H0 += a;
146148
self.H1 += b;
@@ -525,7 +527,7 @@ impl Engine256State {
525527

526528
// Putting the message schedule inside the same loop as the round calculations allows for
527529
// the compiler to generate better code.
528-
for t in range_step(0u, 48, 8) {
530+
do uint::range_step(0, 48, 8) |t| {
529531
schedule_round!(t + 16);
530532
schedule_round!(t + 17);
531533
schedule_round!(t + 18);
@@ -543,9 +545,10 @@ impl Engine256State {
543545
sha2_round!(d, e, f, g, h, a, b, c, K32, t + 5);
544546
sha2_round!(c, d, e, f, g, h, a, b, K32, t + 6);
545547
sha2_round!(b, c, d, e, f, g, h, a, K32, t + 7);
546-
}
548+
true
549+
};
547550

548-
for t in range_step(48u, 64, 8) {
551+
do uint::range_step(48, 64, 8) |t| {
549552
sha2_round!(a, b, c, d, e, f, g, h, K32, t);
550553
sha2_round!(h, a, b, c, d, e, f, g, K32, t + 1);
551554
sha2_round!(g, h, a, b, c, d, e, f, K32, t + 2);
@@ -554,7 +557,8 @@ impl Engine256State {
554557
sha2_round!(d, e, f, g, h, a, b, c, K32, t + 5);
555558
sha2_round!(c, d, e, f, g, h, a, b, K32, t + 6);
556559
sha2_round!(b, c, d, e, f, g, h, a, K32, t + 7);
557-
}
560+
true
561+
};
558562

559563
self.H0 += a;
560564
self.H1 += b;

branches/try/src/librustpkg/tests.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,55 @@ fn test_extern_mod() {
11111111
assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
11121112
}
11131113

1114+
#[test]
1115+
fn test_extern_mod_simpler() {
1116+
let dir = mkdtemp(&os::tmpdir(), "test_extern_mod_simpler").expect("test_extern_mod_simpler");
1117+
let main_file = dir.push("main.rs");
1118+
let lib_depend_dir = mkdtemp(&os::tmpdir(), "foo").expect("test_extern_mod_simpler");
1119+
let aux_dir = lib_depend_dir.push_many(["src", "rust-awesomeness"]);
1120+
assert!(os::mkdir_recursive(&aux_dir, U_RWX));
1121+
let aux_pkg_file = aux_dir.push("lib.rs");
1122+
1123+
writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() { assert!(true); } }\n");
1124+
assert!(os::path_exists(&aux_pkg_file));
1125+
1126+
writeFile(&main_file,
1127+
"extern mod test = \"rust-awesomeness\";\nuse test::bar;\
1128+
fn main() { bar::assert_true(); }\n");
1129+
1130+
command_line_test([~"install", ~"rust-awesomeness"], &lib_depend_dir);
1131+
1132+
let exec_file = dir.push("out");
1133+
// Be sure to extend the existing environment
1134+
let env = Some([(~"RUST_PATH", lib_depend_dir.to_str())] + os::env());
1135+
let rustpkg_exec = rustpkg_exec();
1136+
let rustc = rustpkg_exec.with_filename("rustc");
1137+
debug!("RUST_PATH=%s %s %s \n --sysroot %s -o %s",
1138+
lib_depend_dir.to_str(),
1139+
rustc.to_str(),
1140+
main_file.to_str(),
1141+
test_sysroot().to_str(),
1142+
exec_file.to_str());
1143+
1144+
let mut prog = run::Process::new(rustc.to_str(), [main_file.to_str(),
1145+
~"--sysroot", test_sysroot().to_str(),
1146+
~"-o", exec_file.to_str()],
1147+
run::ProcessOptions {
1148+
env: env,
1149+
dir: Some(&dir),
1150+
in_fd: None,
1151+
out_fd: None,
1152+
err_fd: None
1153+
});
1154+
let outp = prog.finish_with_output();
1155+
if outp.status != 0 {
1156+
fail!("output was %s, error was %s",
1157+
str::from_utf8(outp.output),
1158+
str::from_utf8(outp.error));
1159+
}
1160+
assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
1161+
}
1162+
11141163
#[test]
11151164
fn test_import_rustpkg() {
11161165
let p_id = PkgId::new("foo");

branches/try/src/librustpkg/util.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,8 @@ pub fn compile_input(context: &BuildContext,
268268
let link_options =
269269
~[attr::mk_name_value_item_str(@"name", name_to_use),
270270
attr::mk_name_value_item_str(@"vers", pkg_id.version.to_str().to_managed())] +
271-
if pkg_id.is_complex() {
272-
~[attr::mk_name_value_item_str(@"package_id",
273-
pkg_id.path.to_str().to_managed())]
274-
} else { ~[] };
271+
~[attr::mk_name_value_item_str(@"package_id",
272+
pkg_id.path.to_str().to_managed())];
275273

276274
debug!("link options: %?", link_options);
277275
crate = @ast::Crate {

branches/try/src/libstd/char.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use cast::transmute;
1414
use option::{None, Option, Some};
15-
use iter::{Iterator, range_step};
15+
use i32;
1616
use str::StrSlice;
1717
use unicode::{derived_property, general_category, decompose};
1818
use to_str::ToStr;
@@ -286,14 +286,15 @@ pub fn escape_unicode(c: char, f: &fn(char)) {
286286
(c <= '\uffff') { f('u'); 4 }
287287
_ { f('U'); 8 }
288288
);
289-
for offset in range_step::<i32>(4 * (pad - 1), -1, -4) {
289+
do i32::range_step(4 * (pad - 1), -1, -4) |offset| {
290290
unsafe {
291291
match ((c as i32) >> offset) & 0xf {
292292
i @ 0 .. 9 => { f(transmute('0' as i32 + i)); }
293293
i => { f(transmute('a' as i32 + (i - 10))); }
294294
}
295295
}
296-
}
296+
true
297+
};
297298
}
298299

299300
///

branches/try/src/libstd/iter.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,17 +1790,17 @@ pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One>(start: A, stop: A) -> R
17901790
RangeInclusive{range: range(start, stop), done: false}
17911791
}
17921792

1793-
impl<A: Add<A, A> + Eq + Ord + Clone> Iterator<A> for RangeInclusive<A> {
1793+
impl<A: Add<A, A> + Ord + Clone> Iterator<A> for RangeInclusive<A> {
17941794
#[inline]
17951795
fn next(&mut self) -> Option<A> {
17961796
match self.range.next() {
17971797
Some(x) => Some(x),
17981798
None => {
1799-
if !self.done && self.range.state == self.range.stop {
1799+
if self.done {
1800+
None
1801+
} else {
18001802
self.done = true;
18011803
Some(self.range.stop.clone())
1802-
} else {
1803-
None
18041804
}
18051805
}
18061806
}
@@ -1829,11 +1829,11 @@ impl<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for RangeInclu
18291829
let result = self.range.stop.clone();
18301830
self.range.stop = self.range.stop - self.range.one;
18311831
Some(result)
1832-
} else if !self.done && self.range.state == self.range.stop {
1832+
} else if self.done {
1833+
None
1834+
} else {
18331835
self.done = true;
18341836
Some(self.range.stop.clone())
1835-
} else {
1836-
None
18371837
}
18381838
}
18391839
}
@@ -1857,7 +1857,7 @@ pub fn range_step<A: CheckedAdd + Ord + Clone + Zero>(start: A, stop: A, step: A
18571857
impl<A: CheckedAdd + Ord + Clone> Iterator<A> for RangeStep<A> {
18581858
#[inline]
18591859
fn next(&mut self) -> Option<A> {
1860-
if (self.rev && self.state > self.stop) || (!self.rev && self.state < self.stop) {
1860+
if (self.rev && self.state > self.stop) || self.state < self.stop {
18611861
let result = self.state.clone();
18621862
match self.state.checked_add(&self.step) {
18631863
Some(x) => self.state = x,
@@ -1891,14 +1891,22 @@ pub fn range_step_inclusive<A: CheckedAdd + Ord + Clone + Zero>(start: A, stop:
18911891
impl<A: CheckedAdd + Ord + Clone + Eq> Iterator<A> for RangeStepInclusive<A> {
18921892
#[inline]
18931893
fn next(&mut self) -> Option<A> {
1894-
if !self.done && ((self.rev && self.state >= self.stop) ||
1895-
(!self.rev && self.state <= self.stop)) {
1896-
let result = self.state.clone();
1897-
match self.state.checked_add(&self.step) {
1898-
Some(x) => self.state = x,
1899-
None => self.done = true
1894+
if !self.done {
1895+
if (self.rev && self.state > self.stop) || self.state < self.stop {
1896+
let result = self.state.clone();
1897+
match self.state.checked_add(&self.step) {
1898+
Some(x) => self.state = x,
1899+
None => self.done = true
1900+
}
1901+
Some(result)
1902+
} else {
1903+
if self.state == self.stop {
1904+
self.done = true;
1905+
Some(self.state.clone())
1906+
} else {
1907+
None
1908+
}
19001909
}
1901-
Some(result)
19021910
} else {
19031911
None
19041912
}
@@ -2712,30 +2720,20 @@ mod tests {
27122720
fn test_range_inclusive() {
27132721
assert_eq!(range_inclusive(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4, 5]);
27142722
assert_eq!(range_inclusive(0i, 5).invert().collect::<~[int]>(), ~[5i, 4, 3, 2, 1, 0]);
2715-
assert_eq!(range_inclusive(200, -5).collect::<~[int]>(), ~[]);
2716-
assert_eq!(range_inclusive(200, -5).invert().collect::<~[int]>(), ~[]);
2717-
assert_eq!(range_inclusive(200, 200).collect::<~[int]>(), ~[200]);
2718-
assert_eq!(range_inclusive(200, 200).invert().collect::<~[int]>(), ~[200]);
27192723
}
27202724

27212725
#[test]
27222726
fn test_range_step() {
27232727
assert_eq!(range_step(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15]);
27242728
assert_eq!(range_step(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5]);
2725-
assert_eq!(range_step(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]);
27262729
assert_eq!(range_step(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]);
2727-
assert_eq!(range_step(200, -5, 1).collect::<~[int]>(), ~[]);
2728-
assert_eq!(range_step(200, 200, 1).collect::<~[int]>(), ~[]);
27292730
}
27302731

27312732
#[test]
27322733
fn test_range_step_inclusive() {
27332734
assert_eq!(range_step_inclusive(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15, 20]);
27342735
assert_eq!(range_step_inclusive(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5, 0]);
2735-
assert_eq!(range_step_inclusive(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]);
27362736
assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]);
2737-
assert_eq!(range_step_inclusive(200, -5, 1).collect::<~[int]>(), ~[]);
2738-
assert_eq!(range_step_inclusive(200, 200, 1).collect::<~[int]>(), ~[200]);
27392737
}
27402738

27412739
#[test]

0 commit comments

Comments
 (0)