about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-09-22 15:44:13 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-09-22 15:44:13 -0700
commit2880ecd73ff7443ad72eb7af3c85e673024fc7fd (patch)
treeb9e703a5e279db41fa36bdbe9674abe8f159e91c /src
parent738fe078a43c3f184d0e147f89042474a61fa779 (diff)
downloadrust-2880ecd73ff7443ad72eb7af3c85e673024fc7fd.tar.gz
rust-2880ecd73ff7443ad72eb7af3c85e673024fc7fd.zip
Reformat standard library; no code changes.
Diffstat (limited to 'src')
-rw-r--r--src/lib/_int.rs29
-rw-r--r--src/lib/_str.rs271
-rw-r--r--src/lib/_task.rs15
-rw-r--r--src/lib/_u8.rs16
-rw-r--r--src/lib/_uint.rs113
-rw-r--r--src/lib/_vec.rs141
-rw-r--r--src/lib/dbg.rs39
-rw-r--r--src/lib/deque.rs234
-rw-r--r--src/lib/linux_os.rs72
-rw-r--r--src/lib/macos_os.rs71
-rw-r--r--src/lib/map.rs383
-rw-r--r--src/lib/rand.rs33
-rw-r--r--src/lib/std.rc25
-rw-r--r--src/lib/sys.rs36
-rw-r--r--src/lib/util.rs33
-rw-r--r--src/lib/win32_os.rs49
16 files changed, 852 insertions, 708 deletions
diff --git a/src/lib/_int.rs b/src/lib/_int.rs
index 396dd33190a..38e161bcfa2 100644
--- a/src/lib/_int.rs
+++ b/src/lib/_int.rs
@@ -19,18 +19,27 @@ fn nonpositive(int x) -> bool { ret x <= 0; }
 fn nonnegative(int x) -> bool { ret x >= 0; }
 
 iter range(mutable int lo, int hi) -> int {
-  while (lo < hi) {
-    put lo;
-    lo += 1;
-  }
+    while (lo < hi) {
+        put lo;
+        lo += 1;
+    }
 }
 
 fn to_str(mutable int n, uint radix) -> str
 {
-  check (0u < radix && radix <= 16u);
-  if (n < 0) {
-    ret "-" + _uint.to_str((-n) as uint, radix);
-  } else {
-    ret _uint.to_str(n as uint, radix);
-  }
+    check (0u < radix && radix <= 16u);
+    if (n < 0) {
+        ret "-" + _uint.to_str((-n) as uint, radix);
+    } else {
+        ret _uint.to_str(n as uint, radix);
+    }
 }
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/_str.rs b/src/lib/_str.rs
index 81bbd91fef5..0fc7b373950 100644
--- a/src/lib/_str.rs
+++ b/src/lib/_str.rs
@@ -3,58 +3,58 @@ import rustrt.sbuf;
 import std._vec.rustrt.vbuf;
 
 native "rust" mod rustrt {
-  type sbuf;
-  fn str_buf(str s) -> sbuf;
-  fn str_byte_len(str s) -> uint;
-  fn str_alloc(uint n_bytes) -> str;
-  fn str_from_vec(vec[u8] b) -> str;
-  fn refcount[T](str s) -> uint;
+    type sbuf;
+    fn str_buf(str s) -> sbuf;
+    fn str_byte_len(str s) -> uint;
+    fn str_alloc(uint n_bytes) -> str;
+    fn str_from_vec(vec[u8] b) -> str;
+    fn refcount[T](str s) -> uint;
 }
 
 fn eq(&str a, &str b) -> bool {
-  let uint i = byte_len(a);
-  if (byte_len(b) != i) {
-    ret false;
-  }
-  while (i > 0u) {
-    i -= 1u;
-    auto cha = a.(i);
-    auto chb = b.(i);
-    if (cha != chb) {
-      ret false;
+    let uint i = byte_len(a);
+    if (byte_len(b) != i) {
+        ret false;
+    }
+    while (i > 0u) {
+        i -= 1u;
+        auto cha = a.(i);
+        auto chb = b.(i);
+        if (cha != chb) {
+            ret false;
+        }
     }
-  }
-  ret true;
+    ret true;
 }
 
 fn hash(&str s) -> uint {
-  // djb hash.
-  // FIXME: replace with murmur.
-  let uint u = 5381u;
-  for (u8 c in s) {
-    u *= 33u;
-    u += (c as uint);
-  }
-  ret u;
+    // djb hash.
+    // FIXME: replace with murmur.
+    let uint u = 5381u;
+    for (u8 c in s) {
+        u *= 33u;
+        u += (c as uint);
+    }
+    ret u;
 }
 
 fn is_utf8(vec[u8] v) -> bool {
-  fail; // FIXME
+    fail; // FIXME
 }
 
 fn is_ascii(str s) -> bool {
-  let uint i = byte_len(s);
-  while (i > 0u) {
-    i -= 1u;
-    if ((s.(i) & 0x80u8) != 0u8) {
-      ret false;
+    let uint i = byte_len(s);
+    while (i > 0u) {
+        i -= 1u;
+        if ((s.(i) & 0x80u8) != 0u8) {
+            ret false;
+        }
     }
-  }
-  ret true;
+    ret true;
 }
 
 fn alloc(uint n_bytes) -> str {
-  ret rustrt.str_alloc(n_bytes);
+    ret rustrt.str_alloc(n_bytes);
 }
 
 // Returns the number of bytes (a.k.a. UTF-8 code units) in s.
@@ -63,152 +63,152 @@ fn alloc(uint n_bytes) -> str {
 // http://icu-project.org/apiref/icu4c/classBreakIterator.html for a
 // way to implement those.
 fn byte_len(str s) -> uint {
-  ret rustrt.str_byte_len(s);
+    ret rustrt.str_byte_len(s);
 }
 
 fn buf(str s) -> sbuf {
-  ret rustrt.str_buf(s);
+    ret rustrt.str_buf(s);
 }
 
 fn bytes(str s) -> vec[u8] {
-  /* FIXME (issue #58):
-   * Should be...
-   *
-   *  fn ith(str s, uint i) -> u8 {
-   *      ret s.(i);
-   *  }
-   *  ret _vec.init_fn[u8](bind ith(s, _), byte_len(s));
-   *
-   * but we do not correctly decrement refcount of s when
-   * the binding dies, so we have to do this manually.
-   */
-  let uint n = _str.byte_len(s);
-  let vec[u8] v = _vec.alloc[u8](n);
-  let uint i = 0u;
-  while (i < n) {
-    v += vec(s.(i));
-    i += 1u;
-  }
-  ret v;
+    /* FIXME (issue #58):
+     * Should be...
+     *
+     *  fn ith(str s, uint i) -> u8 {
+     *      ret s.(i);
+     *  }
+     *  ret _vec.init_fn[u8](bind ith(s, _), byte_len(s));
+     *
+     * but we do not correctly decrement refcount of s when
+     * the binding dies, so we have to do this manually.
+     */
+    let uint n = _str.byte_len(s);
+    let vec[u8] v = _vec.alloc[u8](n);
+    let uint i = 0u;
+    while (i < n) {
+        v += vec(s.(i));
+        i += 1u;
+    }
+    ret v;
 }
 
 fn from_bytes(vec[u8] v) : is_utf8(v) -> str {
-  ret rustrt.str_from_vec(v);
+    ret rustrt.str_from_vec(v);
 }
 
 fn refcount(str s) -> uint {
-  // -1 because calling this function incremented the refcount.
-  ret rustrt.refcount[u8](s) - 1u;
+    // -1 because calling this function incremented the refcount.
+    ret rustrt.refcount[u8](s) - 1u;
 }
 
 
 // Standard bits from the world of string libraries.
 
 fn index(str s, u8 c) -> int {
-  let int i = 0;
-  for (u8 k in s) {
-    if (k == c) {
-      ret i;
+    let int i = 0;
+    for (u8 k in s) {
+        if (k == c) {
+            ret i;
+        }
+        i += 1;
     }
-    i += 1;
-  }
-  ret -1;
+    ret -1;
 }
 
 fn rindex(str s, u8 c) -> int {
-  let int n = _str.byte_len(s) as int;
-  while (n >= 0) {
-    if (s.(n) == c) {
-      ret n;
+    let int n = _str.byte_len(s) as int;
+    while (n >= 0) {
+        if (s.(n) == c) {
+            ret n;
+        }
+        n -= 1;
     }
-    n -= 1;
-  }
-  ret n;
+    ret n;
 }
 
 fn find(str haystack, str needle) -> int {
 
-  let int haystack_len = byte_len(haystack) as int;
-  let int needle_len = byte_len(needle) as int;
+    let int haystack_len = byte_len(haystack) as int;
+    let int needle_len = byte_len(needle) as int;
 
-  if (needle_len == 0) {
-    ret 0;
-  }
+    if (needle_len == 0) {
+        ret 0;
+    }
 
-  fn match_at(&str haystack,
-              &str needle,
-              int i) -> bool {
-    let int j = i;
-    for (u8 c in needle) {
-      if (haystack.(j) != c) {
-        ret false;
-      }
-      j += 1;
+    fn match_at(&str haystack,
+                &str needle,
+                int i) -> bool {
+        let int j = i;
+        for (u8 c in needle) {
+            if (haystack.(j) != c) {
+                ret false;
+            }
+            j += 1;
+        }
+        ret true;
     }
-    ret true;
-  }
 
-  let int i = 0;
-  while (i <= haystack_len - needle_len) {
-    if (match_at(haystack, needle, i)) {
-      ret i;
+    let int i = 0;
+    while (i <= haystack_len - needle_len) {
+        if (match_at(haystack, needle, i)) {
+            ret i;
+        }
+        i += 1;
     }
-    i += 1;
-  }
-  ret  -1;
+    ret  -1;
 }
 
 fn substr(str s, uint begin, uint len) -> str {
-  let str accum = "";
-  let uint i = begin;
-  while (i < begin+len) {
-    accum += s.(i);
-    i += 1u;
-  }
-  ret accum;
+    let str accum = "";
+    let uint i = begin;
+    while (i < begin+len) {
+        accum += s.(i);
+        i += 1u;
+    }
+    ret accum;
 }
 
 fn split(str s, u8 sep) -> vec[str] {
-  let vec[str] v = vec();
-  let str accum = "";
-  let bool ends_with_sep = false;
-  for (u8 c in s) {
-    if (c == sep) {
-      v += accum;
-      accum = "";
-      ends_with_sep = true;
-    } else {
-      accum += c;
-      ends_with_sep = false;
+    let vec[str] v = vec();
+    let str accum = "";
+    let bool ends_with_sep = false;
+    for (u8 c in s) {
+        if (c == sep) {
+            v += accum;
+            accum = "";
+            ends_with_sep = true;
+        } else {
+            accum += c;
+            ends_with_sep = false;
+        }
+    }
+    if (_str.byte_len(accum) != 0u ||
+        ends_with_sep) {
+        v += accum;
     }
-  }
-  if (_str.byte_len(accum) != 0u ||
-      ends_with_sep) {
-    v += accum;
-  }
-  ret v;
+    ret v;
 }
 
 fn concat(vec[str] v) -> str {
-  let str s = "";
-  for (str ss in v) {
-    s += ss;
-  }
-  ret s;
+    let str s = "";
+    for (str ss in v) {
+        s += ss;
+    }
+    ret s;
 }
 
 fn connect(vec[str] v, str sep) -> str {
-  let str s = "";
-  let bool first = true;
-  for (str ss in v) {
-    if (first) {
-      first = false;
-    } else {
-      s += sep;
+    let str s = "";
+    let bool first = true;
+    for (str ss in v) {
+        if (first) {
+            first = false;
+        } else {
+            s += sep;
+        }
+        s += ss;
     }
-    s += ss;
-  }
-  ret s;
+    ret s;
 }
 
 
@@ -216,6 +216,7 @@ fn connect(vec[str] v, str sep) -> str {
 // mode: rust;
 // fill-column: 78;
 // indent-tabs-mode: nil
+// c-basic-offset: 4
 // buffer-file-coding-system: utf-8-unix
 // compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
 // End:
diff --git a/src/lib/_task.rs b/src/lib/_task.rs
index a12c2f278fd..8eece16b508 100644
--- a/src/lib/_task.rs
+++ b/src/lib/_task.rs
@@ -1,5 +1,5 @@
 native "rust" mod rustrt {
-  fn task_sleep(uint time_in_us);
+    fn task_sleep(uint time_in_us);
 }
 
 /**
@@ -8,5 +8,14 @@ native "rust" mod rustrt {
  * arg: time_in_us maximum number of microseconds to yield control for
  */
 fn sleep(uint time_in_us) {
-  ret rustrt.task_sleep(time_in_us);
-}
\ No newline at end of file
+    ret rustrt.task_sleep(time_in_us);
+}
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/_u8.rs b/src/lib/_u8.rs
index 7749e30e467..fa2a79e37d9 100644
--- a/src/lib/_u8.rs
+++ b/src/lib/_u8.rs
@@ -12,9 +12,17 @@ fn ge(u8 x, u8 y) -> bool { ret x >= y; }
 fn gt(u8 x, u8 y) -> bool { ret x > y; }
 
 iter range(mutable u8 lo, u8 hi) -> u8 {
-  while (lo < hi) {
-    put lo;
-    lo += 1u8;
-  }
+    while (lo < hi) {
+        put lo;
+        lo += 1u8;
+    }
 }
 
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/_uint.rs b/src/lib/_uint.rs
index f3a6f935706..0930cadc093 100644
--- a/src/lib/_uint.rs
+++ b/src/lib/_uint.rs
@@ -14,73 +14,82 @@ fn ge(uint x, uint y) -> bool { ret x >= y; }
 fn gt(uint x, uint y) -> bool { ret x > y; }
 
 iter range(mutable uint lo, uint hi) -> uint {
-  while (lo < hi) {
-    put lo;
-    lo += 1u;
-  }
+    while (lo < hi) {
+        put lo;
+        lo += 1u;
+    }
 }
 
 fn next_power_of_two(uint n) -> uint {
-  // FIXME change |* uint(4)| below to |* uint(8) / uint(2)| and watch the
-  // world explode.
-  let uint halfbits = sys.rustrt.size_of[uint]() * 4u;
-  let uint tmp = n - 1u;
-  let uint shift = 1u;
-  while (shift <= halfbits) {
-    tmp |= tmp >> shift;
-    shift <<= 1u;
-  }
-  ret tmp + 1u;
+    // FIXME change |* uint(4)| below to |* uint(8) / uint(2)| and watch the
+    // world explode.
+    let uint halfbits = sys.rustrt.size_of[uint]() * 4u;
+    let uint tmp = n - 1u;
+    let uint shift = 1u;
+    while (shift <= halfbits) {
+        tmp |= tmp >> shift;
+        shift <<= 1u;
+    }
+    ret tmp + 1u;
 }
 
 fn to_str(mutable uint n, uint radix) -> str
 {
-  check (0u < radix && radix <= 16u);
-  fn digit(uint n) -> char {
-    alt (n) {
-      case (0u) { ret '0'; }
-      case (1u) { ret '1'; }
-      case (2u) { ret '2'; }
-      case (3u) { ret '3'; }
-      case (4u) { ret '4'; }
-      case (5u) { ret '5'; }
-      case (6u) { ret '6'; }
-      case (7u) { ret '7'; }
-      case (8u) { ret '8'; }
-      case (9u) { ret '9'; }
-      case (10u) { ret 'a'; }
-      case (11u) { ret 'b'; }
-      case (12u) { ret 'c'; }
-      case (13u) { ret 'd'; }
-      case (14u) { ret 'e'; }
-      case (15u) { ret 'f'; }
+    check (0u < radix && radix <= 16u);
+    fn digit(uint n) -> char {
+        alt (n) {
+            case (0u) { ret '0'; }
+            case (1u) { ret '1'; }
+            case (2u) { ret '2'; }
+            case (3u) { ret '3'; }
+            case (4u) { ret '4'; }
+            case (5u) { ret '5'; }
+            case (6u) { ret '6'; }
+            case (7u) { ret '7'; }
+            case (8u) { ret '8'; }
+            case (9u) { ret '9'; }
+            case (10u) { ret 'a'; }
+            case (11u) { ret 'b'; }
+            case (12u) { ret 'c'; }
+            case (13u) { ret 'd'; }
+            case (14u) { ret 'e'; }
+            case (15u) { ret 'f'; }
+        }
     }
-  }
 
-  if (n == 0u) { ret "0"; }
+    if (n == 0u) { ret "0"; }
 
-  let uint r = 1u;
-  if (n > r) {
-    while ((r*radix) <= n) {
-      r *= radix;
+    let uint r = 1u;
+    if (n > r) {
+        while ((r*radix) <= n) {
+            r *= radix;
+        }
     }
-  }
 
-  let str s = "";
-  while (n > 0u) {
+    let str s = "";
+    while (n > 0u) {
 
-    auto i = n/r;
+        auto i = n/r;
 
-    n -= (i * r);
-    r /= radix;
+        n -= (i * r);
+        r /= radix;
 
-    s += digit(i) as u8;
-  }
+        s += digit(i) as u8;
+    }
 
-  while (r > 0u) {
-    s += '0' as u8;
-    r /= radix;
-  }
+    while (r > 0u) {
+        s += '0' as u8;
+        r /= radix;
+    }
 
-  ret s;
+    ret s;
 }
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/_vec.rs b/src/lib/_vec.rs
index 39dc8617261..550206840b9 100644
--- a/src/lib/_vec.rs
+++ b/src/lib/_vec.rs
@@ -2,114 +2,123 @@ import vbuf = rustrt.vbuf;
 import op = util.operator;
 
 native "rust" mod rustrt {
-  type vbuf;
+    type vbuf;
 
-  fn vec_buf[T](vec[T] v, uint offset) -> vbuf;
+    fn vec_buf[T](vec[T] v, uint offset) -> vbuf;
 
-  fn vec_len[T](vec[T] v) -> uint;
-  /**
-   * Sometimes we modify the vec internal data via vec_buf and need to update
-   * the vec's fill length accordingly.
-   */
-  fn vec_len_set[T](vec[T] v, uint n);
+    fn vec_len[T](vec[T] v) -> uint;
+    /**
+     * Sometimes we modify the vec internal data via vec_buf and need to
+     * update the vec's fill length accordingly.
+     */
+    fn vec_len_set[T](vec[T] v, uint n);
 
-  /**
-   * The T in vec_alloc[T, U] is the type of the vec to allocate.  The
-   * U is the type of an element in the vec.  So to allocate a vec[U] we
-   * want to invoke this as vec_alloc[vec[U], U].
-   */
-  fn vec_alloc[T, U](uint n_elts) -> vec[U];
+    /**
+     * The T in vec_alloc[T, U] is the type of the vec to allocate.  The
+     * U is the type of an element in the vec.  So to allocate a vec[U] we
+     * want to invoke this as vec_alloc[vec[U], U].
+     */
+    fn vec_alloc[T, U](uint n_elts) -> vec[U];
 
-  fn refcount[T](vec[T] v) -> uint;
+    fn refcount[T](vec[T] v) -> uint;
 
-  fn vec_print_debug_info[T](vec[T] v);
+    fn vec_print_debug_info[T](vec[T] v);
 }
 
 fn alloc[T](uint n_elts) -> vec[T] {
-  ret rustrt.vec_alloc[vec[T], T](n_elts);
+    ret rustrt.vec_alloc[vec[T], T](n_elts);
 }
 
 fn refcount[T](vec[T] v) -> uint {
-  // -1 because calling this function incremented the refcount.
-  ret rustrt.refcount[T](v) - 1u;
+    // -1 because calling this function incremented the refcount.
+    ret rustrt.refcount[T](v) - 1u;
 }
 
 type init_op[T] = fn(uint i) -> T;
 
 fn init_fn[T](&init_op[T] op, uint n_elts) -> vec[T] {
-  let vec[T] v = alloc[T](n_elts);
-  let uint i = 0u;
-  while (i < n_elts) {
-    v += vec(op(i));
-    i += 1u;
-  }
-  ret v;
+    let vec[T] v = alloc[T](n_elts);
+    let uint i = 0u;
+    while (i < n_elts) {
+        v += vec(op(i));
+        i += 1u;
+    }
+    ret v;
 }
 
 fn init_elt[T](&T t, uint n_elts) -> vec[T] {
-  /**
-   * FIXME (issue #81): should be:
-   *
-   * fn elt_op[T](&T x, uint i) -> T { ret x; }
-   * let init_op[T] inner = bind elt_op[T](t, _);
-   * ret init_fn[T](inner, n_elts);
-   */
-  let vec[T] v = alloc[T](n_elts);
-  let uint i = n_elts;
-  while (i > 0u) {
-    i -= 1u;
-    v += vec(t);
-  }
-  ret v;
+    /**
+     * FIXME (issue #81): should be:
+     *
+     * fn elt_op[T](&T x, uint i) -> T { ret x; }
+     * let init_op[T] inner = bind elt_op[T](t, _);
+     * ret init_fn[T](inner, n_elts);
+     */
+    let vec[T] v = alloc[T](n_elts);
+    let uint i = n_elts;
+    while (i > 0u) {
+        i -= 1u;
+        v += vec(t);
+    }
+    ret v;
 }
 
 fn buf[T](vec[T] v) -> vbuf {
-  ret rustrt.vec_buf[T](v, 0u);
+    ret rustrt.vec_buf[T](v, 0u);
 }
 
 fn len[T](vec[T] v) -> uint {
-  ret rustrt.vec_len[T](v);
+    ret rustrt.vec_len[T](v);
 }
 
 fn len_set[T](vec[T] v, uint n) {
-  rustrt.vec_len_set[T](v, n);
+    rustrt.vec_len_set[T](v, n);
 }
 
 fn buf_off[T](vec[T] v, uint offset) -> vbuf {
-  check (offset < len[T](v));
-  ret rustrt.vec_buf[T](v, offset);
+    check (offset < len[T](v));
+    ret rustrt.vec_buf[T](v, offset);
 }
 
 fn print_debug_info[T](vec[T] v) {
-  rustrt.vec_print_debug_info[T](v);
+    rustrt.vec_print_debug_info[T](v);
 }
 
 // Returns elements from [start..end) from v.
 fn slice[T](vec[T] v, int start, int end) -> vec[T] {
-  check (0 <= start);
-  check (start <= end);
-  check (end <= (len[T](v) as int));
-  auto result = alloc[T]((end - start) as uint);
-  let int i = start;
-  while (i < end) {
-    result += vec(v.(i));
-    i += 1;
-  }
-  ret result;
+    check (0 <= start);
+    check (start <= end);
+    check (end <= (len[T](v) as int));
+    auto result = alloc[T]((end - start) as uint);
+    let int i = start;
+    while (i < end) {
+        result += vec(v.(i));
+        i += 1;
+    }
+    ret result;
 }
 
 fn grow[T](&mutable vec[T] v, int n, &T initval) {
-  let int i = n;
-  while (i > 0) {
-    i -= 1;
-    v += vec(initval);
-  }
+    let int i = n;
+    while (i > 0) {
+        i -= 1;
+        v += vec(initval);
+    }
 }
 
 fn map[T, U](&op[T,U] f, &vec[T] v) -> vec[U] {
-  let vec[U] u = alloc[U](len[T](v));
-  for (T ve in v) {
-    u += vec(f(ve));
-  }
-  ret u;
+    let vec[U] u = alloc[U](len[T](v));
+    for (T ve in v) {
+        u += vec(f(ve));
+    }
+    ret u;
 }
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/dbg.rs b/src/lib/dbg.rs
index 0ea8bd08a9b..6c856cf7983 100644
--- a/src/lib/dbg.rs
+++ b/src/lib/dbg.rs
@@ -8,33 +8,33 @@
 import std._vec;
 
 native "rust" mod rustrt {
-  fn debug_tydesc[T]();
-  fn debug_opaque[T](&T x);
-  fn debug_box[T](@T x);
-  fn debug_tag[T](&T x);
-  fn debug_obj[T](&T x, uint nmethods, uint nbytes);
-  fn debug_fn[T](&T x);
-  fn debug_ptrcast[T, U](@T x) -> @U;
+    fn debug_tydesc[T]();
+    fn debug_opaque[T](&T x);
+    fn debug_box[T](@T x);
+    fn debug_tag[T](&T x);
+    fn debug_obj[T](&T x, uint nmethods, uint nbytes);
+    fn debug_fn[T](&T x);
+    fn debug_ptrcast[T, U](@T x) -> @U;
 }
 
 fn debug_vec[T](vec[T] v) {
-  _vec.print_debug_info[T](v);
+    _vec.print_debug_info[T](v);
 }
 
 fn debug_tydesc[T]() {
-  rustrt.debug_tydesc[T]();
+    rustrt.debug_tydesc[T]();
 }
 
 fn debug_opaque[T](&T x) {
-  rustrt.debug_opaque[T](x);
+    rustrt.debug_opaque[T](x);
 }
 
 fn debug_box[T](@T x) {
-  rustrt.debug_box[T](x);
+    rustrt.debug_box[T](x);
 }
 
 fn debug_tag[T](&T x) {
-  rustrt.debug_tag[T](x);
+    rustrt.debug_tag[T](x);
 }
 
 /**
@@ -47,13 +47,22 @@ fn debug_tag[T](&T x) {
  * the front of any obj's data tuple.x
  */
 fn debug_obj[T](&T x, uint nmethods, uint nbytes) {
-  rustrt.debug_obj[T](x, nmethods, nbytes);
+    rustrt.debug_obj[T](x, nmethods, nbytes);
 }
 
 fn debug_fn[T](&T x) {
-  rustrt.debug_fn[T](x);
+    rustrt.debug_fn[T](x);
 }
 
 fn ptr_cast[T, U](@T x) -> @U {
-  ret rustrt.debug_ptrcast[T, U](x);
+    ret rustrt.debug_ptrcast[T, U](x);
 }
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/deque.rs b/src/lib/deque.rs
index 96a63880bac..959339d8e04 100644
--- a/src/lib/deque.rs
+++ b/src/lib/deque.rs
@@ -7,132 +7,142 @@ import std._vec;
 import std._int;
 
 type t[T] = obj {
-  fn size() -> uint;
+            fn size() -> uint;
 
-  fn add_front(&T t);
-  fn add_back(&T t);
+            fn add_front(&T t);
+            fn add_back(&T t);
 
-  fn pop_front() -> T;
-  fn pop_back() -> T;
+            fn pop_front() -> T;
+            fn pop_back() -> T;
 
-  fn peek_front() -> T;
-  fn peek_back() -> T;
+            fn peek_front() -> T;
+            fn peek_back() -> T;
 
-  fn get(int i) -> T;
+            fn get(int i) -> T;
 };
 
 fn create[T]() -> t[T] {
 
-  type cell[T] = mutable util.option[T];
+    type cell[T] = mutable util.option[T];
 
-  let uint initial_capacity = 32u; // 2^5
-
-  /**
-   * Grow is only called on full elts, so nelts is also len(elts), unlike
-   * elsewhere.
-   */
-  fn grow[T](uint nelts, uint lo, vec[cell[T]] elts) -> vec[cell[T]] {
-    check (nelts == _vec.len[cell[T]](elts));
-
-    fn fill[T](uint i, uint nelts, uint lo, &vec[cell[T]] old) -> cell[T] {
-      if (i < nelts) {
-        ret old.((lo + i) % nelts);
-      } else {
-        ret util.none[T];
-      }
-    }
-
-    let uint nalloc = _uint.next_power_of_two(nelts + 1u);
-    let _vec.init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts);
-    ret _vec.init_fn[cell[T]](copy_op, nalloc);
-  }
-
-  fn get[T](vec[cell[T]] elts, uint i) -> T {
-    alt (elts.(i)) {
-      case (util.some[T](?t)) { ret t; }
-      case (_) { fail; }
-    }
-  }
-
-  obj deque[T](mutable uint nelts,
-               mutable uint lo,
-               mutable uint hi,
-               mutable vec[cell[T]] elts)
-  {
-    fn size() -> uint { ret nelts; }
-
-    fn add_front(&T t) {
-      let uint oldlo = lo;
-
-      if (lo == 0u) {
-        lo = _vec.len[cell[T]](elts) - 1u;
-      } else {
-        lo -= 1u;
-      }
-
-      if (lo == hi) {
-        elts = grow[T](nelts, oldlo, elts);
-        lo = _vec.len[cell[T]](elts) - 1u;
-        hi = nelts;
-      }
-
-      elts.(lo) = util.some[T](t);
-      nelts += 1u;
-    }
-
-    fn add_back(&T t) {
-      if (lo == hi && nelts != 0u) {
-        elts = grow[T](nelts, lo, elts);
-        lo = 0u;
-        hi = nelts;
-      }
-
-      elts.(hi) = util.some[T](t);
-      hi = (hi + 1u) % _vec.len[cell[T]](elts);
-      nelts += 1u;
-    }
+    let uint initial_capacity = 32u; // 2^5
 
     /**
-     * We actually release (turn to none()) the T we're popping so that we
-     * don't keep anyone's refcount up unexpectedly.
+     * Grow is only called on full elts, so nelts is also len(elts), unlike
+     * elsewhere.
      */
-    fn pop_front() -> T {
-      let T t = get[T](elts, lo);
-      elts.(lo) = util.none[T];
-      lo = (lo + 1u) % _vec.len[cell[T]](elts);
-      nelts -= 1u;
-      ret t;
-    }
-
-    fn pop_back() -> T {
-      if (hi == 0u) {
-        hi = _vec.len[cell[T]](elts) - 1u;
-      } else {
-        hi -= 1u;
-      }
-
-      let T t = get[T](elts, hi);
-      elts.(hi) = util.none[T];
-      nelts -= 1u;
-      ret t;
-    }
-
-    fn peek_front() -> T {
-      ret get[T](elts, lo);
+    fn grow[T](uint nelts, uint lo, vec[cell[T]] elts) -> vec[cell[T]] {
+        check (nelts == _vec.len[cell[T]](elts));
+
+        fn fill[T](uint i, uint nelts, uint lo,
+                   &vec[cell[T]] old) -> cell[T] {
+            if (i < nelts) {
+                ret old.((lo + i) % nelts);
+            } else {
+                ret util.none[T];
+            }
+        }
+
+        let uint nalloc = _uint.next_power_of_two(nelts + 1u);
+        let _vec.init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts);
+        ret _vec.init_fn[cell[T]](copy_op, nalloc);
     }
 
-    fn peek_back() -> T {
-      ret get[T](elts, hi - 1u);
+    fn get[T](vec[cell[T]] elts, uint i) -> T {
+        alt (elts.(i)) {
+            case (util.some[T](?t)) { ret t; }
+            case (_) { fail; }
+        }
     }
 
-    fn get(int i) -> T {
-      let uint idx = (lo + (i as uint)) % _vec.len[cell[T]](elts);
-      ret get[T](elts, idx);
-    }
-
-  }
-  let vec[cell[T]] v = _vec.init_elt[cell[T]](util.none[T],
-                                              initial_capacity);
-
-  ret deque[T](0u, 0u, 0u, v);
+    obj deque[T](mutable uint nelts,
+                 mutable uint lo,
+                 mutable uint hi,
+                 mutable vec[cell[T]] elts)
+        {
+            fn size() -> uint { ret nelts; }
+
+            fn add_front(&T t) {
+                let uint oldlo = lo;
+
+                if (lo == 0u) {
+                    lo = _vec.len[cell[T]](elts) - 1u;
+                } else {
+                    lo -= 1u;
+                }
+
+                if (lo == hi) {
+                    elts = grow[T](nelts, oldlo, elts);
+                    lo = _vec.len[cell[T]](elts) - 1u;
+                    hi = nelts;
+                }
+
+                elts.(lo) = util.some[T](t);
+                nelts += 1u;
+            }
+
+            fn add_back(&T t) {
+                if (lo == hi && nelts != 0u) {
+                    elts = grow[T](nelts, lo, elts);
+                    lo = 0u;
+                    hi = nelts;
+                }
+
+                elts.(hi) = util.some[T](t);
+                hi = (hi + 1u) % _vec.len[cell[T]](elts);
+                nelts += 1u;
+            }
+
+            /**
+             * We actually release (turn to none()) the T we're popping so
+             * that we don't keep anyone's refcount up unexpectedly.
+             */
+            fn pop_front() -> T {
+                let T t = get[T](elts, lo);
+                elts.(lo) = util.none[T];
+                lo = (lo + 1u) % _vec.len[cell[T]](elts);
+                nelts -= 1u;
+                ret t;
+            }
+
+            fn pop_back() -> T {
+                if (hi == 0u) {
+                    hi = _vec.len[cell[T]](elts) - 1u;
+                } else {
+                    hi -= 1u;
+                }
+
+                let T t = get[T](elts, hi);
+                elts.(hi) = util.none[T];
+                nelts -= 1u;
+                ret t;
+            }
+
+            fn peek_front() -> T {
+                ret get[T](elts, lo);
+            }
+
+            fn peek_back() -> T {
+                ret get[T](elts, hi - 1u);
+            }
+
+            fn get(int i) -> T {
+                let uint idx = (lo + (i as uint)) % _vec.len[cell[T]](elts);
+                ret get[T](elts, idx);
+            }
+
+        }
+    let vec[cell[T]] v = _vec.init_elt[cell[T]](util.none[T],
+                                                initial_capacity);
+
+    ret deque[T](0u, 0u, 0u, v);
 }
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/linux_os.rs b/src/lib/linux_os.rs
index dd5d8bfc8cc..c81d8d70e86 100644
--- a/src/lib/linux_os.rs
+++ b/src/lib/linux_os.rs
@@ -3,38 +3,48 @@ import _vec.vbuf;
 
 native mod libc = "libc.so.6" {
 
-  fn open(sbuf s, int flags, uint mode) -> int;
-  fn read(int fd, vbuf buf, uint count) -> int;
-  fn write(int fd, vbuf buf, uint count) -> int;
-  fn close(int fd) -> int;
-
-  type FILE;
-  fn fopen(sbuf path, sbuf mode) -> FILE;
-  fn fclose(FILE f);
-  fn fgetc(FILE f) -> int;
-  fn ungetc(int c, FILE f);
-
-  type dir;
-  // readdir is a mess; handle via wrapper function in rustrt.
-  fn opendir(sbuf d) -> dir;
-  fn closedir(dir d) -> int;
-
-  fn getenv(sbuf n) -> sbuf;
-  fn setenv(sbuf n, sbuf v, int overwrite) -> int;
-  fn unsetenv(sbuf n) -> int;
+    fn open(sbuf s, int flags, uint mode) -> int;
+    fn read(int fd, vbuf buf, uint count) -> int;
+    fn write(int fd, vbuf buf, uint count) -> int;
+    fn close(int fd) -> int;
+
+    type FILE;
+    fn fopen(sbuf path, sbuf mode) -> FILE;
+    fn fclose(FILE f);
+    fn fgetc(FILE f) -> int;
+    fn ungetc(int c, FILE f);
+
+    type dir;
+    // readdir is a mess; handle via wrapper function in rustrt.
+    fn opendir(sbuf d) -> dir;
+    fn closedir(dir d) -> int;
+
+    fn getenv(sbuf n) -> sbuf;
+    fn setenv(sbuf n, sbuf v, int overwrite) -> int;
+    fn unsetenv(sbuf n) -> int;
 }
 
 mod libc_constants {
-  fn O_RDONLY() -> int { ret 0x0000; }
-  fn O_WRONLY() -> int { ret 0x0001; }
-  fn O_RDWR()   -> int { ret 0x0002; }
-  fn O_APPEND() -> int { ret 0x0400; }
-  fn O_CREAT()  -> int { ret 0x0040; }
-  fn O_EXCL()   -> int { ret 0x0080; }
-  fn O_TRUNC()  -> int { ret 0x0200; }
-  fn O_TEXT()   -> int { ret 0x0000; } // nonexistent in linux libc
-  fn O_BINARY() -> int { ret 0x0000; } // nonexistent in linux libc
-
-  fn S_IRUSR() -> uint { ret 0x0100u; }
-  fn S_IWUSR() -> uint { ret 0x0080u; }
+    fn O_RDONLY() -> int { ret 0x0000; }
+    fn O_WRONLY() -> int { ret 0x0001; }
+    fn O_RDWR()   -> int { ret 0x0002; }
+    fn O_APPEND() -> int { ret 0x0400; }
+    fn O_CREAT()  -> int { ret 0x0040; }
+    fn O_EXCL()   -> int { ret 0x0080; }
+    fn O_TRUNC()  -> int { ret 0x0200; }
+    fn O_TEXT()   -> int { ret 0x0000; } // nonexistent in linux libc
+    fn O_BINARY() -> int { ret 0x0000; } // nonexistent in linux libc
+
+    fn S_IRUSR() -> uint { ret 0x0100u; }
+    fn S_IWUSR() -> uint { ret 0x0080u; }
 }
+
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/macos_os.rs b/src/lib/macos_os.rs
index 22ab3a79daa..5025818151d 100644
--- a/src/lib/macos_os.rs
+++ b/src/lib/macos_os.rs
@@ -3,38 +3,47 @@ import _vec.vbuf;
 
 native mod libc = "libc.dylib" {
 
-  fn open(sbuf s, int flags, uint mode) -> int;
-  fn read(int fd, vbuf buf, uint count) -> int;
-  fn write(int fd, vbuf buf, uint count) -> int;
-  fn close(int fd) -> int;
-
-  type FILE;
-  fn fopen(sbuf path, sbuf mode) -> FILE;
-  fn fclose(FILE f);
-  fn fgetc(FILE f) -> int;
-  fn ungetc(int c, FILE f);
-
-  type dir;
-  // readdir is a mess; handle via wrapper function in rustrt.
-  fn opendir(sbuf d) -> dir;
-  fn closedir(dir d) -> int;
-
-  fn getenv(sbuf n) -> sbuf;
-  fn setenv(sbuf n, sbuf v, int overwrite) -> int;
-  fn unsetenv(sbuf n) -> int;
+    fn open(sbuf s, int flags, uint mode) -> int;
+    fn read(int fd, vbuf buf, uint count) -> int;
+    fn write(int fd, vbuf buf, uint count) -> int;
+    fn close(int fd) -> int;
+
+    type FILE;
+    fn fopen(sbuf path, sbuf mode) -> FILE;
+    fn fclose(FILE f);
+    fn fgetc(FILE f) -> int;
+    fn ungetc(int c, FILE f);
+
+    type dir;
+    // readdir is a mess; handle via wrapper function in rustrt.
+    fn opendir(sbuf d) -> dir;
+    fn closedir(dir d) -> int;
+
+    fn getenv(sbuf n) -> sbuf;
+    fn setenv(sbuf n, sbuf v, int overwrite) -> int;
+    fn unsetenv(sbuf n) -> int;
 }
 
 mod libc_constants {
-  fn O_RDONLY() -> int { ret 0x0000; }
-  fn O_WRONLY() -> int { ret 0x0001; }
-  fn O_RDWR()   -> int { ret 0x0002; }
-  fn O_APPEND() -> int { ret 0x0008; }
-  fn O_CREAT()  -> int { ret 0x0200; }
-  fn O_EXCL()   -> int { ret 0x0800; }
-  fn O_TRUNC()  -> int { ret 0x0400; }
-  fn O_TEXT()   -> int { ret 0x0000; } // nonexistent in darwin libc
-  fn O_BINARY() -> int { ret 0x0000; } // nonexistent in darwin libc
-
-  fn S_IRUSR() -> uint { ret 0x0400u; }
-  fn S_IWUSR() -> uint { ret 0x0200u; }
+    fn O_RDONLY() -> int { ret 0x0000; }
+    fn O_WRONLY() -> int { ret 0x0001; }
+    fn O_RDWR()   -> int { ret 0x0002; }
+    fn O_APPEND() -> int { ret 0x0008; }
+    fn O_CREAT()  -> int { ret 0x0200; }
+    fn O_EXCL()   -> int { ret 0x0800; }
+    fn O_TRUNC()  -> int { ret 0x0400; }
+    fn O_TEXT()   -> int { ret 0x0000; } // nonexistent in darwin libc
+    fn O_BINARY() -> int { ret 0x0000; } // nonexistent in darwin libc
+
+    fn S_IRUSR() -> uint { ret 0x0400u; }
+    fn S_IWUSR() -> uint { ret 0x0200u; }
 }
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/map.rs b/src/lib/map.rs
index 4047f638504..1ad83957015 100644
--- a/src/lib/map.rs
+++ b/src/lib/map.rs
@@ -13,206 +13,223 @@ type hashfn[K] = fn(&K) -> uint;
 type eqfn[K] = fn(&K, &K) -> bool;
 
 type hashmap[K, V] = obj {
-  fn size() -> uint;
-  fn insert(&K key, &V val) -> bool;
-  fn contains_key(&K key) -> bool;
-  fn get(&K key) -> V;
-  fn find(&K key) -> util.option[V];
-  fn remove(&K key) -> util.option[V];
-  fn rehash();
+                     fn size() -> uint;
+                     fn insert(&K key, &V val) -> bool;
+                     fn contains_key(&K key) -> bool;
+                     fn get(&K key) -> V;
+                     fn find(&K key) -> util.option[V];
+                     fn remove(&K key) -> util.option[V];
+                     fn rehash();
 };
 
 fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
 
-  let uint initial_capacity = 32u; // 2^5
-  let util.rational load_factor = rec(num=3, den=4);
-
-  tag bucket[K, V] {
-    nil;
-    deleted;
-    some(K, V);
-  }
-
-  fn make_buckets[K, V](uint nbkts) -> vec[mutable bucket[K, V]] {
-    ret _vec.init_elt[mutable bucket[K, V]](nil[K, V], nbkts);
-  }
-
-  // Derive two hash functions from the one given by taking the upper
-  // half and lower half of the uint bits.  Our bucket probing
-  // sequence is then defined by
-  //
-  //   hash(key, i) := hashl(key) + i * hashr(key)   for i = 0, 1, 2, ...
-  //
-  // Tearing the hash function apart this way is kosher in practice
-  // as, assuming 32-bit uints, the table would have to be at 2^32
-  // buckets before the resulting pair of hash functions no longer
-  // probes all buckets for a fixed key.  Note that hashr is made to
-  // output odd numbers (hence coprime to the number of nbkts, which
-  // is always a power of 2), so that all buckets are probed for a
-  // fixed key.
-
-  fn hashl[K](&hashfn[K] hasher, uint nbkts, &K key) -> uint {
-    ret (hasher(key) >>> (sys.rustrt.size_of[uint]() * 8u / 2u));
-  }
-
-  fn hashr[K](&hashfn[K] hasher, uint nbkts, &K key) -> uint {
-    ret ((((~ 0u) >>> (sys.rustrt.size_of[uint]() * 8u / 2u))
-          & hasher(key)) * 2u + 1u);
-  }
-
-  fn hash[K](&hashfn[K] hasher, uint nbkts, &K key, uint i) -> uint {
-    ret (hashl[K](hasher, nbkts, key)
-         + i * hashr[K](hasher, nbkts, key)) % nbkts;
-  }
-
-  /**
-   * We attempt to never call this with a full table.  If we do, it
-   * will fail.
-   */
-  fn insert_common[K, V](&hashfn[K] hasher,
-                         &eqfn[K] eqer,
-                         vec[mutable bucket[K, V]] bkts,
-                         uint nbkts,
-                         &K key,
-                         &V val)
-    -> bool
-  {
-    let uint i = 0u;
-    while (i < nbkts) {
-      let uint j = hash[K](hasher, nbkts, key, i);
-      alt (bkts.(j)) {
-        case (some[K, V](?k, _)) {
-          if (eqer(key, k)) {
-            bkts.(j) = some[K, V](k, val);
-            ret false;
-          }
-          i += 1u;
-        }
-        case (_) {
-          bkts.(j) = some[K, V](key, val);
-          ret true;
-        }
-      }
-    }
-    fail; // full table
-  }
-
-  fn find_common[K, V](&hashfn[K] hasher,
-                       &eqfn[K] eqer,
-                       vec[mutable bucket[K, V]] bkts,
-                       uint nbkts,
-                       &K key)
-    -> util.option[V]
-  {
-    let uint i = 0u;
-    while (i < nbkts) {
-      let uint j = (hash[K](hasher, nbkts, key, i));
-      alt (bkts.(j)) {
-        case (some[K, V](?k, ?v)) {
-          if (eqer(key, k)) {
-            ret util.some[V](v);
-          }
-        }
-        case (nil[K, V]) {
-          ret util.none[V];
-        }
-        case (deleted[K, V]) { }
-      }
-      i += 1u;
-    }
-    ret util.none[V];
-  }
-
-
-  fn rehash[K, V](&hashfn[K] hasher,
-                  &eqfn[K] eqer,
-                  vec[mutable bucket[K, V]] oldbkts, uint noldbkts,
-                  vec[mutable bucket[K, V]] newbkts, uint nnewbkts)
-  {
-    for (bucket[K, V] b in oldbkts) {
-      alt (b) {
-        case (some[K, V](?k, ?v)) {
-          insert_common[K, V](hasher, eqer, newbkts, nnewbkts, k, v);
-        }
-        case (_) { }
-      }
+    let uint initial_capacity = 32u; // 2^5
+    let util.rational load_factor = rec(num=3, den=4);
+
+    tag bucket[K, V] {
+        nil;
+        deleted;
+        some(K, V);
     }
-  }
-
-  obj hashmap[K, V](hashfn[K] hasher,
-                    eqfn[K] eqer,
-                    mutable vec[mutable bucket[K, V]] bkts,
-                    mutable uint nbkts,
-                    mutable uint nelts,
-                    util.rational lf)
-  {
-    fn size() -> uint { ret nelts; }
-
-    fn insert(&K key, &V val) -> bool {
-      let util.rational load = rec(num=(nelts + 1u) as int, den=nbkts as int);
-      if (!util.rational_leq(load, lf)) {
-        let uint nnewbkts = _uint.next_power_of_two(nbkts + 1u);
-        let vec[mutable bucket[K, V]] newbkts = make_buckets[K, V](nnewbkts);
-        rehash[K, V](hasher, eqer, bkts, nbkts, newbkts, nnewbkts);
-        bkts = newbkts;
-        nbkts = nnewbkts;
-      }
-
-      if (insert_common[K, V](hasher, eqer, bkts, nbkts, key, val)) {
-        nelts += 1u;
-        ret true;
-      }
-      ret false;
+
+    fn make_buckets[K, V](uint nbkts) -> vec[mutable bucket[K, V]] {
+        ret _vec.init_elt[mutable bucket[K, V]](nil[K, V], nbkts);
     }
 
-    fn contains_key(&K key) -> bool {
-      alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
-        case (util.some[V](_)) { ret true; }
-        case (_) { ret false; }
-      }
+    // Derive two hash functions from the one given by taking the upper
+    // half and lower half of the uint bits.  Our bucket probing
+    // sequence is then defined by
+    //
+    //   hash(key, i) := hashl(key) + i * hashr(key)   for i = 0, 1, 2, ...
+    //
+    // Tearing the hash function apart this way is kosher in practice
+    // as, assuming 32-bit uints, the table would have to be at 2^32
+    // buckets before the resulting pair of hash functions no longer
+    // probes all buckets for a fixed key.  Note that hashr is made to
+    // output odd numbers (hence coprime to the number of nbkts, which
+    // is always a power of 2), so that all buckets are probed for a
+    // fixed key.
+
+    fn hashl[K](&hashfn[K] hasher, uint nbkts, &K key) -> uint {
+        ret (hasher(key) >>> (sys.rustrt.size_of[uint]() * 8u / 2u));
     }
 
-    fn get(&K key) -> V {
-      alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
-        case (util.some[V](?val)) { ret val; }
-        case (_) { fail; }
-      }
+    fn hashr[K](&hashfn[K] hasher, uint nbkts, &K key) -> uint {
+        ret ((((~ 0u) >>> (sys.rustrt.size_of[uint]() * 8u / 2u))
+              & hasher(key)) * 2u + 1u);
     }
 
-    fn find(&K key) -> util.option[V] {
-      be find_common[K, V](hasher, eqer, bkts, nbkts, key);
+    fn hash[K](&hashfn[K] hasher, uint nbkts, &K key, uint i) -> uint {
+        ret (hashl[K](hasher, nbkts, key)
+             + i * hashr[K](hasher, nbkts, key)) % nbkts;
     }
 
-    fn remove(&K key) -> util.option[V] {
-      let uint i = 0u;
-      while (i < nbkts) {
-        let uint j = (hash[K](hasher, nbkts, key, i));
-        alt (bkts.(j)) {
-          case (some[K, V](?k, ?v)) {
-            if (eqer(key, k)) {
-              bkts.(j) = deleted[K, V];
-              nelts -= 1u;
-              ret util.some[V](v);
+    /**
+     * We attempt to never call this with a full table.  If we do, it
+     * will fail.
+     */
+    fn insert_common[K, V](&hashfn[K] hasher,
+                           &eqfn[K] eqer,
+                           vec[mutable bucket[K, V]] bkts,
+                           uint nbkts,
+                           &K key,
+                           &V val)
+        -> bool
+        {
+            let uint i = 0u;
+            while (i < nbkts) {
+                let uint j = hash[K](hasher, nbkts, key, i);
+                alt (bkts.(j)) {
+                    case (some[K, V](?k, _)) {
+                        if (eqer(key, k)) {
+                            bkts.(j) = some[K, V](k, val);
+                            ret false;
+                        }
+                        i += 1u;
+                    }
+                    case (_) {
+                        bkts.(j) = some[K, V](key, val);
+                        ret true;
+                    }
+                }
+            }
+            fail; // full table
+        }
+
+    fn find_common[K, V](&hashfn[K] hasher,
+                         &eqfn[K] eqer,
+                         vec[mutable bucket[K, V]] bkts,
+                         uint nbkts,
+                         &K key)
+        -> util.option[V]
+        {
+            let uint i = 0u;
+            while (i < nbkts) {
+                let uint j = (hash[K](hasher, nbkts, key, i));
+                alt (bkts.(j)) {
+                    case (some[K, V](?k, ?v)) {
+                        if (eqer(key, k)) {
+                            ret util.some[V](v);
+                        }
+                    }
+                    case (nil[K, V]) {
+                        ret util.none[V];
+                    }
+                    case (deleted[K, V]) { }
+                }
+                i += 1u;
             }
-          }
-          case (deleted[K, V]) { }
-          case (nil[K, V]) {
             ret util.none[V];
-          }
         }
-        i += 1u;
-      }
-      ret util.none[V];
-    }
 
-    fn rehash() {
-      let vec[mutable bucket[K, V]] newbkts = make_buckets[K, V](nbkts);
-      rehash[K, V](hasher, eqer, bkts, nbkts, newbkts, nbkts);
-      bkts = newbkts;
-    }
-  }
 
-  let vec[mutable bucket[K, V]] bkts = make_buckets[K, V](initial_capacity);
+    fn rehash[K, V](&hashfn[K] hasher,
+                    &eqfn[K] eqer,
+                    vec[mutable bucket[K, V]] oldbkts, uint noldbkts,
+                    vec[mutable bucket[K, V]] newbkts, uint nnewbkts)
+        {
+            for (bucket[K, V] b in oldbkts) {
+                alt (b) {
+                    case (some[K, V](?k, ?v)) {
+                        insert_common[K, V](hasher, eqer, newbkts,
+                                            nnewbkts, k, v);
+                    }
+                    case (_) { }
+                }
+            }
+        }
+
+    obj hashmap[K, V](hashfn[K] hasher,
+                      eqfn[K] eqer,
+                      mutable vec[mutable bucket[K, V]] bkts,
+                      mutable uint nbkts,
+                      mutable uint nelts,
+                      util.rational lf)
+        {
+            fn size() -> uint { ret nelts; }
+
+            fn insert(&K key, &V val) -> bool {
+                let util.rational load = rec(num=(nelts + 1u) as int,
+                                             den=nbkts as int);
+                if (!util.rational_leq(load, lf)) {
+                    let uint nnewbkts = _uint.next_power_of_two(nbkts + 1u);
+                    let vec[mutable bucket[K, V]] newbkts =
+                        make_buckets[K, V](nnewbkts);
+                    rehash[K, V](hasher, eqer, bkts, nbkts,
+                                 newbkts, nnewbkts);
+                    bkts = newbkts;
+                    nbkts = nnewbkts;
+                }
+
+                if (insert_common[K, V](hasher, eqer, bkts,
+                                        nbkts, key, val)) {
+                    nelts += 1u;
+                    ret true;
+                }
+                ret false;
+            }
+
+            fn contains_key(&K key) -> bool {
+                alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
+                    case (util.some[V](_)) { ret true; }
+                    case (_) { ret false; }
+                }
+            }
 
-  ret hashmap[K, V](hasher, eqer, bkts, initial_capacity, 0u, load_factor);
+            fn get(&K key) -> V {
+                alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
+                    case (util.some[V](?val)) { ret val; }
+                    case (_) { fail; }
+                }
+            }
+
+            fn find(&K key) -> util.option[V] {
+                be find_common[K, V](hasher, eqer, bkts, nbkts, key);
+            }
+
+            fn remove(&K key) -> util.option[V] {
+                let uint i = 0u;
+                while (i < nbkts) {
+                    let uint j = (hash[K](hasher, nbkts, key, i));
+                    alt (bkts.(j)) {
+                        case (some[K, V](?k, ?v)) {
+                            if (eqer(key, k)) {
+                                bkts.(j) = deleted[K, V];
+                                nelts -= 1u;
+                                ret util.some[V](v);
+                            }
+                        }
+                        case (deleted[K, V]) { }
+                        case (nil[K, V]) {
+                            ret util.none[V];
+                        }
+                    }
+                    i += 1u;
+                }
+                ret util.none[V];
+            }
+
+            fn rehash() {
+                let vec[mutable bucket[K, V]] newbkts =
+                    make_buckets[K, V](nbkts);
+                rehash[K, V](hasher, eqer, bkts, nbkts, newbkts, nbkts);
+                bkts = newbkts;
+            }
+        }
+
+    let vec[mutable bucket[K, V]] bkts =
+        make_buckets[K, V](initial_capacity);
+
+    ret hashmap[K, V](hasher, eqer, bkts, initial_capacity, 0u, load_factor);
 }
+
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/rand.rs b/src/lib/rand.rs
index 96dcbaf7d73..06eb2f06fd7 100644
--- a/src/lib/rand.rs
+++ b/src/lib/rand.rs
@@ -3,23 +3,32 @@
  */
 
 native "rust" mod rustrt {
-  type rctx;
-  fn rand_new() -> rctx;
-  fn rand_next(rctx c) -> u32;
-  fn rand_free(rctx c);
+    type rctx;
+    fn rand_new() -> rctx;
+    fn rand_next(rctx c) -> u32;
+    fn rand_free(rctx c);
 }
 
 type rng = obj { fn next() -> u32; };
 
 fn mk_rng() -> rng {
-  obj rt_rng(rustrt.rctx c) {
-    fn next() -> u32 {
-      ret rustrt.rand_next(c);
+    obj rt_rng(rustrt.rctx c) {
+        fn next() -> u32 {
+            ret rustrt.rand_next(c);
+        }
+        drop {
+            rustrt.rand_free(c);
+        }
     }
-    drop {
-      rustrt.rand_free(c);
-    }
-  }
 
-  ret rt_rng(rustrt.rand_new());
+    ret rt_rng(rustrt.rand_new());
 }
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/std.rc b/src/lib/std.rc
index 79dabc0e621..184a71abaff 100644
--- a/src/lib/std.rc
+++ b/src/lib/std.rc
@@ -38,17 +38,26 @@ auth rand.mk_rng = unsafe;
 // Target-OS module.
 
 alt (target_os) {
-  case ("win32") {
-    mod os = "win32_os.rs";
-  } case ("macos") {
-    mod os = "macos_os.rs";
-  } else {
-    mod os = "linux_os.rs";
-  }
-}
+    case ("win32") {
+        mod os = "win32_os.rs";
+    } case ("macos") {
+        mod os = "macos_os.rs";
+    } else {
+        mod os = "linux_os.rs";
+    }
+ }
 
 // FIXME: parametric 
 mod map;
 mod deque;
 mod rand;
 mod dbg;
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/sys.rs b/src/lib/sys.rs
index 18e2d3261c7..90e5cc49ff2 100644
--- a/src/lib/sys.rs
+++ b/src/lib/sys.rs
@@ -2,21 +2,29 @@ export rustrt;
 
 native "rust" mod rustrt {
 
-  // Explicitly re-export native stuff we want to be made
-  // available outside this crate. Otherwise it's
-  // visible-in-crate, but not re-exported.
+    // Explicitly re-export native stuff we want to be made
+    // available outside this crate. Otherwise it's
+    // visible-in-crate, but not re-exported.
 
-  export last_os_error;
-  export size_of;
-  export align_of;
-  export refcount;
-  export gc;
+    export last_os_error;
+    export size_of;
+    export align_of;
+    export refcount;
+    export gc;
 
-  fn last_os_error() -> str;
-  fn size_of[T]() -> uint;
-  fn align_of[T]() -> uint;
-  fn refcount[T](@T t) -> uint;
-  fn gc();
-  fn unsupervise();
+    fn last_os_error() -> str;
+    fn size_of[T]() -> uint;
+    fn align_of[T]() -> uint;
+    fn refcount[T](@T t) -> uint;
+    fn gc();
+    fn unsupervise();
 }
 
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/util.rs b/src/lib/util.rs
index 9b55d89a44d..f6e1327be15 100644
--- a/src/lib/util.rs
+++ b/src/lib/util.rs
@@ -1,23 +1,23 @@
 tag option[T] {
-  none;
-  some(T);
+    none;
+    some(T);
 }
 
 type operator[T, U] = fn(&T) -> U;
 
 fn option_map[T, U](&operator[T, U] f, &option[T] opt) -> option[U] {
-  alt (opt) {
-    case (some[T](?x)) {
-      ret some[U](f(x));
+    alt (opt) {
+        case (some[T](?x)) {
+            ret some[U](f(x));
+        }
+        case (none[T]) {
+            ret none[U];
+        }
     }
-    case (none[T]) {
-      ret none[U];
-    }
-  }
 }
 
 fn id[T](&T x) -> T {
-  ret x;
+    ret x;
 }
 
 /* FIXME (issue #141):  See test/run-pass/constrained-type.rs.  Uncomment
@@ -25,6 +25,15 @@ fn id[T](&T x) -> T {
 type rational = rec(int num, int den); // : _int.positive(*.den);
 
 fn rational_leq(&rational x, &rational y) -> bool {
-  // NB: Uses the fact that rationals have positive denominators WLOG.
-  ret x.num * y.den <= y.num * x.den;
+    // NB: Uses the fact that rationals have positive denominators WLOG.
+    ret x.num * y.den <= y.num * x.den;
 }
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End:
diff --git a/src/lib/win32_os.rs b/src/lib/win32_os.rs
index 3a6da60f56a..e0ad4188fa3 100644
--- a/src/lib/win32_os.rs
+++ b/src/lib/win32_os.rs
@@ -2,29 +2,38 @@ import _str.sbuf;
 import _vec.vbuf;
 
 native mod libc = "msvcrt.dll" {
-  fn open(sbuf s, int flags, uint mode) -> int = "_open";
-  fn read(int fd, vbuf buf, uint count) -> int = "_read";
-  fn write(int fd, vbuf buf, uint count) -> int = "_write";
-  fn close(int fd) -> int = "_close";
+    fn open(sbuf s, int flags, uint mode) -> int = "_open";
+    fn read(int fd, vbuf buf, uint count) -> int = "_read";
+    fn write(int fd, vbuf buf, uint count) -> int = "_write";
+    fn close(int fd) -> int = "_close";
 
-  type FILE;
-  fn fopen(sbuf path, sbuf mode) -> FILE;
-  fn fclose(FILE f);
-  fn fgetc(FILE f) -> int;
-  fn ungetc(int c, FILE f);
+    type FILE;
+    fn fopen(sbuf path, sbuf mode) -> FILE;
+    fn fclose(FILE f);
+    fn fgetc(FILE f) -> int;
+    fn ungetc(int c, FILE f);
 }
 
 mod libc_constants {
-  fn O_RDONLY() -> int { ret 0x0000; }
-  fn O_WRONLY() -> int { ret 0x0001; }
-  fn O_RDWR()   -> int { ret 0x0002; }
-  fn O_APPEND() -> int { ret 0x0400; }
-  fn O_CREAT()  -> int { ret 0x0040; }
-  fn O_EXCL()   -> int { ret 0x0080; }
-  fn O_TRUNC()  -> int { ret 0x0200; }
-  fn O_TEXT()   -> int { ret 0x4000; }
-  fn O_BINARY() -> int { ret 0x8000; }
+    fn O_RDONLY() -> int { ret 0x0000; }
+    fn O_WRONLY() -> int { ret 0x0001; }
+    fn O_RDWR()   -> int { ret 0x0002; }
+    fn O_APPEND() -> int { ret 0x0400; }
+    fn O_CREAT()  -> int { ret 0x0040; }
+    fn O_EXCL()   -> int { ret 0x0080; }
+    fn O_TRUNC()  -> int { ret 0x0200; }
+    fn O_TEXT()   -> int { ret 0x4000; }
+    fn O_BINARY() -> int { ret 0x8000; }
 
-  fn S_IRUSR() -> uint { ret 0x0100u; } // really _S_IREAD  in win32
-  fn S_IWUSR() -> uint { ret 0x0080u; } // really _S_IWRITE in win32
+    fn S_IRUSR() -> uint { ret 0x0100u; } // really _S_IREAD  in win32
+    fn S_IWUSR() -> uint { ret 0x0080u; } // really _S_IWRITE in win32
 }
+
+// Local Variables:
+// mode: rust;
+// fill-column: 78;
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
+// End: