Mercurial > hg > octave-jordi > gnulib-hg
annotate lib/memcasecmp.c @ 649:89f4c1937ac7
update FSF address in copyright and remove any trailing blanks
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Mon, 15 Jul 1996 02:41:49 +0000 |
parents | acf0ac624534 |
children | 3f92402509d3 |
rev | line source |
---|---|
597 | 1 /* Case-insensitive buffer comparator. |
2 Copyright (C) 1996 Free Software Foundation, Inc. | |
3 | |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2, or (at your option) | |
7 any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
649
89f4c1937ac7
update FSF address in copyright and remove any trailing blanks
Jim Meyering <jim@meyering.net>
parents:
602
diff
changeset
|
15 along with this program; if not, write to the Free Software Foundation, |
89f4c1937ac7
update FSF address in copyright and remove any trailing blanks
Jim Meyering <jim@meyering.net>
parents:
602
diff
changeset
|
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
597 | 17 |
18 /* Jim Meyering (meyering@na-net.ornl.gov) */ | |
19 | |
583 | 20 #ifdef HAVE_CONFIG_H |
21 # include <config.h> | |
22 #endif | |
23 | |
24 #include <sys/types.h> | |
25 #include <ctype.h> | |
26 | |
587 | 27 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) |
602
acf0ac624534
[IN_CTYPE_DOMAIN]: Rename from ISASCII.
Jim Meyering <jim@meyering.net>
parents:
597
diff
changeset
|
28 #define IN_CTYPE_DOMAIN(c) 1 |
587 | 29 #else |
602
acf0ac624534
[IN_CTYPE_DOMAIN]: Rename from ISASCII.
Jim Meyering <jim@meyering.net>
parents:
597
diff
changeset
|
30 #define IN_CTYPE_DOMAIN(c) isascii(c) |
587 | 31 #endif |
602
acf0ac624534
[IN_CTYPE_DOMAIN]: Rename from ISASCII.
Jim Meyering <jim@meyering.net>
parents:
597
diff
changeset
|
32 #define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c)) |
587 | 33 |
583 | 34 #if _LIBC || STDC_HEADERS |
35 # define TOLOWER(c) tolower (c) | |
36 #else | |
37 # define TOLOWER(c) (ISUPPER (c) ? tolower (c) : (c)) | |
38 #endif | |
39 | |
40 #include "memcasecmp.h" | |
41 | |
42 /* Like memcmp, but ignore differences in case. */ | |
43 | |
44 int | |
587 | 45 memcasecmp (vs1, vs2, n) |
46 const void *vs1; | |
47 const void *vs2; | |
48 size_t n; | |
583 | 49 { |
50 unsigned int i; | |
51 unsigned char *s1 = (unsigned char *) vs1; | |
52 unsigned char *s2 = (unsigned char *) vs2; | |
53 for (i = 0; i < n; i++) | |
54 { | |
55 unsigned char u1 = *s1++; | |
56 unsigned char u2 = *s2++; | |
57 if (TOLOWER (u1) != TOLOWER (u2)) | |
58 return TOLOWER (u1) - TOLOWER (u2); | |
59 } | |
60 return 0; | |
61 } |