]> git.saurik.com Git - apple/libc.git/blame_incremental - string/FreeBSD/strcasecmp.c.patch
Libc-391.5.22.tar.gz
[apple/libc.git] / string / FreeBSD / strcasecmp.c.patch
... / ...
CommitLineData
1--- strcasecmp.c.orig 2003-05-20 15:23:54.000000000 -0700
2+++ strcasecmp.c 2005-02-18 18:46:40.000000000 -0800
3@@ -37,41 +37,62 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/string/strcasecmp.c,v 1.6 2002/08/30 15:40:01 robert Exp $");
6
7+#include "xlocale_private.h"
8+
9 #include <strings.h>
10 #include <ctype.h>
11
12 typedef unsigned char u_char;
13
14 int
15-strcasecmp(s1, s2)
16+strcasecmp_l(s1, s2, loc)
17 const char *s1, *s2;
18+ locale_t loc;
19 {
20 const u_char
21 *us1 = (const u_char *)s1,
22 *us2 = (const u_char *)s2;
23
24- while (tolower(*us1) == tolower(*us2++))
25+ NORMALIZE_LOCALE(loc);
26+ while (tolower_l(*us1, loc) == tolower_l(*us2++, loc))
27 if (*us1++ == '\0')
28 return (0);
29- return (tolower(*us1) - tolower(*--us2));
30+ return (tolower_l(*us1, loc) - tolower_l(*--us2, loc));
31 }
32
33 int
34-strncasecmp(s1, s2, n)
35+strcasecmp(s1, s2)
36+ const char *s1, *s2;
37+{
38+ return strcasecmp_l(s1, s2, __current_locale());
39+}
40+
41+int
42+strncasecmp_l(s1, s2, n, loc)
43 const char *s1, *s2;
44 size_t n;
45+ locale_t loc;
46 {
47+ NORMALIZE_LOCALE(loc);
48 if (n != 0) {
49 const u_char
50 *us1 = (const u_char *)s1,
51 *us2 = (const u_char *)s2;
52
53 do {
54- if (tolower(*us1) != tolower(*us2++))
55- return (tolower(*us1) - tolower(*--us2));
56+ if (tolower_l(*us1, loc) != tolower_l(*us2++, loc))
57+ return (tolower_l(*us1, loc) - tolower_l(*--us2, loc));
58 if (*us1++ == '\0')
59 break;
60 } while (--n != 0);
61 }
62 return (0);
63 }
64+
65+int
66+strncasecmp(s1, s2, n)
67+ const char *s1, *s2;
68+ size_t n;
69+{
70+ return strncasecmp_l(s1, s2, n, __current_locale());
71+}