]> git.saurik.com Git - apple/libc.git/blob - string/FreeBSD/strcoll.c.patch
47bae5979271003f1cdc2f613ac00681710c27d6
[apple/libc.git] / string / FreeBSD / strcoll.c.patch
1 --- strcoll.c.orig 2003-05-20 15:23:54.000000000 -0700
2 +++ strcoll.c 2005-02-17 10:37:14.000000000 -0800
3 @@ -28,26 +28,30 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/string/strcoll.c,v 1.13 2001/11/07 19:55:16 obrien Exp $");
6
7 +#include "xlocale_private.h"
8 +
9 #include <stdlib.h>
10 #include <string.h>
11 #include "collate.h"
12
13 int
14 -strcoll(s, s2)
15 +strcoll_l(s, s2, loc)
16 const char *s, *s2;
17 + locale_t loc;
18 {
19 int len, len2, prim, prim2, sec, sec2, ret, ret2;
20 const char *t, *t2;
21 char *tt, *tt2;
22
23 - if (__collate_load_error)
24 + NORMALIZE_LOCALE(loc);
25 + if (loc->__collate_load_error)
26 return strcmp(s, s2);
27
28 len = len2 = 1;
29 ret = ret2 = 0;
30 - if (__collate_substitute_nontrivial) {
31 - t = tt = __collate_substitute(s);
32 - t2 = tt2 = __collate_substitute(s2);
33 + if (loc->__collate_substitute_nontrivial) {
34 + t = tt = (char *)__collate_substitute_l((unsigned char *)s, loc);
35 + t2 = tt2 = (char *)__collate_substitute_l((unsigned char *)s2, loc);
36 } else {
37 tt = tt2 = NULL;
38 t = s;
39 @@ -56,11 +60,11 @@
40 while(*t && *t2) {
41 prim = prim2 = 0;
42 while(*t && !prim) {
43 - __collate_lookup(t, &len, &prim, &sec);
44 + __collate_lookup_l((unsigned char *)t, &len, &prim, &sec, loc);
45 t += len;
46 }
47 while(*t2 && !prim2) {
48 - __collate_lookup(t2, &len2, &prim2, &sec2);
49 + __collate_lookup_l((unsigned char *)t2, &len2, &prim2, &sec2, loc);
50 t2 += len2;
51 }
52 if(!prim || !prim2)
53 @@ -73,9 +77,9 @@
54 ret2 = sec - sec2;
55 }
56 if(!*t && *t2)
57 - ret = -(int)((u_char)*t2);
58 + ret = -(int)((unsigned char)*t2);
59 else if(*t && !*t2)
60 - ret = (u_char)*t;
61 + ret = (unsigned char)*t;
62 else if(!*t && !*t2)
63 ret = ret2;
64 end:
65 @@ -84,3 +88,10 @@
66
67 return ret;
68 }
69 +
70 +int
71 +strcoll(s, s2)
72 + const char *s, *s2;
73 +{
74 + return strcoll_l(s, s2, __current_locale());
75 +}