Print this page
2964 need POSIX 2008 locale object support
   1 /*
   2  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
   3  * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
   4  * Copyright (c) 1993
   5  *      The Regents of the University of California.  All rights reserved.
   6  *
   7  * This code is derived from software contributed to Berkeley by
   8  * Paul Borman at Krystal Technologies.
   9  *





  10  * Redistribution and use in source and binary forms, with or without
  11  * modification, are permitted provided that the following conditions
  12  * are met:
  13  * 1. Redistributions of source code must retain the above copyright
  14  *    notice, this list of conditions and the following disclaimer.
  15  * 2. Redistributions in binary form must reproduce the above copyright
  16  *    notice, this list of conditions and the following disclaimer in the
  17  *    documentation and/or other materials provided with the distribution.
  18  * 4. Neither the name of the University nor the names of its contributors
  19  *    may be used to endorse or promote products derived from this software
  20  *    without specific prior written permission.
  21  *
  22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT


  43 #include <note.h>
  44 #include "runetype.h"
  45 #include "mblocal.h"
  46 
  47 static size_t   _none_mbrtowc(wchar_t *_RESTRICT_KYWD,
  48     const char *_RESTRICT_KYWD, size_t, mbstate_t *_RESTRICT_KYWD);
  49 
  50 static int      _none_mbsinit(const mbstate_t *);
  51 static size_t   _none_mbsnrtowcs(wchar_t *_RESTRICT_KYWD dst,
  52     const char **_RESTRICT_KYWD src, size_t nms, size_t len,
  53     mbstate_t *_RESTRICT_KYWD);
  54 static size_t   _none_wcrtomb(char *_RESTRICT_KYWD, wchar_t,
  55     mbstate_t *_RESTRICT_KYWD);
  56 static size_t   _none_wcsnrtombs(char *_RESTRICT_KYWD,
  57     const wchar_t **_RESTRICT_KYWD,
  58     size_t, size_t, mbstate_t *_RESTRICT_KYWD);
  59 
  60 /* setup defaults */
  61 
  62 int
  63 _none_init(_RuneLocale *rl)
  64 {
  65         charset_is_ascii = 1;
  66 
  67         __mbrtowc = _none_mbrtowc;
  68         __mbsinit = _none_mbsinit;
  69         __mbsnrtowcs = _none_mbsnrtowcs;
  70         __wcrtomb = _none_wcrtomb;
  71         __wcsnrtombs = _none_wcsnrtombs;
  72         _CurrentRuneLocale = rl;

  73         return (0);
  74 }
  75 
  76 static int
  77 _none_mbsinit(const mbstate_t *unused)
  78 {
  79         _NOTE(ARGUNUSED(unused));
  80 
  81         /*
  82          * Encoding is not state dependent - we are always in the
  83          * initial state.
  84          */
  85         return (1);
  86 }
  87 
  88 static size_t
  89 _none_mbrtowc(wchar_t *_RESTRICT_KYWD pwc, const char *_RESTRICT_KYWD s,
  90     size_t n, mbstate_t *_RESTRICT_KYWD unused)
  91 {
  92         _NOTE(ARGUNUSED(unused));


 180         }
 181         *src = s;
 182         return (nchr);
 183 }
 184 
 185 /* setup defaults */
 186 
 187 size_t (*__mbrtowc)(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
 188     size_t, mbstate_t *_RESTRICT_KYWD) = _none_mbrtowc;
 189 
 190 int (*__mbsinit)(const mbstate_t *) = _none_mbsinit;
 191 
 192 size_t (*__mbsnrtowcs)(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
 193     size_t, size_t, mbstate_t *_RESTRICT_KYWD) = _none_mbsnrtowcs;
 194 
 195 size_t (*__wcrtomb)(char *_RESTRICT_KYWD, wchar_t, mbstate_t *_RESTRICT_KYWD) =
 196     _none_wcrtomb;
 197 
 198 size_t (*__wcsnrtombs)(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
 199     size_t, size_t, mbstate_t *_RESTRICT_KYWD) = _none_wcsnrtombs;
























   1 /*
   2  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
   3  * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
   4  * Copyright (c) 1993
   5  *      The Regents of the University of California.  All rights reserved.
   6  *
   7  * This code is derived from software contributed to Berkeley by
   8  * Paul Borman at Krystal Technologies.
   9  *
  10  * Copyright (c) 2011 The FreeBSD Foundation
  11  * All rights reserved.
  12  * Portions of this software were developed by David Chisnall
  13  * under sponsorship from the FreeBSD Foundation.
  14  *
  15  * Redistribution and use in source and binary forms, with or without
  16  * modification, are permitted provided that the following conditions
  17  * are met:
  18  * 1. Redistributions of source code must retain the above copyright
  19  *    notice, this list of conditions and the following disclaimer.
  20  * 2. Redistributions in binary form must reproduce the above copyright
  21  *    notice, this list of conditions and the following disclaimer in the
  22  *    documentation and/or other materials provided with the distribution.
  23  * 4. Neither the name of the University nor the names of its contributors
  24  *    may be used to endorse or promote products derived from this software
  25  *    without specific prior written permission.
  26  *
  27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT


  48 #include <note.h>
  49 #include "runetype.h"
  50 #include "mblocal.h"
  51 
  52 static size_t   _none_mbrtowc(wchar_t *_RESTRICT_KYWD,
  53     const char *_RESTRICT_KYWD, size_t, mbstate_t *_RESTRICT_KYWD);
  54 
  55 static int      _none_mbsinit(const mbstate_t *);
  56 static size_t   _none_mbsnrtowcs(wchar_t *_RESTRICT_KYWD dst,
  57     const char **_RESTRICT_KYWD src, size_t nms, size_t len,
  58     mbstate_t *_RESTRICT_KYWD);
  59 static size_t   _none_wcrtomb(char *_RESTRICT_KYWD, wchar_t,
  60     mbstate_t *_RESTRICT_KYWD);
  61 static size_t   _none_wcsnrtombs(char *_RESTRICT_KYWD,
  62     const wchar_t **_RESTRICT_KYWD,
  63     size_t, size_t, mbstate_t *_RESTRICT_KYWD);
  64 
  65 /* setup defaults */
  66 
  67 int
  68 _none_init(struct xlocale_ctype *l, _RuneLocale *rl)
  69 {
  70         charset_is_ascii = 1;   /* XXX */
  71 
  72         l->__mbrtowc = _none_mbrtowc;
  73         l->__mbsinit = _none_mbsinit;
  74         l->__mbsnrtowcs = _none_mbsnrtowcs;
  75         l->__wcrtomb = _none_wcrtomb;
  76         l->__wcsnrtombs = _none_wcsnrtombs;
  77         l->runes = rl;
  78         /* XXX */
  79         return (0);
  80 }
  81 
  82 static int
  83 _none_mbsinit(const mbstate_t *unused)
  84 {
  85         _NOTE(ARGUNUSED(unused));
  86 
  87         /*
  88          * Encoding is not state dependent - we are always in the
  89          * initial state.
  90          */
  91         return (1);
  92 }
  93 
  94 static size_t
  95 _none_mbrtowc(wchar_t *_RESTRICT_KYWD pwc, const char *_RESTRICT_KYWD s,
  96     size_t n, mbstate_t *_RESTRICT_KYWD unused)
  97 {
  98         _NOTE(ARGUNUSED(unused));


 186         }
 187         *src = s;
 188         return (nchr);
 189 }
 190 
 191 /* setup defaults */
 192 
 193 size_t (*__mbrtowc)(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
 194     size_t, mbstate_t *_RESTRICT_KYWD) = _none_mbrtowc;
 195 
 196 int (*__mbsinit)(const mbstate_t *) = _none_mbsinit;
 197 
 198 size_t (*__mbsnrtowcs)(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
 199     size_t, size_t, mbstate_t *_RESTRICT_KYWD) = _none_mbsnrtowcs;
 200 
 201 size_t (*__wcrtomb)(char *_RESTRICT_KYWD, wchar_t, mbstate_t *_RESTRICT_KYWD) =
 202     _none_wcrtomb;
 203 
 204 size_t (*__wcsnrtombs)(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
 205     size_t, size_t, mbstate_t *_RESTRICT_KYWD) = _none_wcsnrtombs;
 206 
 207 struct xlocale_ctype __xlocale_global_ctype = {
 208         {{0}, "C"},
 209         (_RuneLocale*)&_DefaultRuneLocale,
 210         _none_mbrtowc,
 211         _none_mbsinit,
 212         _none_mbsnrtowcs,
 213         _none_wcrtomb,
 214         _none_wcsnrtombs,
 215         1,      /* __mb_cur_max */
 216         256     /* __mb_sb_limit */
 217 };
 218 
 219 const struct xlocale_ctype __xlocale_C_ctype = {
 220         {{0}, "C"},
 221         (_RuneLocale*)&_DefaultRuneLocale,
 222         _none_mbrtowc,
 223         _none_mbsinit,
 224         _none_mbsnrtowcs,
 225         _none_wcrtomb,
 226         _none_wcsnrtombs,
 227         1,      /* __mb_cur_max */
 228         256     /* __mb_sb_limit */
 229 };