root/maint/gnulib/lib/uchar.in.h

/* [previous][next][first][last][top][bottom][index][help] */
   1 /* <uchar.h> substitute - 16-bit and 32-bit wide character types.
   2    Copyright (C) 2019-2021 Free Software Foundation, Inc.
   3 
   4    This file is free software: you can redistribute it and/or modify
   5    it under the terms of the GNU Lesser General Public License as
   6    published by the Free Software Foundation; either version 2.1 of the
   7    License, or (at your option) any later version.
   8 
   9    This file is distributed in the hope that it will be useful,
  10    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12    GNU Lesser General Public License for more details.
  13 
  14    You should have received a copy of the GNU Lesser General Public License
  15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
  16 
  17 /* Written by Bruno Haible <bruno@clisp.org>, 2019.  */
  18 
  19 /*
  20  * ISO C 11 <uchar.h> for platforms that lack it.
  21  */
  22 
  23 #ifndef _@GUARD_PREFIX@_UCHAR_H
  24 
  25 #if __GNUC__ >= 3
  26 @PRAGMA_SYSTEM_HEADER@
  27 #endif
  28 @PRAGMA_COLUMNS@
  29 
  30 #if @HAVE_UCHAR_H@
  31 # @INCLUDE_NEXT@ @NEXT_UCHAR_H@
  32 #endif
  33 
  34 /* Get uint_least16_t, uint_least32_t.  */
  35 #include <stdint.h>
  36 
  37 /* Get mbstate_t, size_t.  */
  38 #include <wchar.h>
  39 
  40 /* The __attribute__ feature is available in gcc versions 2.5 and later.
  41    The attribute __pure__ was added in gcc 2.96.  */
  42 #ifndef _GL_ATTRIBUTE_PURE
  43 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
  44 #  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
  45 # else
  46 #  define _GL_ATTRIBUTE_PURE /* empty */
  47 # endif
  48 #endif
  49 
  50 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
  51 
  52 
  53 #if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_UCHAR_TYPES@))
  54 
  55 /* A 16-bit variant of wchar_t.
  56    Note: This type does *NOT* denote UTF-16 units.  (Only on platforms
  57    on which __STDC_UTF_16__ is defined.)  */
  58 typedef uint_least16_t char16_t;
  59 
  60 #elif @GNULIBHEADERS_OVERRIDE_CHAR16_T@
  61 
  62 typedef uint_least16_t gl_char16_t;
  63 # define char16_t gl_char16_t
  64 
  65 #endif
  66 
  67 #if !(@HAVE_UCHAR_H@ || (defined __cplusplus && @CXX_HAS_UCHAR_TYPES@))
  68 
  69 /* A 32-bit variant of wchar_t.
  70    Note: This type does *NOT* denote UTF-32 code points.  (Only on platforms
  71    on which __STDC_UTF_32__ is defined.)  */
  72 typedef uint_least32_t char32_t;
  73 
  74 #elif @GNULIBHEADERS_OVERRIDE_CHAR32_T@
  75 
  76 typedef uint_least32_t gl_char32_t;
  77 # define char32_t gl_char32_t
  78 
  79 #endif
  80 
  81 /* Define if a 'char32_t' can hold more characters than a 'wchar_t'.  */
  82 #if @SMALL_WCHAR_T@                    /* 32-bit AIX, Cygwin, native Windows */
  83 # define _GL_LARGE_CHAR32_T 1
  84 #endif
  85 
  86 
  87 /* Convert a single-byte character to a 32-bit wide character.  */
  88 #if @GNULIB_BTOC32@
  89 _GL_FUNCDECL_SYS (btoc32, wint_t, (int c) _GL_ATTRIBUTE_PURE);
  90 _GL_CXXALIAS_SYS (btoc32, wint_t, (int c));
  91 _GL_CXXALIASWARN (btoc32);
  92 #endif
  93 
  94 
  95 /* Test a specific property of a 32-bit wide character.  */
  96 #if @GNULIB_C32ISALNUM@
  97 _GL_FUNCDECL_SYS (c32isalnum, int, (wint_t wc));
  98 _GL_CXXALIAS_SYS (c32isalnum, int, (wint_t wc));
  99 _GL_CXXALIASWARN (c32isalnum);
 100 #endif
 101 #if @GNULIB_C32ISALPHA@
 102 _GL_FUNCDECL_SYS (c32isalpha, int, (wint_t wc));
 103 _GL_CXXALIAS_SYS (c32isalpha, int, (wint_t wc));
 104 _GL_CXXALIASWARN (c32isalpha);
 105 #endif
 106 #if @GNULIB_C32ISBLANK@
 107 _GL_FUNCDECL_SYS (c32isblank, int, (wint_t wc));
 108 _GL_CXXALIAS_SYS (c32isblank, int, (wint_t wc));
 109 _GL_CXXALIASWARN (c32isblank);
 110 #endif
 111 #if @GNULIB_C32ISCNTRL@
 112 _GL_FUNCDECL_SYS (c32iscntrl, int, (wint_t wc));
 113 _GL_CXXALIAS_SYS (c32iscntrl, int, (wint_t wc));
 114 _GL_CXXALIASWARN (c32iscntrl);
 115 #endif
 116 #if @GNULIB_C32ISDIGIT@
 117 _GL_FUNCDECL_SYS (c32isdigit, int, (wint_t wc));
 118 _GL_CXXALIAS_SYS (c32isdigit, int, (wint_t wc));
 119 _GL_CXXALIASWARN (c32isdigit);
 120 #endif
 121 #if @GNULIB_C32ISGRAPH@
 122 _GL_FUNCDECL_SYS (c32isgraph, int, (wint_t wc));
 123 _GL_CXXALIAS_SYS (c32isgraph, int, (wint_t wc));
 124 _GL_CXXALIASWARN (c32isgraph);
 125 #endif
 126 #if @GNULIB_C32ISLOWER@
 127 _GL_FUNCDECL_SYS (c32islower, int, (wint_t wc));
 128 _GL_CXXALIAS_SYS (c32islower, int, (wint_t wc));
 129 _GL_CXXALIASWARN (c32islower);
 130 #endif
 131 #if @GNULIB_C32ISPRINT@
 132 _GL_FUNCDECL_SYS (c32isprint, int, (wint_t wc));
 133 _GL_CXXALIAS_SYS (c32isprint, int, (wint_t wc));
 134 _GL_CXXALIASWARN (c32isprint);
 135 #endif
 136 #if @GNULIB_C32ISPUNCT@
 137 _GL_FUNCDECL_SYS (c32ispunct, int, (wint_t wc));
 138 _GL_CXXALIAS_SYS (c32ispunct, int, (wint_t wc));
 139 _GL_CXXALIASWARN (c32ispunct);
 140 #endif
 141 #if @GNULIB_C32ISSPACE@
 142 _GL_FUNCDECL_SYS (c32isspace, int, (wint_t wc));
 143 _GL_CXXALIAS_SYS (c32isspace, int, (wint_t wc));
 144 _GL_CXXALIASWARN (c32isspace);
 145 #endif
 146 #if @GNULIB_C32ISUPPER@
 147 _GL_FUNCDECL_SYS (c32isupper, int, (wint_t wc));
 148 _GL_CXXALIAS_SYS (c32isupper, int, (wint_t wc));
 149 _GL_CXXALIASWARN (c32isupper);
 150 #endif
 151 #if @GNULIB_C32ISXDIGIT@
 152 _GL_FUNCDECL_SYS (c32isxdigit, int, (wint_t wc));
 153 _GL_CXXALIAS_SYS (c32isxdigit, int, (wint_t wc));
 154 _GL_CXXALIASWARN (c32isxdigit);
 155 #endif
 156 
 157 
 158 /* Converts a 32-bit wide character to a multibyte character.  */
 159 #if @GNULIB_C32RTOMB@
 160 # if @REPLACE_C32RTOMB@
 161 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 162 #   undef c32rtomb
 163 #   define c32rtomb rpl_c32rtomb
 164 #  endif
 165 _GL_FUNCDECL_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
 166 _GL_CXXALIAS_RPL (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
 167 # else
 168 #  if !@HAVE_C32RTOMB@
 169 _GL_FUNCDECL_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
 170 #  endif
 171 _GL_CXXALIAS_SYS (c32rtomb, size_t, (char *s, char32_t wc, mbstate_t *ps));
 172 # endif
 173 _GL_CXXALIASWARN (c32rtomb);
 174 #elif defined GNULIB_POSIXCHECK
 175 # undef c32rtomb
 176 # if HAVE_RAW_DECL_C32RTOMB
 177 _GL_WARN_ON_USE (mbrtoc32, "c32rtomb is not portable - "
 178                  "use gnulib module c32rtomb for portability");
 179 # endif
 180 #endif
 181 
 182 
 183 /* Convert a 32-bit wide string to a string.  */
 184 #if @GNULIB_C32SNRTOMBS@
 185 _GL_FUNCDECL_SYS (c32snrtombs, size_t,
 186                   (char *dest, const char32_t **srcp, size_t srclen, size_t len,
 187                    mbstate_t *ps)
 188                   _GL_ARG_NONNULL ((2)));
 189 _GL_CXXALIAS_SYS (c32snrtombs, size_t,
 190                   (char *dest, const char32_t **srcp, size_t srclen, size_t len,
 191                    mbstate_t *ps));
 192 _GL_CXXALIASWARN (c32snrtombs);
 193 #endif
 194 
 195 
 196 /* Convert a 32-bit wide string to a string.  */
 197 #if @GNULIB_C32SRTOMBS@
 198 _GL_FUNCDECL_SYS (c32srtombs, size_t,
 199                   (char *dest, const char32_t **srcp, size_t len, mbstate_t *ps)
 200                   _GL_ARG_NONNULL ((2)));
 201 _GL_CXXALIAS_SYS (c32srtombs, size_t,
 202                   (char *dest, const char32_t **srcp, size_t len,
 203                    mbstate_t *ps));
 204 _GL_CXXALIASWARN (c32srtombs);
 205 #endif
 206 
 207 
 208 /* Convert a 32-bit wide string to a string.  */
 209 #if @GNULIB_C32STOMBS@
 210 _GL_FUNCDECL_SYS (c32stombs, size_t,
 211                   (char *dest, const char32_t *src, size_t len)
 212                   _GL_ARG_NONNULL ((2)));
 213 _GL_CXXALIAS_SYS (c32stombs, size_t,
 214                   (char *dest, const char32_t *src, size_t len));
 215 _GL_CXXALIASWARN (c32stombs);
 216 #endif
 217 
 218 
 219 /* Converts a 32-bit wide character to unibyte character.
 220    Returns the single-byte representation of WC if it exists,
 221    or EOF otherwise.  */
 222 #if @GNULIB_C32TOB@
 223 _GL_FUNCDECL_SYS (c32tob, int, (wint_t wc));
 224 _GL_CXXALIAS_SYS (c32tob, int, (wint_t wc));
 225 _GL_CXXALIASWARN (c32tob);
 226 #endif
 227 
 228 
 229 /* Converts a multibyte character to a 32-bit wide character.  */
 230 #if @GNULIB_MBRTOC32@
 231 # if @REPLACE_MBRTOC32@
 232 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 233 #   undef mbrtoc32
 234 #   define mbrtoc32 rpl_mbrtoc32
 235 #  endif
 236 _GL_FUNCDECL_RPL (mbrtoc32, size_t,
 237                   (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
 238 _GL_CXXALIAS_RPL (mbrtoc32, size_t,
 239                   (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
 240 # else
 241 #  if !@HAVE_MBRTOC32@
 242 _GL_FUNCDECL_SYS (mbrtoc32, size_t,
 243                   (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
 244 #  endif
 245 _GL_CXXALIAS_SYS (mbrtoc32, size_t,
 246                   (char32_t *pc, const char *s, size_t n, mbstate_t *ps));
 247 # endif
 248 _GL_CXXALIASWARN (mbrtoc32);
 249 #elif defined GNULIB_POSIXCHECK
 250 # undef mbrtoc32
 251 # if HAVE_RAW_DECL_MBRTOC32
 252 _GL_WARN_ON_USE (mbrtoc32, "mbrtoc32 is not portable - "
 253                  "use gnulib module mbrtoc32 for portability");
 254 # endif
 255 #endif
 256 
 257 
 258 /* Convert a string to a 32-bit wide string.  */
 259 #if @GNULIB_MBSNRTOC32S@
 260 _GL_FUNCDECL_SYS (mbsnrtoc32s, size_t,
 261                   (char32_t *dest, const char **srcp, size_t srclen, size_t len,
 262                    mbstate_t *ps)
 263                   _GL_ARG_NONNULL ((2)));
 264 _GL_CXXALIAS_SYS (mbsnrtoc32s, size_t,
 265                   (char32_t *dest, const char **srcp, size_t srclen, size_t len,
 266                    mbstate_t *ps));
 267 _GL_CXXALIASWARN (mbsnrtoc32s);
 268 #endif
 269 
 270 
 271 /* Convert a string to a 32-bit wide string.  */
 272 #if @GNULIB_MBSRTOC32S@
 273 _GL_FUNCDECL_SYS (mbsrtoc32s, size_t,
 274                   (char32_t *dest, const char **srcp, size_t len, mbstate_t *ps)
 275                   _GL_ARG_NONNULL ((2)));
 276 _GL_CXXALIAS_SYS (mbsrtoc32s, size_t,
 277                   (char32_t *dest, const char **srcp, size_t len,
 278                    mbstate_t *ps));
 279 _GL_CXXALIASWARN (mbsrtoc32s);
 280 #endif
 281 
 282 
 283 /* Convert a string to a 32-bit wide string.  */
 284 #if @GNULIB_MBSTOC32S@
 285 _GL_FUNCDECL_SYS (mbstoc32s, size_t,
 286                   (char32_t *dest, const char *src, size_t len)
 287                   _GL_ARG_NONNULL ((2)));
 288 _GL_CXXALIAS_SYS (mbstoc32s, size_t,
 289                   (char32_t *dest, const char *src, size_t len));
 290 _GL_CXXALIASWARN (mbstoc32s);
 291 #endif
 292 
 293 
 294 #endif /* _@GUARD_PREFIX@_UCHAR_H */

/* [previous][next][first][last][top][bottom][index][help] */