1 /* 2 * scratch implementation of strcasecmp(), 3 * in case your C library doesn't have it 4 * 5 * For license terms, see the file COPYING in this directory. 6 */ 7 8 #ifdef HAVE_CONFIG_H 9 #include "config.h" 10 #endif 11 12 #ifndef HAVE_STRCASECMP 13 #include <ctype.h> 14 strcasecmp(char * s1,char * s2)15strcasecmp(char *s1, char *s2) 16 { 17 while (toupper(*s1) == toupper(*s2++)) 18 if (*s1++ == '\0') 19 return(0); 20 return(toupper(*s1) - toupper(*--s2)); 21 } 22 strncasecmp(char * s1,char * s2,register int n)23strncasecmp(char *s1, char *s2, register int n) 24 { 25 while (--n >= 0 && toupper(*s1) == toupper(*s2++)) 26 if (toupper(*s1++) == '\0') 27 return(0); 28 return(n < 0 ? 0 : toupper(*s1) - toupper(*--s2)); 29 } 30 31 #endif /* !HAVE_STRCASECMP */ 32 33 /* Local Variables: 34 * mode: C; 35 * c-file-style: gnu; 36 * indent-tabs-mode: nil; 37 * End: 38 */ 39