summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/btowc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/locale/btowc.c')
-rw-r--r--lib/libc/locale/btowc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libc/locale/btowc.c b/lib/libc/locale/btowc.c
index 2c4d493..72507bc 100644
--- a/lib/libc/locale/btowc.c
+++ b/lib/libc/locale/btowc.c
@@ -2,6 +2,11 @@
* Copyright (c) 2002, 2003 Tim J. Robbins.
* 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:
@@ -32,12 +37,13 @@ __FBSDID("$FreeBSD$");
#include "mblocal.h"
wint_t
-btowc(int c)
+btowc_l(int c, locale_t l)
{
static const mbstate_t initial;
mbstate_t mbs = initial;
char cc;
wchar_t wc;
+ FIX_LOCALE(l);
if (c == EOF)
return (WEOF);
@@ -47,7 +53,12 @@ btowc(int c)
* counts.
*/
cc = (char)c;
- if (__mbrtowc(&wc, &cc, 1, &mbs) > 1)
+ if (XLOCALE_CTYPE(l)->__mbrtowc(&wc, &cc, 1, &mbs) > 1)
return (WEOF);
return (wc);
}
+wint_t
+btowc(int c)
+{
+ return btowc_l(c, __get_locale());
+}
OpenPOWER on IntegriCloud