Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Approved by: TBD

*** 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. * * Redistribution and use in source and binary forms, with or without
*** 32,72 **** */ #include "lint.h" #include <sys/types.h> #include <errno.h> - #include "runetype.h" #include <stdlib.h> #include <string.h> #include <wchar.h> #include "mblocal.h" static size_t _GB18030_mbrtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t, mbstate_t *_RESTRICT_KYWD); static int _GB18030_mbsinit(const mbstate_t *); static size_t _GB18030_wcrtomb(char *_RESTRICT_KYWD, wchar_t, mbstate_t *_RESTRICT_KYWD); typedef struct { int count; uchar_t bytes[4]; } _GB18030State; ! int ! _GB18030_init(_RuneLocale *rl) { ! __mbrtowc = _GB18030_mbrtowc; ! __wcrtomb = _GB18030_wcrtomb; ! __mbsinit = _GB18030_mbsinit; ! _CurrentRuneLocale = rl; ! __ctype[520] = 4; ! charset_is_ascii = 0; ! ! return (0); } static int _GB18030_mbsinit(const mbstate_t *ps) { --- 33,79 ---- */ #include "lint.h" #include <sys/types.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <wchar.h> #include "mblocal.h" + #include "lctype.h" static size_t _GB18030_mbrtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t, mbstate_t *_RESTRICT_KYWD); static int _GB18030_mbsinit(const mbstate_t *); static size_t _GB18030_wcrtomb(char *_RESTRICT_KYWD, wchar_t, mbstate_t *_RESTRICT_KYWD); + static size_t _GB18030_mbsnrtowcs(wchar_t *_RESTRICT_KYWD, + const char **_RESTRICT_KYWD, size_t, size_t, + mbstate_t *_RESTRICT_KYWD); + static size_t _GB18030_wcsnrtombs(char *_RESTRICT_KYWD, + const wchar_t **_RESTRICT_KYWD, size_t, size_t, + mbstate_t *_RESTRICT_KYWD); + typedef struct { int count; uchar_t bytes[4]; } _GB18030State; ! void ! _GB18030_init(struct lc_ctype *lct) { ! lct->lc_mbrtowc = _GB18030_mbrtowc; ! lct->lc_wcrtomb = _GB18030_wcrtomb; ! lct->lc_mbsinit = _GB18030_mbsinit; ! lct->lc_mbsnrtowcs = _GB18030_mbsnrtowcs; ! lct->lc_wcsnrtombs = _GB18030_wcsnrtombs; ! lct->lc_max_mblen = 4; ! lct->lc_is_ascii = 0; } static int _GB18030_mbsinit(const mbstate_t *ps) {
*** 218,223 **** --- 225,246 ---- return (len); ilseq: errno = EILSEQ; return ((size_t)-1); + } + + static size_t + _GB18030_mbsnrtowcs(wchar_t *_RESTRICT_KYWD dst, + const char **_RESTRICT_KYWD src, size_t nms, size_t len, + mbstate_t *_RESTRICT_KYWD ps) + { + return (__mbsnrtowcs_std(dst, src, nms, len, ps, _GB18030_mbrtowc)); + } + + static size_t + _GB18030_wcsnrtombs(char *_RESTRICT_KYWD dst, + const wchar_t **_RESTRICT_KYWD src, size_t nwc, size_t len, + mbstate_t *_RESTRICT_KYWD ps) + { + return (__wcsnrtombs_std(dst, src, nwc, len, ps, _GB18030_wcrtomb)); }