about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2013-07-01 12:30:14 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2013-07-10 09:35:35 +0200
commitdb0a13b9865510ec07f7597e11009eabc2676afc (patch)
treeb674a79ce8c955a01e8669bcfeaab759b443915d /src/libstd
parent3c19f1bca83be3f4abef378d0a4cd852c8615164 (diff)
downloadrust-db0a13b9865510ec07f7597e11009eabc2676afc.tar.gz
rust-db0a13b9865510ec07f7597e11009eabc2676afc.zip
Switch over to new range_rev semantics; fix #5270.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/num/int_macros.rs7
-rw-r--r--src/libstd/num/uint_macros.rs7
-rw-r--r--src/libstd/run.rs2
-rw-r--r--src/libstd/trie.rs2
4 files changed, 10 insertions, 8 deletions
diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs
index 4fd30be80e6..cef32b5c7e4 100644
--- a/src/libstd/num/int_macros.rs
+++ b/src/libstd/num/int_macros.rs
@@ -132,9 +132,10 @@ pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool {
 }
 
 #[inline]
-/// Iterate over the range [`hi`..`lo`)
+/// Iterate over the range (`hi`..`lo`]
 pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool {
-    range_step(hi, lo, -1 as $T, it)
+    if hi == min_value { return true; }
+    range_step_inclusive(hi-1, lo, -1 as $T, it)
 }
 
 impl Num for $T {}
@@ -897,7 +898,7 @@ mod tests {
         for range(0,3) |i| {
             l.push(i);
         }
-        for range_rev(13,10) |i| {
+        for range_rev(14,11) |i| {
             l.push(i);
         }
         for range_step(20,26,2) |i| {
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index 09397ecfd77..54c1327fa93 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -132,9 +132,10 @@ pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool {
 }
 
 #[inline]
-/// Iterate over the range [`hi`..`lo`)
+/// Iterate over the range (`hi`..`lo`]
 pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool {
-    range_step(hi, lo, -1 as $T_SIGNED, it)
+    if hi == min_value { return true; }
+    range_step_inclusive(hi-1, lo, -1 as $T_SIGNED, it)
 }
 
 impl Num for $T {}
@@ -662,7 +663,7 @@ mod tests {
         for range(0,3) |i| {
             l.push(i);
         }
-        for range_rev(13,10) |i| {
+        for range_rev(14,11) |i| {
             l.push(i);
         }
         for range_step(20,26,2) |i| {
diff --git a/src/libstd/run.rs b/src/libstd/run.rs
index 17dc604a178..883870db1e6 100644
--- a/src/libstd/run.rs
+++ b/src/libstd/run.rs
@@ -669,7 +669,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
             fail!("failure in dup3(err_fd, 2): %s", os::last_os_error());
         }
         // close all other fds
-        for int::range_rev(getdtablesize() as int - 1, 2) |fd| {
+        for int::range_rev(getdtablesize() as int, 3) |fd| {
             close(fd as c_int);
         }
 
diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs
index 8ce02d59ab1..50552fd7547 100644
--- a/src/libstd/trie.rs
+++ b/src/libstd/trie.rs
@@ -261,7 +261,7 @@ impl<T> TrieNode<T> {
 
     fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
         for uint::range_rev(self.children.len(), 0) |idx| {
-            match self.children[idx - 1] {
+            match self.children[idx] {
                 Internal(ref x) => if !x.each_reverse(|i,t| f(i,t)) { return false },
                 External(k, ref v) => if !f(&k, v) { return false },
                 Nothing => ()