From 2249108ae3e3c5d02e45007e195672e350517856 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Sat, 17 Feb 2007 17:53:48 +0000 Subject: fix issue 9, add preliminary lists module --- appl/lib/libc0.b | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'appl/lib/libc0.b') 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 -- cgit v1.2.3