home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / string / strcasecmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-21  |  805 b   |  32 lines

  1. /*
  2.  * This file is part of the C library for Linux and is
  3.  * covered by the GNU Library General Public license version 2, or
  4.  * any later version.
  5.  * 
  6.  * Copyright (C) 1992, 1993 Hoongjiu Lu
  7.  *
  8.  */
  9. #include <ansidecl.h>
  10. #include <string.h>
  11. #include <ctype.h>
  12.  
  13.  
  14. /* Compare S1 and S2, ignoring case, returning less than, equal to or
  15.    greater than zero if S1 is lexiographically less than,
  16.    equal to or greater than S2.  */
  17. int
  18. DEFUN(strcasecmp, (s1, s2), CONST char *s1 AND CONST char *s2)
  19. {
  20.   register CONST unsigned char *p1 = (CONST unsigned char *) s1;
  21.   register CONST unsigned char *p2 = (CONST unsigned char *) s2;
  22.   register int ret;
  23.   unsigned char c1;
  24.  
  25.   if (p1 == p2)
  26.     return 0;
  27.  
  28.   for (; !(ret = (c1 = tolower(*p1)) - tolower(*p2)); p1++, p2++)
  29.     if (c1 == '\0') break;
  30.   return ret;
  31. }
  32.