Skip to content

Commit 9def617

Browse files
committed
---
yaml --- r: 138557 b: refs/heads/try2 c: 3e6b2cf h: refs/heads/master i: 138555: ffd5dbc v: v3
1 parent 6e6e60c commit 9def617

Some content is hidden

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

42 files changed

+330
-1100
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 99a902c81d7bc57fece1b520591f328afe76154a
8+
refs/heads/try2: 3e6b2cfab5b838138f2bec5c696089b7f5005361
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ do
678678
LLVM_BUILD_DIR=${CFG_BUILD_DIR}llvm/$t
679679
if [ ! -z "$CFG_DISABLE_OPTIMIZE_LLVM" ]
680680
then
681-
LLVM_DBG_OPTS=""
681+
LLVM_DBG_OPTS="--enable-debug-symbols --disable-optimized"
682682
# Just use LLVM straight from its build directory to
683683
# avoid 'make install' time
684684
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug+Asserts

branches/try2/doc/rust.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,7 @@ The following are examples of structure expressions:
16111611
# struct Point { x: float, y: float }
16121612
# struct TuplePoint(float, float);
16131613
# mod game { pub struct User { name: &str, age: uint, score: uint } }
1614+
# use game;
16141615
Point {x: 10f, y: 20f};
16151616
TuplePoint(10f, 20f);
16161617
let u = game::User {name: "Joe", age: 35u, score: 100_000};

branches/try2/doc/tutorial-tasks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ Here is the function that implements the child task:
468468

469469
~~~~
470470
# use std::comm::DuplexStream;
471+
# use comm::{Port, Chan};
471472
fn stringifier(channel: &DuplexStream<~str, uint>) {
472473
let mut value: uint;
473474
loop {
@@ -490,6 +491,7 @@ Here is the code for the parent task:
490491

491492
~~~~
492493
# use std::comm::DuplexStream;
494+
# use comm::{Port, Chan};
493495
# use task::spawn;
494496
# fn stringifier(channel: &DuplexStream<~str, uint>) {
495497
# let mut value: uint;

branches/try2/doc/tutorial.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,9 +2270,7 @@ fn chicken_farmer() {
22702270
// The same, but name it `my_chicken`
22712271
use my_chicken = farm::chicken;
22722272
...
2273-
# my_chicken();
22742273
}
2275-
# chicken();
22762274
# }
22772275
~~~
22782276

branches/try2/src/libcore/hash.rs

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -186,46 +186,42 @@ fn SipState(key0: u64, key1: u64) -> SipState {
186186
state
187187
}
188188

189-
// sadly, these macro definitions can't appear later,
190-
// because they're needed in the following defs;
191-
// this design could be improved.
192-
193-
macro_rules! u8to64_le (
194-
($buf:expr, $i:expr) =>
195-
($buf[0+$i] as u64 |
196-
$buf[1+$i] as u64 << 8 |
197-
$buf[2+$i] as u64 << 16 |
198-
$buf[3+$i] as u64 << 24 |
199-
$buf[4+$i] as u64 << 32 |
200-
$buf[5+$i] as u64 << 40 |
201-
$buf[6+$i] as u64 << 48 |
202-
$buf[7+$i] as u64 << 56)
203-
)
204-
205-
macro_rules! rotl (
206-
($x:expr, $b:expr) =>
207-
(($x << $b) | ($x >> (64 - $b)))
208-
)
209-
210-
macro_rules! compress (
211-
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
212-
({
213-
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
214-
$v0 = rotl!($v0, 32);
215-
$v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
216-
$v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
217-
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
218-
$v2 = rotl!($v2, 32);
219-
})
220-
)
221-
222189

223190
impl io::Writer for SipState {
224191

225192
// Methods for io::writer
226193
#[inline(always)]
227194
fn write(&self, msg: &[const u8]) {
228195

196+
macro_rules! u8to64_le (
197+
($buf:expr, $i:expr) =>
198+
($buf[0+$i] as u64 |
199+
$buf[1+$i] as u64 << 8 |
200+
$buf[2+$i] as u64 << 16 |
201+
$buf[3+$i] as u64 << 24 |
202+
$buf[4+$i] as u64 << 32 |
203+
$buf[5+$i] as u64 << 40 |
204+
$buf[6+$i] as u64 << 48 |
205+
$buf[7+$i] as u64 << 56)
206+
);
207+
208+
macro_rules! rotl (
209+
($x:expr, $b:expr) =>
210+
(($x << $b) | ($x >> (64 - $b)))
211+
);
212+
213+
macro_rules! compress (
214+
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
215+
({
216+
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
217+
$v0 = rotl!($v0, 32);
218+
$v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
219+
$v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
220+
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
221+
$v2 = rotl!($v2, 32);
222+
})
223+
);
224+
229225
let length = msg.len();
230226
self.length += length;
231227

branches/try2/src/libcore/os.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,17 @@ pub fn path_exists(p: &Path) -> bool {
566566
*
567567
* If the given path is relative, return it prepended with the current working
568568
* directory. If the given path is already an absolute path, return it
569-
* as is. This is a shortcut for calling os::getcwd().unsafe_join(p)
569+
* as is.
570570
*/
571571
// NB: this is here rather than in path because it is a form of environment
572572
// querying; what it does depends on the process working directory, not just
573573
// the input paths.
574574
pub fn make_absolute(p: &Path) -> Path {
575-
getcwd().unsafe_join(p)
575+
if p.is_absolute {
576+
copy *p
577+
} else {
578+
getcwd().push_many(p.components)
579+
}
576580
}
577581

578582

branches/try2/src/libcore/path.rs

Lines changed: 5 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ pub trait GenericPath {
6464
pure fn push_many((&[~str])) -> Self;
6565
pure fn pop() -> Self;
6666

67-
pure fn unsafe_join((&Self)) -> Self;
68-
pure fn is_restricted() -> bool;
69-
7067
pure fn normalize() -> Self;
7168
}
7269

@@ -488,19 +485,6 @@ impl GenericPath for PosixPath {
488485
self.push_many(other.components)
489486
}
490487

491-
pure fn unsafe_join(other: &PosixPath) -> PosixPath {
492-
if other.is_absolute {
493-
PosixPath { is_absolute: true,
494-
components: copy other.components }
495-
} else {
496-
self.push_rel(other)
497-
}
498-
}
499-
500-
pure fn is_restricted() -> bool {
501-
false
502-
}
503-
504488
pure fn push_many(cs: &[~str]) -> PosixPath {
505489
let mut v = copy self.components;
506490
for cs.each |e| {
@@ -701,61 +685,6 @@ impl GenericPath for WindowsPath {
701685
self.push_many(other.components)
702686
}
703687

704-
pure fn unsafe_join(other: &WindowsPath) -> WindowsPath {
705-
/* rhs not absolute is simple push */
706-
if !other.is_absolute {
707-
return self.push_many(other.components);
708-
}
709-
710-
/* if rhs has a host set, then the whole thing wins */
711-
match other.host {
712-
Some(copy host) => {
713-
return WindowsPath {
714-
host: Some(host),
715-
device: copy other.device,
716-
is_absolute: true,
717-
components: copy other.components
718-
};
719-
}
720-
_ => {}
721-
}
722-
723-
/* if rhs has a device set, then a part wins */
724-
match other.device {
725-
Some(copy device) => {
726-
return WindowsPath {
727-
host: None,
728-
device: Some(device),
729-
is_absolute: true,
730-
components: copy other.components
731-
};
732-
}
733-
_ => {}
734-
}
735-
736-
/* fallback: host and device of lhs win, but the
737-
whole path of the right */
738-
WindowsPath {
739-
host: copy self.host,
740-
device: copy self.device,
741-
is_absolute: self.is_absolute || other.is_absolute,
742-
components: copy other.components
743-
}
744-
}
745-
746-
pure fn is_restricted() -> bool {
747-
match self.filestem() {
748-
Some(stem) => {
749-
match stem.to_lower() {
750-
~"con" | ~"aux" | ~"com1" | ~"com2" | ~"com3" | ~"com4" |
751-
~"lpt1" | ~"lpt2" | ~"lpt3" | ~"prn" | ~"nul" => true,
752-
_ => false
753-
}
754-
},
755-
None => false
756-
}
757-
}
758-
759688
pure fn push_many(cs: &[~str]) -> WindowsPath {
760689
let mut v = copy self.components;
761690
for cs.each |e| {
@@ -796,10 +725,7 @@ impl GenericPath for WindowsPath {
796725
pure fn normalize() -> WindowsPath {
797726
return WindowsPath {
798727
host: copy self.host,
799-
device: match self.device {
800-
None => None,
801-
Some(ref device) => Some(device.to_upper())
802-
},
728+
device: copy self.device,
803729
is_absolute: self.is_absolute,
804730
components: normalize(self.components)
805731
}
@@ -838,13 +764,13 @@ pub mod windows {
838764
839765
pub pure fn extract_unc_prefix(s: &str) -> Option<(~str,~str)> {
840766
if (s.len() > 1 &&
841-
(s[0] == '\\' as u8 || s[0] == '/' as u8) &&
842-
s[0] == s[1]) {
767+
s[0] == '\\' as u8 &&
768+
s[1] == '\\' as u8) {
843769
let mut i = 2;
844770
while i < s.len() {
845-
if is_sep(s[i]) {
771+
if s[i] == '\\' as u8 {
846772
let pre = s.slice(2, i);
847-
let mut rest = s.slice(i, s.len());
773+
let rest = s.slice(i, s.len());
848774
return Some((pre, rest));
849775
}
850776
i += 1;
@@ -990,21 +916,13 @@ mod tests {
990916
#[test]
991917
fn test_extract_unc_prefixes() {
992918
assert windows::extract_unc_prefix("\\\\").is_none();
993-
assert windows::extract_unc_prefix("//").is_none();
994919
assert windows::extract_unc_prefix("\\\\hi").is_none();
995-
assert windows::extract_unc_prefix("//hi").is_none();
996920
assert windows::extract_unc_prefix("\\\\hi\\") ==
997921
Some((~"hi", ~"\\"));
998-
assert windows::extract_unc_prefix("//hi\\") ==
999-
Some((~"hi", ~"\\"));
1000922
assert windows::extract_unc_prefix("\\\\hi\\there") ==
1001923
Some((~"hi", ~"\\there"));
1002-
assert windows::extract_unc_prefix("//hi/there") ==
1003-
Some((~"hi", ~"/there"));
1004924
assert windows::extract_unc_prefix("\\\\hi\\there\\friends.txt") ==
1005925
Some((~"hi", ~"\\there\\friends.txt"));
1006-
assert windows::extract_unc_prefix("//hi\\there\\friends.txt") ==
1007-
Some((~"hi", ~"\\there\\friends.txt"));
1008926
}
1009927

1010928
#[test]
@@ -1063,61 +981,5 @@ mod tests {
1063981
.push_many([~"lib", ~"thingy.dll"])
1064982
.with_filename("librustc.dll")),
1065983
"c:\\program files (x86)\\rust\\lib\\librustc.dll");
1066-
1067-
t(&(WindowsPath("\\\\computer\\share")
1068-
.unsafe_join(&WindowsPath("\\a"))),
1069-
"\\\\computer\\a");
1070-
1071-
t(&(WindowsPath("//computer/share")
1072-
.unsafe_join(&WindowsPath("\\a"))),
1073-
"\\\\computer\\a");
1074-
1075-
t(&(WindowsPath("//computer/share")
1076-
.unsafe_join(&WindowsPath("\\\\computer\\share"))),
1077-
"\\\\computer\\share");
1078-
1079-
t(&(WindowsPath("C:/whatever")
1080-
.unsafe_join(&WindowsPath("//computer/share/a/b"))),
1081-
"\\\\computer\\share\\a\\b");
1082-
1083-
t(&(WindowsPath("C:")
1084-
.unsafe_join(&WindowsPath("D:/foo"))),
1085-
"D:\\foo");
1086-
1087-
t(&(WindowsPath("C:")
1088-
.unsafe_join(&WindowsPath("B"))),
1089-
"C:B");
1090-
1091-
t(&(WindowsPath("C:")
1092-
.unsafe_join(&WindowsPath("/foo"))),
1093-
"C:\\foo");
1094-
1095-
t(&(WindowsPath("C:\\")
1096-
.unsafe_join(&WindowsPath("\\bar"))),
1097-
"C:\\bar");
1098-
1099-
t(&(WindowsPath("")
1100-
.unsafe_join(&WindowsPath(""))),
1101-
"");
1102-
1103-
t(&(WindowsPath("")
1104-
.unsafe_join(&WindowsPath("a"))),
1105-
"a");
1106-
1107-
t(&(WindowsPath("")
1108-
.unsafe_join(&WindowsPath("C:\\a"))),
1109-
"C:\\a");
1110-
1111-
t(&(WindowsPath("c:\\foo")
1112-
.normalize()),
1113-
"C:\\foo");
1114-
}
1115-
1116-
#[test]
1117-
fn test_windows_path_restrictions() {
1118-
assert WindowsPath("hi").is_restricted() == false;
1119-
assert WindowsPath("C:\\NUL").is_restricted() == true;
1120-
assert WindowsPath("C:\\COM1.TXT").is_restricted() == true;
1121-
assert WindowsPath("c:\\prn.exe").is_restricted() == true;
1122984
}
1123985
}

branches/try2/src/libcore/str.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -590,40 +590,6 @@ pub pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] {
590590
result
591591
}
592592

593-
/// Levenshtein Distance between two strings
594-
pub fn levdistance(s: &str, t: &str) -> uint {
595-
596-
let slen = str::len(s);
597-
let tlen = str::len(t);
598-
599-
if slen == 0 { return tlen; }
600-
if tlen == 0 { return slen; }
601-
602-
let mut dcol = vec::from_fn(tlen + 1, |x| x);
603-
604-
for str::each_chari(s) |i, sc| {
605-
606-
let mut current = i;
607-
dcol[0] = current + 1;
608-
609-
for str::each_chari(t) |j, tc| {
610-
611-
let mut next = dcol[j + 1];
612-
613-
if sc == tc {
614-
dcol[j + 1] = current;
615-
} else {
616-
dcol[j + 1] = ::cmp::min(current, next);
617-
dcol[j + 1] = ::cmp::min(dcol[j + 1], dcol[j]) + 1;
618-
}
619-
620-
current = next;
621-
}
622-
}
623-
624-
return dcol[tlen];
625-
}
626-
627593
/**
628594
* Splits a string into a vector of the substrings separated by LF ('\n')
629595
*/

0 commit comments

Comments
 (0)