1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /* $XConsortium: ansi_c.c /main/1 1996/04/21 19:25:03 drk $
- *
- * (c) Copyright 1996 Digital Equipment Corporation.
- * (c) Copyright 1996 Hewlett-Packard Company.
- * (c) Copyright 1996 International Business Machines Corp.
- * (c) Copyright 1993-1996 Sun Microsystems, Inc.
- * (c) Copyright 1996 Novell, Inc.
- * (c) Copyright 1996 FUJITSU LIMITED.
- * (c) Copyright 1996 Hitachi.
- */
- #include <ctype.h>
- #include "ansi_c.h"
- #ifdef NEED_STRCASECMP
- /*
- * In case strcasecmp and strncasecmp are not provided by the system
- * here are ones which do the trick.
- */
- int
- strcasecmp(const char *s1,
- const char *s2)
- {
- int c1, c2;
- while (*s1 && *s2) {
- c1 = isupper(*s1) ? tolower(*s1) : *s1;
- c2 = isupper(*s2) ? tolower(*s2) : *s2;
- if (c1 != c2)
- return (c1 - c2);
- s1++;
- s2++;
- }
- return (int) (*s1 - *s2);
- }
- int
- strncasecmp(const char *s1,
- const char *s2,
- size_t count)
- {
- int c1, c2;
- if (!count)
- return 0;
- while (*s1 && *s2) {
- c1 = isupper(*s1) ? tolower(*s1) : *s1;
- c2 = isupper(*s2) ? tolower(*s2) : *s2;
- if ((c1 != c2) || (! --count))
- return (c1 - c2);
- s1++;
- s2++;
- }
- return (int) (*s1 - *s2);
- }
- #else
- int ansi_c_strcasecmp_not_needed = 0; /* Make the compiler happy. */
- #endif
|