[BACK]Return to strcasecmp.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpfr

Annotation of OpenXM_contrib/gmp/mpfr/strcasecmp.c, Revision 1.1

1.1     ! ohara       1: /* Copyright (C) 1991, 1992, 1995, 2002 Free Software Foundation, Inc.
        !             2: This file was part of the GNU C Library. Modified by kb@mail.tug.org to
        !             3: avoid glibc-isms. Modified by Vincent Lefevre (-> ISO C prototypes).
        !             4:
        !             5: This file is free software; you can redistribute it and/or
        !             6: modify it under the terms of the GNU Library General Public License as
        !             7: published by the Free Software Foundation; either version 2 of the
        !             8: License, or (at your option) any later version.
        !             9:
        !            10: This file is distributed in the hope that it will be useful,
        !            11: but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        !            13: Library General Public License for more details.
        !            14:
        !            15: You should have received a copy of the GNU Library General Public
        !            16: License along with this file; see the file COPYING.LIB.  If not, write
        !            17: to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
        !            18: Boston, MA 02111-1307, USA.  */
        !            19:
        !            20: #ifdef HAVE_CONFIG_H
        !            21: #include <config.h>
        !            22: #endif
        !            23:
        !            24: #if !defined (__STDC__) || !__STDC__
        !            25: /* This is a separate conditional since some stdc systems
        !            26:    reject `defined (const)'.  */
        !            27: #ifndef const
        !            28: #define const
        !            29: #endif
        !            30: #endif
        !            31:
        !            32: #include <ctype.h>
        !            33:
        !            34: int strcasecmp (const char *, const char *);
        !            35: int strncasecmp (const char *, const char *, size_t);
        !            36:
        !            37: /* Compare S1 and S2, ignoring case, returning less than, equal to or
        !            38:    greater than zero if S1 is lexiographically less than,
        !            39:    equal to or greater than S2.  */
        !            40: int
        !            41: strcasecmp (const char *s1, const char *s2)
        !            42: {
        !            43:   register const unsigned char *p1 = (const unsigned char *) s1;
        !            44:   register const unsigned char *p2 = (const unsigned char *) s2;
        !            45:   unsigned char c1, c2;
        !            46:
        !            47:   if (p1 == p2)
        !            48:     return 0;
        !            49:
        !            50:   do
        !            51:     {
        !            52:       c1 = tolower (*p1++);
        !            53:       c2 = tolower (*p2++);
        !            54:       if (c1 == '\0')
        !            55:        break;
        !            56:     }
        !            57:   while (c1 == c2);
        !            58:
        !            59:   return c1 - c2;
        !            60: }
        !            61:
        !            62: int
        !            63: strncasecmp (const char *s1, const char *s2, size_t n)
        !            64: {
        !            65:   register const unsigned char *p1 = (const unsigned char *) s1;
        !            66:   register const unsigned char *p2 = (const unsigned char *) s2;
        !            67:   unsigned char c1, c2;
        !            68:
        !            69:   if (p1 == p2 || n == 0)
        !            70:     return 0;
        !            71:
        !            72:   do
        !            73:     {
        !            74:       c1 = tolower (*p1++);
        !            75:       c2 = tolower (*p2++);
        !            76:       if (c1 == '\0' || c1 != c2)
        !            77:        return c1 - c2;
        !            78:     } while (--n > 0);
        !            79:
        !            80:   return c1 - c2;
        !            81: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>