[Wisp-cvs] wisp/src/builtin dictbase.wisp,1.241,1.242 strings.wisp,1.102,1.103
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2002-09-11 17:35:07
|
Update of /cvsroot/wisp/wisp/src/builtin In directory usw-pr-cvs1:/tmp/cvs-serv4198/src/builtin Modified Files: dictbase.wisp strings.wisp Log Message: Made |string-compare| able to compare strings of different character width. Index: dictbase.wisp =================================================================== RCS file: /cvsroot/wisp/wisp/src/builtin/dictbase.wisp,v retrieving revision 1.241 retrieving revision 1.242 diff -u -d -r1.241 -r1.242 --- dictbase.wisp 7 Sep 2002 22:03:56 -0000 1.241 +++ dictbase.wisp 11 Sep 2002 17:35:03 -0000 1.242 @@ -135,7 +135,6 @@ (local rvec-set! (asm NN_rvec_set)) (local salloc (asm NN_salloc)) (local string (asm NN_string)) -(local string-compare (asm NN_strcomp)) (local string-fill! (asm NN_string_fill)) (local string-length (asm NN_string_length)) ;(local string-move! (asm NN_string_move)) Index: strings.wisp =================================================================== RCS file: /cvsroot/wisp/wisp/src/builtin/strings.wisp,v retrieving revision 1.102 retrieving revision 1.103 diff -u -d -r1.102 -r1.103 --- strings.wisp 7 Sep 2002 22:02:43 -0000 1.102 +++ strings.wisp 11 Sep 2002 17:35:03 -0000 1.103 @@ -155,6 +155,23 @@ ;; Comparison +(define (string-compare s t) + (if (and (c8string? s) (c8string? t)) + ((asm NN_strcomp) s t) + (let ((sl (string-length s)) + (tl (string-length t))) + (my ml (if (< sl tl) sl tl) + (let (loop (i 0)) + (if (< i ml) + (cond + ((char>? s[i] t[i]) 1) + ((char<? s[i] t[i]) -1) + (else (loop (+ i 1)))) + (cond + ((> sl tl) 1) + ((< sl tl) -1) + (else 0)))))))) + (define (string=? s t) (zero? (string-compare s t))) |