From: Chris Hanson Date: Sun, 24 Jul 2005 05:08:30 +0000 (+0000) Subject: Rewrite 'strcmp_ci' to use 'toupper' from STDC rather than X-Git-Tag: 20090517-FFI~1242 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=b20075ba344ac2e8767db2aa6064a7867a90ba29;p=mit-scheme.git Rewrite 'strcmp_ci' to use 'toupper' from STDC rather than non-standardized '_toupper'. --- diff --git a/v7/src/microcode/primutl.c b/v7/src/microcode/primutl.c index 3579d2bca..08cef3a49 100644 --- a/v7/src/microcode/primutl.c +++ b/v7/src/microcode/primutl.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: primutl.c,v 9.78 2004/01/08 17:52:34 cph Exp $ +$Id: primutl.c,v 9.79 2005/07/24 05:08:30 cph Exp $ Copyright 1993,2000,2001,2004 Massachusetts Institute of Technology @@ -103,27 +103,25 @@ extern int /* Common utilities. */ -#ifndef _toupper -# define _toupper toupper -#endif - int -DEFUN (strcmp_ci, (s1, s2), fast char * s1 AND fast char * s2) +DEFUN (strcmp_ci, (s1, s2), char * s1 AND char * s2) { - fast int diff; + const unsigned char * p1 = ((unsigned char *) s1); + const unsigned char * p2 = ((unsigned char *) s2); + int diff; - while ((*s1 != '\0') && (*s2 != '\0')) - { - fast int c1 = (*s1++); - fast int c2 = (*s2++); - if (islower (c1)) c1 = (_toupper (c1)); - if (islower (c2)) c2 = (_toupper (c2)); - diff = (c1 - c2); - if (diff != 0) - return ((diff > 0) ? 1 : -1); - } - diff = (*s1 - *s2); - return ((diff == 0) ? 0 : ((diff > 0) ? 1 : -1)); + while ((*p1 != '\0') && (*p2 != '\0')) + { + int c1 = (*p1++); + int c2 = (*p2++); + c1 = (toupper (c1)); + c2 = (toupper (c2)); + diff = (c1 - c2); + if (diff != 0) + return ((diff > 0) ? 1 : -1); + } + diff = (((int) (*p1)) - ((int) (*p2))); + return ((diff == 0) ? 0 : (diff > 0) ? 1 : (-1)); } SCHEME_OBJECT