[15273] | 1 | /* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc. |
---|
| 2 | |
---|
| 3 | NOTE: The canonical source of this file is maintained with the GNU C Library. |
---|
[16930] | 4 | Bugs can be reported to bug-glibc@gnu.org. |
---|
[15273] | 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify it |
---|
| 7 | under the terms of the GNU General Public License as published by the |
---|
| 8 | Free Software Foundation; either version 2, or (at your option) any |
---|
| 9 | later version. |
---|
| 10 | |
---|
| 11 | This program is distributed in the hope that it will be useful, |
---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | GNU General Public License for more details. |
---|
| 15 | |
---|
| 16 | You should have received a copy of the GNU General Public License |
---|
| 17 | along with this program; if not, write to the Free Software |
---|
| 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
---|
| 19 | USA. */ |
---|
| 20 | |
---|
| 21 | #ifdef HAVE_CONFIG_H |
---|
| 22 | # include <config.h> |
---|
| 23 | #endif |
---|
| 24 | |
---|
| 25 | #include <ctype.h> |
---|
| 26 | #include <string.h> |
---|
| 27 | |
---|
| 28 | #ifndef weak_alias |
---|
| 29 | # define __strcasecmp strcasecmp |
---|
| 30 | # define TOLOWER(Ch) tolower (Ch) |
---|
| 31 | #else |
---|
| 32 | # ifdef USE_IN_EXTENDED_LOCALE_MODEL |
---|
| 33 | # define __strcasecmp __strcasecmp_l |
---|
| 34 | # define TOLOWER(Ch) __tolower_l ((Ch), loc) |
---|
| 35 | # else |
---|
| 36 | # define TOLOWER(Ch) tolower (Ch) |
---|
| 37 | # endif |
---|
| 38 | #endif |
---|
| 39 | |
---|
| 40 | #ifdef USE_IN_EXTENDED_LOCALE_MODEL |
---|
| 41 | # define LOCALE_PARAM , loc |
---|
| 42 | # define LOCALE_PARAM_DECL __locale_t loc; |
---|
| 43 | #else |
---|
| 44 | # define LOCALE_PARAM |
---|
| 45 | # define LOCALE_PARAM_DECL |
---|
| 46 | #endif |
---|
| 47 | |
---|
| 48 | /* Compare S1 and S2, ignoring case, returning less than, equal to or |
---|
| 49 | greater than zero if S1 is lexicographically less than, |
---|
| 50 | equal to or greater than S2. */ |
---|
| 51 | int |
---|
| 52 | __strcasecmp (s1, s2 LOCALE_PARAM) |
---|
| 53 | const char *s1; |
---|
| 54 | const char *s2; |
---|
| 55 | LOCALE_PARAM_DECL |
---|
| 56 | { |
---|
| 57 | const unsigned char *p1 = (const unsigned char *) s1; |
---|
| 58 | const unsigned char *p2 = (const unsigned char *) s2; |
---|
| 59 | unsigned char c1, c2; |
---|
| 60 | |
---|
| 61 | if (p1 == p2) |
---|
| 62 | return 0; |
---|
| 63 | |
---|
| 64 | do |
---|
| 65 | { |
---|
| 66 | c1 = TOLOWER (*p1++); |
---|
| 67 | c2 = TOLOWER (*p2++); |
---|
| 68 | if (c1 == '\0') |
---|
| 69 | break; |
---|
| 70 | } |
---|
| 71 | while (c1 == c2); |
---|
| 72 | |
---|
| 73 | return c1 - c2; |
---|
| 74 | } |
---|
| 75 | #ifndef __strcasecmp |
---|
| 76 | weak_alias (__strcasecmp, strcasecmp) |
---|
| 77 | #endif |
---|