projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tweak comments
[gnulib.git]
/
lib
/
memcasecmp.c
diff --git
a/lib/memcasecmp.c
b/lib/memcasecmp.c
index
a4d2e96
..
a2e42e8
100644
(file)
--- a/
lib/memcasecmp.c
+++ b/
lib/memcasecmp.c
@@
-1,5
+1,5
@@
/* Case-insensitive buffer comparator.
/* Case-insensitive buffer comparator.
- Copyright (C) 1996 Free Software Foundation, Inc.
+ Copyright (C) 1996
, 1997
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-25,21
+25,23
@@
#include <ctype.h>
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
#include <ctype.h>
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
-#define IN_CTYPE_DOMAIN(c) 1
+#
define IN_CTYPE_DOMAIN(c) 1
#else
#else
-#define IN_CTYPE_DOMAIN(c) isascii(c)
+#
define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
#endif
-#define IS
UPPER(c) (IN_CTYPE_DOMAIN (c) && isupp
er (c))
+#define IS
LOWER(c) (IN_CTYPE_DOMAIN (c) && islow
er (c))
#if _LIBC || STDC_HEADERS
#if _LIBC || STDC_HEADERS
-# define TO
LOWER(c) tolow
er (c)
+# define TO
UPPER(c) toupp
er (c)
#else
#else
-# define TO
LOWER(c) (ISUPPER (c) ? tolow
er (c) : (c))
+# define TO
UPPER(c) (ISLOWER (c) ? toupp
er (c) : (c))
#endif
#include "memcasecmp.h"
#endif
#include "memcasecmp.h"
-/* Like memcmp, but ignore differences in case. */
+/* Like memcmp, but ignore differences in case.
+ Convert to upper case (not lower) before comparing so that
+ join -i works with sort -f. */
int
memcasecmp (vs1, vs2, n)
int
memcasecmp (vs1, vs2, n)
@@
-54,8
+56,8
@@
memcasecmp (vs1, vs2, n)
{
unsigned char u1 = *s1++;
unsigned char u2 = *s2++;
{
unsigned char u1 = *s1++;
unsigned char u2 = *s2++;
- if (TO
LOWER (u1) != TOLOW
ER (u2))
- return TO
LOWER (u1) - TOLOW
ER (u2);
+ if (TO
UPPER (u1) != TOUPP
ER (u2))
+ return TO
UPPER (u1) - TOUPP
ER (u2);
}
return 0;
}
}
return 0;
}