unsigned integers for sizes of things

Closes #62.
This commit is contained in:
Andrew Kelley
2016-07-26 20:40:11 -07:00
parent 76f87cdd96
commit bc81ddfea6
19 changed files with 264 additions and 394 deletions

View File

@@ -1,8 +1,8 @@
// TODO fix https://github.com/andrewrk/zig/issues/140
// and then make this able to run at compile time
#static_eval_enable(false)
pub fn len(ptr: &const u8) -> isize {
var count: isize = 0;
pub fn len(ptr: &const u8) -> usize {
var count: usize = 0;
while (ptr[count] != 0; count += 1) {}
return count;
}
@@ -11,7 +11,7 @@ pub fn len(ptr: &const u8) -> isize {
// and then make this able to run at compile time
#static_eval_enable(false)
pub fn cmp(a: &const u8, b: &const u8) -> i32 {
var index: isize = 0;
var index: usize = 0;
while (a[index] == b[index] && a[index] != 0; index += 1) {}
return a[index] - b[index];
}