annotate liboctave/strcasecmp.c @ 6650:10da0f6d85c2 ss-2-9-11

[project @ 2007-05-22 06:48:18 by jwe]
author jwe
date Tue, 22 May 2007 06:48:18 +0000
parents ed81d74118bb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6111
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
1 /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
2 This file is part of the GNU C Library.
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
3
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
4 The GNU C Library is free software; you can redistribute it and/or
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
5 modify it under the terms of the GNU General Public License as
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
6 published by the Free Software Foundation; either version 2 of the
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
7 License, or (at your option) any later version.
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
8
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
9 The GNU C Library is distributed in the hope that it will be useful,
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
12 General Public License for more details.
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
13
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
14 You should have received a copy of the GNU General Public
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
15 License along with the GNU C Library; see the file COPYING. If
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
16 not, write to the Free Software Foundation, Inc., 51 Franklin Street,
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
17 Fifth Floor, Boston, MA 02110-1301, USA. */
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
18
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
19 #ifdef HAVE_CONFIG_H
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
20 #include <config.h>
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
21 #endif
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
22
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
23 #ifndef HAVE_STRCASECMP
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
24
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
25 #include <ctype.h>
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
26 #include <string.h>
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
27
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
28 /* Compare S1 and S2, ignoring case, returning less than, equal to or
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
29 greater than zero if S1 is lexiographically less than,
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
30 equal to or greater than S2. */
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
31 int
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
32 strcasecmp (const char *s1, const char *s2)
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
33 {
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
34 register const unsigned char *p1 = (const unsigned char *) s1;
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
35 register const unsigned char *p2 = (const unsigned char *) s2;
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
36 unsigned char c1, c2;
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
37
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
38 if (p1 == p2)
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
39 return 0;
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
40
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
41 do
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
42 {
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
43 c1 = tolower (*p1++);
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
44 c2 = tolower (*p2++);
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
45 if (c1 == '\0')
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
46 break;
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
47 }
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
48 while (c1 == c2);
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
49
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
50 return c1 - c2;
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
51 }
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
52
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents:
diff changeset
53 #endif