]> git.saurik.com Git - apple/libc.git/blame - string/FreeBSD/strxfrm.c.patch
Libc-391.5.22.tar.gz
[apple/libc.git] / string / FreeBSD / strxfrm.c.patch
CommitLineData
3d9156a7
A
1--- strxfrm.c.orig 2003-05-20 15:23:55.000000000 -0700
2+++ strxfrm.c 2005-02-17 15:06:28.000000000 -0800
3@@ -28,24 +28,28 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/string/strxfrm.c,v 1.15 2002/09/06 11:24:06 tjr Exp $");
6
7+#include "xlocale_private.h"
8+
9 #include <stdlib.h>
10 #include <string.h>
11 #include "collate.h"
12
13 size_t
14-strxfrm(char * __restrict dest, const char * __restrict src, size_t len)
15+strxfrm_l(char * __restrict dest, const char * __restrict src, size_t len,
16+ locale_t loc)
17 {
18 int prim, sec, l;
19 size_t slen;
20 char *s, *ss;
21
22+ NORMALIZE_LOCALE(loc);
23 if (!*src) {
24 if (len > 0)
25 *dest = '\0';
26 return 0;
27 }
28
29- if (__collate_load_error) {
30+ if (loc->__collate_load_error) {
31 slen = strlen(src);
32 if (len > 0) {
33 if (slen < len)
34@@ -60,10 +64,10 @@
35
36 slen = 0;
37 prim = sec = 0;
38- ss = s = __collate_substitute(src);
39+ ss = s = (char *)__collate_substitute_l((unsigned char *)src, loc);
40 while (*s) {
41 while (*s && !prim) {
42- __collate_lookup(s, &l, &prim, &sec);
43+ __collate_lookup_l((unsigned char *)s, &l, &prim, &sec, loc);
44 s += l;
45 }
46 if (prim) {
47@@ -81,3 +85,9 @@
48
49 return slen;
50 }
51+
52+size_t
53+strxfrm(char * __restrict dest, const char * __restrict src, size_t len)
54+{
55+ return strxfrm_l(dest, src, len, __current_locale());
56+}