Home | History | Annotate | Download | only in lib
      1 /* -*- buffer-read-only: t -*- vi: set ro: */
      2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
      3 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
      4 
      5    Copyright (C) 2007-2009 Free Software Foundation, Inc.
      6 
      7    This program is free software; you can redistribute it and/or modify
      8    it under the terms of the GNU General Public License as published by
      9    the Free Software Foundation; either version 3, or (at your option)
     10    any later version.
     11 
     12    This program is distributed in the hope that it will be useful,
     13    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15    GNU General Public License for more details.
     16 
     17    You should have received a copy of the GNU General Public License
     18    along with this program; if not, write to the Free Software Foundation,
     19    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
     20 
     21 /* Written by Eric Blake.  */
     22 
     23 /*
     24  * ISO C 99 <wchar.h> for platforms that have issues.
     25  * <http://www.opengroup.org/susv3xbd/wchar.h.html>
     26  *
     27  * For now, this just ensures proper prerequisite inclusion order and
     28  * the declaration of wcwidth().
     29  */
     30 
     31 #if __GNUC__ >= 3
     32 @PRAGMA_SYSTEM_HEADER@
     33 #endif
     34 
     35 #if defined __need_mbstate_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
     36 /* Special invocation convention:
     37    - Inside uClibc header files.
     38    - On HP-UX 11.00 we have a sequence of nested includes
     39      <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
     40      once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
     41      and once directly.  In both situations 'wint_t' is not yet defined,
     42      therefore we cannot provide the function overrides; instead include only
     43      the system's <wchar.h>.
     44    - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
     45      the latter includes <wchar.h>.  But here, we have no way to detect whether
     46      <wctype.h> is completely included or is still being included.  */
     47 
     48 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
     49 
     50 #else
     51 /* Normal invocation convention.  */
     52 
     53 #ifndef _GL_WCHAR_H
     54 
     55 #define _GL_ALREADY_INCLUDING_WCHAR_H
     56 
     57 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
     58    <wchar.h>.
     59    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
     60    included before <wchar.h>.  */
     61 #include <stddef.h>
     62 #include <stdio.h>
     63 #include <time.h>
     64 
     65 /* Include the original <wchar.h> if it exists.
     66    Some builds of uClibc lack it.  */
     67 /* The include_next requires a split double-inclusion guard.  */
     68 #if @HAVE_WCHAR_H@
     69 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
     70 #endif
     71 
     72 #undef _GL_ALREADY_INCLUDING_WCHAR_H
     73 
     74 #ifndef _GL_WCHAR_H
     75 #define _GL_WCHAR_H
     76 
     77 /* The definition of GL_LINK_WARNING is copied here.  */
     78 
     79 #ifdef __cplusplus
     80 extern "C" {
     81 #endif
     82 
     83 
     84 /* Define wint_t.  (Also done in wctype.in.h.)  */
     85 #if !@HAVE_WINT_T@ && !defined wint_t
     86 # define wint_t int
     87 # ifndef WEOF
     88 #  define WEOF -1
     89 # endif
     90 #endif
     91 
     92 
     93 /* Override mbstate_t if it is too small.
     94    On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
     95    implementing mbrtowc for encodings like UTF-8.  */
     96 #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
     97 typedef int rpl_mbstate_t;
     98 # undef mbstate_t
     99 # define mbstate_t rpl_mbstate_t
    100 # define GNULIB_defined_mbstate_t 1
    101 #endif
    102 
    103 
    104 /* Convert a single-byte character to a wide character.  */
    105 #if @GNULIB_BTOWC@
    106 # if @REPLACE_BTOWC@
    107 #  undef btowc
    108 #  define btowc rpl_btowc
    109 # endif
    110 # if !@HAVE_BTOWC@ || @REPLACE_BTOWC@
    111 extern wint_t btowc (int c);
    112 # endif
    113 #elif defined GNULIB_POSIXCHECK
    114 # undef btowc
    115 # define btowc(c) \
    116     (GL_LINK_WARNING ("btowc is unportable - " \
    117                       "use gnulib module btowc for portability"), \
    118      btowc (c))
    119 #endif
    120 
    121 
    122 /* Convert a wide character to a single-byte character.  */
    123 #if @GNULIB_WCTOB@
    124 # if @REPLACE_WCTOB@
    125 #  undef wctob
    126 #  define wctob rpl_wctob
    127 # endif
    128 # if (!defined wctob && !@HAVE_DECL_WCTOB@) || @REPLACE_WCTOB@
    129 /* wctob is provided by gnulib, or wctob exists but is not declared.  */
    130 extern int wctob (wint_t wc);
    131 # endif
    132 #elif defined GNULIB_POSIXCHECK
    133 # undef wctob
    134 # define wctob(w) \
    135     (GL_LINK_WARNING ("wctob is unportable - " \
    136                       "use gnulib module wctob for portability"), \
    137      wctob (w))
    138 #endif
    139 
    140 
    141 /* Test whether *PS is in the initial state.  */
    142 #if @GNULIB_MBSINIT@
    143 # if @REPLACE_MBSINIT@
    144 #  undef mbsinit
    145 #  define mbsinit rpl_mbsinit
    146 # endif
    147 # if !@HAVE_MBSINIT@ || @REPLACE_MBSINIT@
    148 extern int mbsinit (const mbstate_t *ps);
    149 # endif
    150 #elif defined GNULIB_POSIXCHECK
    151 # undef mbsinit
    152 # define mbsinit(p) \
    153     (GL_LINK_WARNING ("mbsinit is unportable - " \
    154                       "use gnulib module mbsinit for portability"), \
    155      mbsinit (p))
    156 #endif
    157 
    158 
    159 /* Convert a multibyte character to a wide character.  */
    160 #if @GNULIB_MBRTOWC@
    161 # if @REPLACE_MBRTOWC@
    162 #  undef mbrtowc
    163 #  define mbrtowc rpl_mbrtowc
    164 # endif
    165 # if !@HAVE_MBRTOWC@ || @REPLACE_MBRTOWC@
    166 extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
    167 # endif
    168 #elif defined GNULIB_POSIXCHECK
    169 # undef mbrtowc
    170 # define mbrtowc(w,s,n,p) \
    171     (GL_LINK_WARNING ("mbrtowc is unportable - " \
    172                       "use gnulib module mbrtowc for portability"), \
    173      mbrtowc (w, s, n, p))
    174 #endif
    175 
    176 
    177 /* Recognize a multibyte character.  */
    178 #if @GNULIB_MBRLEN@
    179 # if @REPLACE_MBRLEN@
    180 #  undef mbrlen
    181 #  define mbrlen rpl_mbrlen
    182 # endif
    183 # if !@HAVE_MBRLEN@ || @REPLACE_MBRLEN@
    184 extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
    185 # endif
    186 #elif defined GNULIB_POSIXCHECK
    187 # undef mbrlen
    188 # define mbrlen(s,n,p) \
    189     (GL_LINK_WARNING ("mbrlen is unportable - " \
    190                       "use gnulib module mbrlen for portability"), \
    191      mbrlen (s, n, p))
    192 #endif
    193 
    194 
    195 /* Convert a string to a wide string.  */
    196 #if @GNULIB_MBSRTOWCS@
    197 # if @REPLACE_MBSRTOWCS@
    198 #  undef mbsrtowcs
    199 #  define mbsrtowcs rpl_mbsrtowcs
    200 # endif
    201 # if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@
    202 extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps);
    203 # endif
    204 #elif defined GNULIB_POSIXCHECK
    205 # undef mbsrtowcs
    206 # define mbsrtowcs(d,s,l,p) \
    207     (GL_LINK_WARNING ("mbsrtowcs is unportable - " \
    208                       "use gnulib module mbsrtowcs for portability"), \
    209      mbsrtowcs (d, s, l, p))
    210 #endif
    211 
    212 
    213 /* Convert a string to a wide string.  */
    214 #if @GNULIB_MBSNRTOWCS@
    215 # if @REPLACE_MBSNRTOWCS@
    216 #  undef mbsnrtowcs
    217 #  define mbsnrtowcs rpl_mbsnrtowcs
    218 # endif
    219 # if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@
    220 extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps);
    221 # endif
    222 #elif defined GNULIB_POSIXCHECK
    223 # undef mbsnrtowcs
    224 # define mbsnrtowcs(d,s,n,l,p) \
    225     (GL_LINK_WARNING ("mbsnrtowcs is unportable - " \
    226                       "use gnulib module mbsnrtowcs for portability"), \
    227      mbsnrtowcs (d, s, n, l, p))
    228 #endif
    229 
    230 
    231 /* Convert a wide character to a multibyte character.  */
    232 #if @GNULIB_WCRTOMB@
    233 # if @REPLACE_WCRTOMB@
    234 #  undef wcrtomb
    235 #  define wcrtomb rpl_wcrtomb
    236 # endif
    237 # if !@HAVE_WCRTOMB@ || @REPLACE_WCRTOMB@
    238 extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
    239 # endif
    240 #elif defined GNULIB_POSIXCHECK
    241 # undef wcrtomb
    242 # define wcrtomb(s,w,p) \
    243     (GL_LINK_WARNING ("wcrtomb is unportable - " \
    244                       "use gnulib module wcrtomb for portability"), \
    245      wcrtomb (s, w, p))
    246 #endif
    247 
    248 
    249 /* Convert a wide string to a string.  */
    250 #if @GNULIB_WCSRTOMBS@
    251 # if @REPLACE_WCSRTOMBS@
    252 #  undef wcsrtombs
    253 #  define wcsrtombs rpl_wcsrtombs
    254 # endif
    255 # if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@
    256 extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps);
    257 # endif
    258 #elif defined GNULIB_POSIXCHECK
    259 # undef wcsrtombs
    260 # define wcsrtombs(d,s,l,p) \
    261     (GL_LINK_WARNING ("wcsrtombs is unportable - " \
    262                       "use gnulib module wcsrtombs for portability"), \
    263      wcsrtombs (d, s, l, p))
    264 #endif
    265 
    266 
    267 /* Convert a wide string to a string.  */
    268 #if @GNULIB_WCSNRTOMBS@
    269 # if @REPLACE_WCSNRTOMBS@
    270 #  undef wcsnrtombs
    271 #  define wcsnrtombs rpl_wcsnrtombs
    272 # endif
    273 # if !@HAVE_WCSNRTOMBS@ || @REPLACE_WCSNRTOMBS@
    274 extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps);
    275 # endif
    276 #elif defined GNULIB_POSIXCHECK
    277 # undef wcsnrtombs
    278 # define wcsnrtombs(d,s,n,l,p) \
    279     (GL_LINK_WARNING ("wcsnrtombs is unportable - " \
    280                       "use gnulib module wcsnrtombs for portability"), \
    281      wcsnrtombs (d, s, n, l, p))
    282 #endif
    283 
    284 
    285 /* Return the number of screen columns needed for WC.  */
    286 #if @GNULIB_WCWIDTH@
    287 # if @REPLACE_WCWIDTH@
    288 #  undef wcwidth
    289 #  define wcwidth rpl_wcwidth
    290 extern int wcwidth (wchar_t);
    291 # else
    292 #  if !defined wcwidth && !@HAVE_DECL_WCWIDTH@
    293 /* wcwidth exists but is not declared.  */
    294 extern int wcwidth (int /* actually wchar_t */);
    295 #  endif
    296 # endif
    297 #elif defined GNULIB_POSIXCHECK
    298 # undef wcwidth
    299 # define wcwidth(w) \
    300     (GL_LINK_WARNING ("wcwidth is unportable - " \
    301                       "use gnulib module wcwidth for portability"), \
    302      wcwidth (w))
    303 #endif
    304 
    305 
    306 #ifdef __cplusplus
    307 }
    308 #endif
    309 
    310 #endif /* _GL_WCHAR_H */
    311 #endif /* _GL_WCHAR_H */
    312 #endif
    313