Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>

*** 1,6 **** --- 1,7 ---- /* + * Copyright 2013 Garrett D'Amore <garrett@damore.org> * Copyright 2010 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved. * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. *
*** 39,82 **** #include <stdio.h> #include <stdlib.h> #include <string.h> #include <wchar.h> #include <note.h> - #include "runetype.h" #include "mblocal.h" - static size_t _none_mbrtowc(wchar_t *_RESTRICT_KYWD, - const char *_RESTRICT_KYWD, size_t, mbstate_t *_RESTRICT_KYWD); - - static int _none_mbsinit(const mbstate_t *); - static size_t _none_mbsnrtowcs(wchar_t *_RESTRICT_KYWD dst, - const char **_RESTRICT_KYWD src, size_t nms, size_t len, - mbstate_t *_RESTRICT_KYWD); - static size_t _none_wcrtomb(char *_RESTRICT_KYWD, wchar_t, - mbstate_t *_RESTRICT_KYWD); - static size_t _none_wcsnrtombs(char *_RESTRICT_KYWD, - const wchar_t **_RESTRICT_KYWD, - size_t, size_t, mbstate_t *_RESTRICT_KYWD); - /* setup defaults */ ! int ! _none_init(_RuneLocale *rl) { ! charset_is_ascii = 1; ! ! __mbrtowc = _none_mbrtowc; ! __mbsinit = _none_mbsinit; ! __mbsnrtowcs = _none_mbsnrtowcs; ! __wcrtomb = _none_wcrtomb; ! __wcsnrtombs = _none_wcsnrtombs; ! _CurrentRuneLocale = rl; ! return (0); } ! static int ! _none_mbsinit(const mbstate_t *unused) { _NOTE(ARGUNUSED(unused)); /* * Encoding is not state dependent - we are always in the --- 40,68 ---- #include <stdio.h> #include <stdlib.h> #include <string.h> #include <wchar.h> #include <note.h> #include "mblocal.h" + #include "lctype.h" /* setup defaults */ ! void ! _none_init(struct lc_ctype *lct) { ! lct->lc_is_ascii = 1; ! lct->lc_mbrtowc = __mbrtowc_ascii; ! lct->lc_mbsinit = __mbsinit_ascii; ! lct->lc_mbsnrtowcs = __mbsnrtowcs_ascii; ! lct->lc_wcrtomb = __wcrtomb_ascii; ! lct->lc_wcsnrtombs = __wcsnrtombs_ascii; ! lct->lc_max_mblen = 1; } ! int ! __mbsinit_ascii(const mbstate_t *unused) { _NOTE(ARGUNUSED(unused)); /* * Encoding is not state dependent - we are always in the
*** 83,94 **** * initial state. */ return (1); } ! static size_t ! _none_mbrtowc(wchar_t *_RESTRICT_KYWD pwc, const char *_RESTRICT_KYWD s, size_t n, mbstate_t *_RESTRICT_KYWD unused) { _NOTE(ARGUNUSED(unused)); if (s == NULL) --- 69,80 ---- * initial state. */ return (1); } ! size_t ! __mbrtowc_ascii(wchar_t *_RESTRICT_KYWD pwc, const char *_RESTRICT_KYWD s, size_t n, mbstate_t *_RESTRICT_KYWD unused) { _NOTE(ARGUNUSED(unused)); if (s == NULL)
*** 100,111 **** if (pwc != NULL) *pwc = (unsigned char)*s; return (*s == '\0' ? 0 : 1); } ! static size_t ! _none_wcrtomb(char *_RESTRICT_KYWD s, wchar_t wc, mbstate_t *_RESTRICT_KYWD unused) { _NOTE(ARGUNUSED(unused)); if (s == NULL) --- 86,97 ---- if (pwc != NULL) *pwc = (unsigned char)*s; return (*s == '\0' ? 0 : 1); } ! size_t ! __wcrtomb_ascii(char *_RESTRICT_KYWD s, wchar_t wc, mbstate_t *_RESTRICT_KYWD unused) { _NOTE(ARGUNUSED(unused)); if (s == NULL)
*** 117,128 **** } *s = (unsigned char)wc; return (1); } ! static size_t ! _none_mbsnrtowcs(wchar_t *_RESTRICT_KYWD dst, const char **_RESTRICT_KYWD src, size_t nms, size_t len, mbstate_t *_RESTRICT_KYWD unused) { const char *s; size_t nchr; --- 103,114 ---- } *s = (unsigned char)wc; return (1); } ! size_t ! __mbsnrtowcs_ascii(wchar_t *_RESTRICT_KYWD dst, const char **_RESTRICT_KYWD src, size_t nms, size_t len, mbstate_t *_RESTRICT_KYWD unused) { const char *s; size_t nchr;
*** 144,155 **** } *src = s; return (nchr); } ! static size_t ! _none_wcsnrtombs(char *_RESTRICT_KYWD dst, const wchar_t **_RESTRICT_KYWD src, size_t nwc, size_t len, mbstate_t *_RESTRICT_KYWD unused) { const wchar_t *s; size_t nchr; --- 130,141 ---- } *src = s; return (nchr); } ! size_t ! __wcsnrtombs_ascii(char *_RESTRICT_KYWD dst, const wchar_t **_RESTRICT_KYWD src, size_t nwc, size_t len, mbstate_t *_RESTRICT_KYWD unused) { const wchar_t *s; size_t nchr;
*** 179,199 **** nchr++; } *src = s; return (nchr); } - - /* setup defaults */ - - size_t (*__mbrtowc)(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, - size_t, mbstate_t *_RESTRICT_KYWD) = _none_mbrtowc; - - int (*__mbsinit)(const mbstate_t *) = _none_mbsinit; - - size_t (*__mbsnrtowcs)(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD, - size_t, size_t, mbstate_t *_RESTRICT_KYWD) = _none_mbsnrtowcs; - - size_t (*__wcrtomb)(char *_RESTRICT_KYWD, wchar_t, mbstate_t *_RESTRICT_KYWD) = - _none_wcrtomb; - - size_t (*__wcsnrtombs)(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD, - size_t, size_t, mbstate_t *_RESTRICT_KYWD) = _none_wcsnrtombs; --- 165,169 ----