summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/collcmp.c
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-06-05 19:12:52 +0000
committerpfg <pfg@FreeBSD.org>2016-06-05 19:12:52 +0000
commit0366f1b52787fc04c4e16927e2a5d2d9b9920673 (patch)
tree10d3a6e472257f64e9b5efe360f166cb3ee1940c /lib/libc/locale/collcmp.c
parent4d8712daf1610ccab464077fdc055a48a4b845ed (diff)
downloadFreeBSD-src-0366f1b52787fc04c4e16927e2a5d2d9b9920673.zip
FreeBSD-src-0366f1b52787fc04c4e16927e2a5d2d9b9920673.tar.gz
libc/locale: Fix type breakage in __collate_range_cmp().
When collation support was brought in, the second and third arguments in __collate_range_cmp() were changed from int to wchar_t, breaking the ABI. Change them to a "char" type which makes more sense and keeps the ABI compatible. Also introduce __wcollate_range_cmp() which does work with wide characters. This function is used only internally in libc so we don't export it. Use the new function in glob(3), fnmatch(3), and regexec(3). PR: 179721 Suggested by: ache. jilles MFC after: 3 weeks (perhaps partial only)
Diffstat (limited to 'lib/libc/locale/collcmp.c')
-rw-r--r--lib/libc/locale/collcmp.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/libc/locale/collcmp.c b/lib/libc/locale/collcmp.c
index 102fbfb..b90c379 100644
--- a/lib/libc/locale/collcmp.c
+++ b/lib/libc/locale/collcmp.c
@@ -41,14 +41,27 @@ __FBSDID("$FreeBSD$");
* Compare two characters using collate
*/
-int __collate_range_cmp(struct xlocale_collate *table, wchar_t c1, wchar_t c2)
+int __collate_range_cmp(struct xlocale_collate *table, char c1, char c2)
+{
+ char s1[2], s2[2];
+
+ s1[0] = c1;
+ s1[1] = '\0';
+ s2[0] = c2;
+ s2[1] = '\0';
+ struct _xlocale l = {{0}};
+ l.components[XLC_COLLATE] = (struct xlocale_component *)table;
+ return (strcoll_l(s1, s2, &l));
+}
+
+int __wcollate_range_cmp(struct xlocale_collate *table, wchar_t c1, wchar_t c2)
{
wchar_t s1[2], s2[2];
s1[0] = c1;
- s1[1] = 0;
+ s1[1] = L'\0';
s2[0] = c2;
- s2[1] = 0;
+ s2[1] = L'\0';
struct _xlocale l = {{0}};
l.components[XLC_COLLATE] = (struct xlocale_component *)table;
return (wcscoll_l(s1, s2, &l));
OpenPOWER on IntegriCloud