diff options
| author | Patrick Walton <[email protected]> | 2011-03-25 18:34:21 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-03-25 18:35:30 -0700 |
| commit | 24a75eeccc7990e2c15e47c31283705f6091f752 (patch) | |
| tree | 85ad91e31f3b2ccf1385a4992b05186ffe5e5d20 /src/lib | |
| parent | Add get_extern_const, factor get_extern into get_extern_fn and get_simple_ext... (diff) | |
| download | rust-24a75eeccc7990e2c15e47c31283705f6091f752.tar.xz rust-24a75eeccc7990e2c15e47c31283705f6091f752.zip | |
rustc: Parse definition IDs from crates; add a function to parse unsigned ints to the standard library
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/_uint.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/_uint.rs b/src/lib/_uint.rs index f456b733..f6686b5d 100644 --- a/src/lib/_uint.rs +++ b/src/lib/_uint.rs @@ -33,6 +33,18 @@ fn next_power_of_two(uint n) -> uint { ret tmp + 1u; } +fn parse_buf(vec[u8] buf, uint radix) -> uint { + auto i = _vec.len[u8](buf) - 1u; + auto power = 1u; + auto n = 0u; + while (i >= 0u) { + n += (((buf.(i)) - ('0' as u8)) as uint) * power; + power *= radix; + i -= 1u; + } + ret n; +} + fn to_str(uint num, uint radix) -> str { auto n = num; |