summaryrefslogtreecommitdiff
path: root/lib/libc/string/strxfrm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/string/strxfrm.c')
-rw-r--r--lib/libc/string/strxfrm.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/libc/string/strxfrm.c b/lib/libc/string/strxfrm.c
index a4c8019468d6a..b758b0c4a3832 100644
--- a/lib/libc/string/strxfrm.c
+++ b/lib/libc/string/strxfrm.c
@@ -3,6 +3,11 @@
* at Electronni Visti IA, Kiev, Ukraine.
* All rights reserved.
*
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed by David Chisnall
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -33,11 +38,22 @@ __FBSDID("$FreeBSD$");
#include "collate.h"
size_t
+strxfrm_l(char * __restrict dest, const char * __restrict src, size_t len, locale_t loc);
+size_t
strxfrm(char * __restrict dest, const char * __restrict src, size_t len)
{
+ return strxfrm_l(dest, src, len, __get_locale());
+}
+
+size_t
+strxfrm_l(char * __restrict dest, const char * __restrict src, size_t len, locale_t locale)
+{
int prim, sec, l;
size_t slen;
char *s, *ss;
+ FIX_LOCALE(locale);
+ struct xlocale_collate *table =
+ (struct xlocale_collate*)locale->components[XLC_COLLATE];
if (!*src) {
if (len > 0)
@@ -45,15 +61,15 @@ strxfrm(char * __restrict dest, const char * __restrict src, size_t len)
return 0;
}
- if (__collate_load_error)
+ if (table->__collate_load_error)
return strlcpy(dest, src, len);
slen = 0;
prim = sec = 0;
- ss = s = __collate_substitute(src);
+ ss = s = __collate_substitute(table, src);
while (*s) {
while (*s && !prim) {
- __collate_lookup(s, &l, &prim, &sec);
+ __collate_lookup(table, s, &l, &prim, &sec);
s += l;
}
if (prim) {