diff options
| author | Charles.Forsyth <devnull@localhost> | 2007-02-17 17:53:48 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2007-02-17 17:53:48 +0000 |
| commit | 2249108ae3e3c5d02e45007e195672e350517856 (patch) | |
| tree | 3da5b86485276c26726c55e23da718686986f61a /appl/lib/libc0.b | |
| parent | 463f3a975e935d078a7c3479e0a56afb06f10fb5 (diff) | |
fix issue 9, add preliminary lists module
Diffstat (limited to 'appl/lib/libc0.b')
| -rw-r--r-- | appl/lib/libc0.b | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/appl/lib/libc0.b b/appl/lib/libc0.b index a9a2e834..aa6caff2 100644 --- a/appl/lib/libc0.b +++ b/appl/lib/libc0.b @@ -170,12 +170,20 @@ strcmp(s1: array of byte, s2: array of byte): int strncmp(s1: array of byte, s2: array of byte, n: int): int { - l1 := strlen(s1); - l2 := strlen(s2); - for(i := 0; i < l1 && i < l2 && i < n; i++) - if(s1[i] != s2[i]) - return int s1[i]-int s2[i]; - return l1-l2; + i1 := i2 := 0; + while(n > 0){ + c1 := int s1[i1++]; + c2 := int s2[i2++]; + n--; + if(c1 != c2){ + if(c1 > c2) + return 1; + return -1; + } + if(c1 == 0) + break; + } + return 0; } strchr(s: array of byte, n: int): array of byte |
