Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add wcscoll_l, wcsxfrm_l, wcsncasecmp_l, wcscasecmp_l, btowc_l,
details: https://anonhg.NetBSD.org/src/rev/8c652f7669a3
branches: trunk
changeset: 786183:8c652f7669a3
user: joerg <joerg%NetBSD.org@localhost>
date: Thu Apr 18 23:24:26 2013 +0000
description:
Add wcscoll_l, wcsxfrm_l, wcsncasecmp_l, wcscasecmp_l, btowc_l,
mbrlen_l, mbsinit_l, mbsrtowcs_l, wcrtomb_l, wcsrtombs_l and wctob_l.
diffstat:
include/wchar.h | 24 ++++++-
lib/libc/include/namespace.h | 4 +-
lib/libc/locale/multibyte_amd1.c | 132 ++++++++++++++++++++++++++++++--------
lib/libc/locale/wcscoll.c | 19 ++++-
lib/libc/locale/wcsxfrm.c | 17 ++++-
lib/libc/string/wcscasecmp.c | 22 +++++-
lib/libc/string/wcsncasecmp.c | 22 +++++-
7 files changed, 191 insertions(+), 49 deletions(-)
diffs (truncated from 513 to 300 lines):
diff -r 15a9a32c45db -r 8c652f7669a3 include/wchar.h
--- a/include/wchar.h Thu Apr 18 22:23:17 2013 +0000
+++ b/include/wchar.h Thu Apr 18 23:24:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wchar.h,v 1.33 2013/04/18 22:23:17 joerg Exp $ */
+/* $NetBSD: wchar.h,v 1.34 2013/04/18 23:24:26 joerg Exp $ */
/*-
* Copyright (c)1999 Citrus Project,
@@ -211,6 +211,11 @@
typedef struct _locale *locale_t;
# define __LOCALE_T_DECLARED
# endif
+int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
+size_t wcsxfrm_l(wchar_t *, const wchar_t *, size_t, locale_t);
+int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
+int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
+
float wcstof_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t);
double wcstod_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t);
long double wcstold_l(const wchar_t * __restrict, wchar_t ** __restrict,
@@ -227,6 +232,21 @@
wchar_t ** __restrict, int, locale_t);
int wcwidth_l(wchar_t, locale_t);
int wcswidth_l(const wchar_t *, size_t, locale_t);
-#endif
+#endif /* _POSIX_C_SOURCE || _NETBSD_SOURCE */
+
+#if defined(_NETBSD_SOURCE)
+wint_t btowc_l(int, locale_t);
+size_t mbrlen_l(const char * __restrict, size_t, mbstate_t * __restrict,
+ locale_t);
+size_t mbrtowc_l(wchar_t * __restrict, const char * __restrict, size_t,
+ mbstate_t * __restrict, locale_t);
+int mbsinit_l(const mbstate_t *, locale_t);
+size_t mbsrtowcs_l(wchar_t * __restrict, const char ** __restrict, size_t,
+ mbstate_t * __restrict, locale_t);
+size_t wcrtomb_l(char * __restrict, wchar_t, mbstate_t * __restrict, locale_t);
+size_t wcsrtombs_l(char * __restrict, const wchar_t ** __restrict, size_t,
+ mbstate_t * __restrict, locale_t);
+int wctob_l(wint_t, locale_t);
+#endif /* _NETBSD_SOURCE */
#endif /* !_WCHAR_H_ */
diff -r 15a9a32c45db -r 8c652f7669a3 lib/libc/include/namespace.h
--- a/lib/libc/include/namespace.h Thu Apr 18 22:23:17 2013 +0000
+++ b/lib/libc/include/namespace.h Thu Apr 18 23:24:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.160 2013/04/18 22:23:17 joerg Exp $ */
+/* $NetBSD: namespace.h,v 1.161 2013/04/18 23:24:26 joerg Exp $ */
/*-
* Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@@ -704,8 +704,10 @@
#define wait4 _wait4
#define waitpid _waitpid
#define wcscasecmp _wcscasecmp
+#define wcscasecmp_l _wcscasecmp_l
#define wcsdup _wcsdup
#define wcsncasecmp _wcsncasecmp
+#define wcsncasecmp_l _wcsncasecmp_l
#define wcstof _wcstof
#define wcstof_l _wcstof_l
#define wcstod _wcstod
diff -r 15a9a32c45db -r 8c652f7669a3 lib/libc/locale/multibyte_amd1.c
--- a/lib/libc/locale/multibyte_amd1.c Thu Apr 18 22:23:17 2013 +0000
+++ b/lib/libc/locale/multibyte_amd1.c Thu Apr 18 23:24:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: multibyte_amd1.c,v 1.9 2010/06/13 04:14:57 tnozaki Exp $ */
+/* $NetBSD: multibyte_amd1.c,v 1.10 2013/04/18 23:24:27 joerg Exp $ */
/*-
* Copyright (c)2002, 2008 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: multibyte_amd1.c,v 1.9 2010/06/13 04:14:57 tnozaki Exp $");
+__RCSID("$NetBSD: multibyte_amd1.c,v 1.10 2013/04/18 23:24:27 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -46,19 +46,22 @@
#include "runetype_local.h"
#include "multibyte.h"
-#define _RUNE_LOCALE() \
- ((_RuneLocale *)(*_current_locale())->part_impl[(size_t)LC_CTYPE])
+#define _RUNE_LOCALE(loc) \
+ ((_RuneLocale *)((loc)->part_impl[(size_t)LC_CTYPE]))
-#define _CITRUS_CTYPE() \
- (_RUNE_LOCALE()->rl_citrus_ctype)
+#define _CITRUS_CTYPE(loc) \
+ (_RUNE_LOCALE(loc)->rl_citrus_ctype)
size_t
-mbrlen(const char *s, size_t n, mbstate_t *ps)
+mbrlen_l(const char *s, size_t n, mbstate_t *ps, locale_t loc)
{
size_t ret;
int err0;
- _fixup_ps(_RUNE_LOCALE(), ps, s == NULL);
+ if (loc == NULL)
+ loc = _C_locale;
+
+ _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_mbrlen(_ps_to_ctype(ps), s, n,
_ps_to_private(ps), &ret);
@@ -68,8 +71,14 @@
return ret;
}
+size_t
+mbrlen(const char *s, size_t n, mbstate_t *ps)
+{
+ return mbrlen_l(s, n, ps, *_current_locale());
+}
+
int
-mbsinit(const mbstate_t *ps)
+mbsinit_l(const mbstate_t *ps, locale_t loc)
{
int ret;
int err0;
@@ -78,8 +87,11 @@
if (ps == NULL)
return 1;
+ if (loc == NULL)
+ loc = _C_locale;
+
if (_ps_to_runelocale(ps) == NULL)
- rl = _RUNE_LOCALE();
+ rl = _RUNE_LOCALE(loc);
else
rl = _ps_to_runelocale(ps);
@@ -92,13 +104,22 @@
return ret;
}
+int
+mbsinit(const mbstate_t *ps)
+{
+ return mbsinit_l(ps, *_current_locale());
+}
+
size_t
-mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+mbrtowc_l(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps, locale_t loc)
{
size_t ret;
int err0;
- _fixup_ps(_RUNE_LOCALE(), ps, s == NULL);
+ if (loc == NULL)
+ loc = _C_locale;
+
+ _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_mbrtowc(_ps_to_ctype(ps), pwc, s, n,
_ps_to_private(ps), &ret);
@@ -109,12 +130,22 @@
}
size_t
-mbsrtowcs(wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps)
+mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+ return mbrtowc_l(pwc, s, n, ps, *_current_locale());
+}
+
+size_t
+mbsrtowcs_l(wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps,
+ locale_t loc)
{
size_t ret;
int err0;
- _fixup_ps(_RUNE_LOCALE(), ps, s == NULL);
+ if (loc == NULL)
+ loc = _C_locale;
+
+ _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_mbsrtowcs(_ps_to_ctype(ps), pwcs, s, n,
_ps_to_private(ps), &ret);
@@ -125,12 +156,21 @@
}
size_t
-wcrtomb(char *s, wchar_t wc, mbstate_t *ps)
+mbsrtowcs(wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps)
+{
+ return mbsrtowcs_l(pwcs, s, n, ps, *_current_locale());
+}
+
+size_t
+wcrtomb_l(char *s, wchar_t wc, mbstate_t *ps, locale_t loc)
{
size_t ret;
int err0;
- _fixup_ps(_RUNE_LOCALE(), ps, s == NULL);
+ if (loc == NULL)
+ loc = _C_locale;
+
+ _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_wcrtomb(_ps_to_ctype(ps), s, wc,
_ps_to_private(ps), &ret);
@@ -141,12 +181,22 @@
}
size_t
-wcsrtombs(char *s, const wchar_t **ppwcs, size_t n, mbstate_t *ps)
+wcrtomb(char *s, wchar_t wc, mbstate_t *ps)
+{
+ return wcrtomb_l(s, wc, ps, *_current_locale());
+}
+
+size_t
+wcsrtombs_l(char *s, const wchar_t **ppwcs, size_t n, mbstate_t *ps,
+ locale_t loc)
{
size_t ret;
int err0;
- _fixup_ps(_RUNE_LOCALE(), ps, s == NULL);
+ if (loc == NULL)
+ loc = _C_locale;
+
+ _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_wcsrtombs(_ps_to_ctype(ps), s, ppwcs, n,
_ps_to_private(ps), &ret);
@@ -156,13 +206,44 @@
return ret;
}
+size_t
+wcsrtombs(char *s, const wchar_t **ppwcs, size_t n, mbstate_t *ps)
+{
+ return wcsrtombs_l(s, ppwcs, n, ps, *_current_locale());
+}
+
+wint_t
+btowc_l(int c, locale_t loc)
+{
+ wint_t ret;
+ int err0;
+
+ if (loc == NULL)
+ loc = _C_locale;
+
+ err0 = _citrus_ctype_btowc(_CITRUS_CTYPE(loc), c, &ret);
+ if (err0)
+ errno = err0;
+
+ return ret;
+}
+
wint_t
btowc(int c)
{
- wint_t ret;
+ return btowc_l(c, *_current_locale());
+}
+
+int
+wctob_l(wint_t wc, locale_t loc)
+{
+ int ret;
int err0;
- err0 = _citrus_ctype_btowc(_CITRUS_CTYPE(), c, &ret);
+ if (loc == NULL)
+ loc = _C_locale;
+
+ err0 = _citrus_ctype_wctob(_CITRUS_CTYPE(loc), wc, &ret);
if (err0)
errno = err0;
@@ -172,12 +253,5 @@
int
wctob(wint_t wc)
{
- int ret;
- int err0;
-
- err0 = _citrus_ctype_wctob(_CITRUS_CTYPE(), wc, &ret);
- if (err0)
- errno = err0;
-
- return ret;
-}
+ return wctob_l(wc, *_current_locale());
Home |
Main Index |
Thread Index |
Old Index