From: andy Date: Tue, 21 Mar 2006 21:57:00 +0000 (+0000) Subject: Melchior discovered that cmp() was just wrong, failing to actually X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6e973e07f406e2abd456a7ba7f3841543eca1c8b;p=simgear.git Melchior discovered that cmp() was just wrong, failing to actually inspect the string pointers. It also failed to properly sort strings where one is a prefix of the other. It looks to me like I just never finished this, and it ended up in CVS because it just happened to compile... --- diff --git a/simgear/nasal/lib.c b/simgear/nasal/lib.c index a9feb00c..7984e3dd 100644 --- a/simgear/nasal/lib.c +++ b/simgear/nasal/lib.c @@ -107,20 +107,18 @@ static naRef streq(naContext c, naRef me, int argc, naRef* args) static naRef f_cmp(naContext c, naRef me, int argc, naRef* args) { char *a, *b; - int i, len; + int i, alen, blen; if(argc < 2 || !naIsString(args[0]) || !naIsString(args[1])) naRuntimeError(c, "bad argument to cmp"); a = naStr_data(args[0]); + alen = naStr_len(args[0]); b = naStr_data(args[1]); - len = naStr_len(args[0]); - if(naStr_len(args[1]) < len) - len = naStr_len(args[1]); - for(i=0; i 0) return naNum(1); + blen = naStr_len(args[1]); + for(i=0; i= 0 && olen < len) { va_end(va); return buf; }