aboutsummaryrefslogtreecommitdiff
path: root/std/cstr.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-12-31 17:10:29 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-12-31 17:10:29 -0500
commit69132bdeda9f9ee672d883fd442b6158d8725422 (patch)
tree29b1bfd8acbab82442f83bbad2d06d0eea0d7f35 /std/cstr.zig
parent5f89393acb0e3626d942302ca24de14349850040 (diff)
downloadzig-69132bdeda9f9ee672d883fd442b6158d8725422.tar.gz
zig-69132bdeda9f9ee672d883fd442b6158d8725422.zip
IR: progress toward compiling standard library
* comptime fn call * is_comptime doesn't count as an instruction dependency * update more std code to latest zig
Diffstat (limited to 'std/cstr.zig')
-rw-r--r--std/cstr.zig18
1 files changed, 9 insertions, 9 deletions
diff --git a/std/cstr.zig b/std/cstr.zig
index ce847a5fbc..c994b3c814 100644
--- a/std/cstr.zig
+++ b/std/cstr.zig
@@ -15,12 +15,12 @@ pub fn len(ptr: &const u8) -> usize {
pub fn cmp(a: &const u8, b: &const u8) -> i8 {
var index: usize = 0;
while (a[index] == b[index] && a[index] != 0; index += 1) {}
- return if (a[index] > b[index]) {
- 1
+ if (a[index] > b[index]) {
+ return 1;
} else if (a[index] < b[index]) {
- -1
+ return -1;
} else {
- 0
+ return 0;
};
}
@@ -127,7 +127,7 @@ pub const CBuf = struct {
};
fn testSimpleCBuf() {
- @setFnTest(this, true);
+ @setFnTest(this);
var buf = %%CBuf.initEmpty(&debug.global_allocator);
assert(buf.len() == 0);
@@ -148,13 +148,13 @@ fn testSimpleCBuf() {
}
fn testCompileTimeStrCmp() {
- @setFnTest(this, true);
+ @setFnTest(this);
- assert(@constEval(cmp(c"aoeu", c"aoez") == -1));
+ assert(@staticEval(cmp(c"aoeu", c"aoez") == -1));
}
fn testCompileTimeStrLen() {
- @setFnTest(this, true);
+ @setFnTest(this);
- assert(@constEval(len(c"123456789") == 9));
+ assert(@staticEval(len(c"123456789") == 9));
}