| 1 |
/* A substitute for ISO C99 <ctype.h>, for platforms on which it is incomplete. |
| 2 |
|
| 3 |
Copyright (C) 2009-2026 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
This file is free software: you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU Lesser General Public License as |
| 7 |
published by the Free Software Foundation; either version 2.1 of the |
| 8 |
License, or (at your option) any later version. |
| 9 |
|
| 10 |
This file is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU Lesser General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Lesser General Public License |
| 16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 17 |
|
| 18 |
/* Written by Bruno Haible. */ |
| 19 |
|
| 20 |
/* |
| 21 |
* ISO C 99 <ctype.h> for platforms on which it is incomplete. |
| 22 |
* <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html> |
| 23 |
*/ |
| 24 |
|
| 25 |
#ifndef _@GUARD_PREFIX@_CTYPE_H |
| 26 |
|
| 27 |
#if __GNUC__ >= 3 |
| 28 |
@PRAGMA_SYSTEM_HEADER@ |
| 29 |
#endif |
| 30 |
@PRAGMA_COLUMNS@ |
| 31 |
|
| 32 |
/* On Solaris 11 OmniOS, we cannot include <locale.h> until after <wchar.h> has |
| 33 |
been entirely included. That is because |
| 34 |
- <locale.h> includes <xlocale.h>, which makes use of the mbstate_t type. |
| 35 |
- <wchar.h> includes <iso/wchar_iso.h>, which includes <ctype.h> *before* |
| 36 |
defining mbstate_t, WEOF, etc. */ |
| 37 |
#if defined __sun && defined _ISO_WCHAR_ISO_H && !defined WEOF |
| 38 |
/* We're in the middle of including <iso/wchar_iso.h>. |
| 39 |
Include just the original <ctype.h>. */ |
| 40 |
|
| 41 |
#@INCLUDE_NEXT@ @NEXT_CTYPE_H@ |
| 42 |
|
| 43 |
#else |
| 44 |
|
| 45 |
/* Include the original <ctype.h>. */ |
| 46 |
/* The include_next requires a split double-inclusion guard. */ |
| 47 |
#@INCLUDE_NEXT@ @NEXT_CTYPE_H@ |
| 48 |
|
| 49 |
#ifndef _@GUARD_PREFIX@_CTYPE_H |
| 50 |
#define _@GUARD_PREFIX@_CTYPE_H |
| 51 |
|
| 52 |
/* This file uses _GL_ARG_NONNULL, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ |
| 53 |
#if !_GL_CONFIG_H_INCLUDED |
| 54 |
#error "Please include config.h first." |
| 55 |
#endif |
| 56 |
|
| 57 |
#if (@GNULIB_ISALNUM_L@ || @GNULIB_ISALPHA_L@ || @GNULIB_ISBLANK_L@ \ |
| 58 |
|| @GNULIB_ISCNTRL_L@ || @GNULIB_ISDIGIT_L@ || @GNULIB_ISGRAPH_L@ \ |
| 59 |
|| @GNULIB_ISLOWER_L@ || @GNULIB_ISPRINT_L@ || @GNULIB_ISPUNCT_L@ \ |
| 60 |
|| @GNULIB_ISSPACE_L@ || @GNULIB_ISUPPER_L@ || @GNULIB_ISXDIGIT_L@ \ |
| 61 |
|| @GNULIB_TOLOWER_L@ || @GNULIB_TOUPPER_L@) |
| 62 |
/* Get locale_t. */ |
| 63 |
# include <locale.h> |
| 64 |
#endif |
| 65 |
|
| 66 |
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
| 67 |
|
| 68 |
/* The definition of _GL_ARG_NONNULL is copied here. */ |
| 69 |
|
| 70 |
/* The definition of _GL_WARN_ON_USE is copied here. */ |
| 71 |
|
| 72 |
/* Return non-zero if c is alphanumeric. */ |
| 73 |
#if @GNULIB_ISALNUM_L@ |
| 74 |
# if !@HAVE_ISALNUM_L@ |
| 75 |
_GL_FUNCDECL_SYS (isalnum_l, int, (int c, locale_t locale), |
| 76 |
_GL_ARG_NONNULL ((2))); |
| 77 |
# endif |
| 78 |
_GL_CXXALIAS_SYS (isalnum_l, int, (int c, locale_t locale)); |
| 79 |
# if __GLIBC__ >= 2 |
| 80 |
_GL_CXXALIASWARN (isalnum_l); |
| 81 |
# endif |
| 82 |
#elif defined GNULIB_POSIXCHECK |
| 83 |
# if HAVE_RAW_DECL_ISALNUM_L |
| 84 |
_GL_WARN_ON_USE (isalnum_l, "isalnum_l is unportable - " |
| 85 |
"use gnulib module isalnum_l for portability"); |
| 86 |
# endif |
| 87 |
#endif |
| 88 |
|
| 89 |
/* Return non-zero if c is alphabetic. */ |
| 90 |
#if @GNULIB_ISALPHA_L@ |
| 91 |
# if !@HAVE_ISALPHA_L@ |
| 92 |
_GL_FUNCDECL_SYS (isalpha_l, int, (int c, locale_t locale), |
| 93 |
_GL_ARG_NONNULL ((2))); |
| 94 |
# endif |
| 95 |
_GL_CXXALIAS_SYS (isalpha_l, int, (int c, locale_t locale)); |
| 96 |
# if __GLIBC__ >= 2 |
| 97 |
_GL_CXXALIASWARN (isalpha_l); |
| 98 |
# endif |
| 99 |
#elif defined GNULIB_POSIXCHECK |
| 100 |
# if HAVE_RAW_DECL_ISALPHA_L |
| 101 |
_GL_WARN_ON_USE (isalpha_l, "isalpha_l is unportable - " |
| 102 |
"use gnulib module isalpha_l for portability"); |
| 103 |
# endif |
| 104 |
#endif |
| 105 |
|
| 106 |
/* Return non-zero if c is a blank, i.e. a space or tab character. */ |
| 107 |
#if @GNULIB_ISBLANK@ |
| 108 |
# if !@HAVE_ISBLANK@ |
| 109 |
_GL_EXTERN_C int isblank (int c); |
| 110 |
# endif |
| 111 |
#elif defined GNULIB_POSIXCHECK |
| 112 |
# if HAVE_RAW_DECL_ISBLANK |
| 113 |
_GL_WARN_ON_USE (isblank, "isblank is unportable - " |
| 114 |
"use gnulib module isblank for portability"); |
| 115 |
# endif |
| 116 |
#endif |
| 117 |
|
| 118 |
/* Return non-zero if c is a blank, i.e. a space or tab character. */ |
| 119 |
#if @GNULIB_ISBLANK_L@ |
| 120 |
# if !@HAVE_ISBLANK_L@ |
| 121 |
_GL_FUNCDECL_SYS (isblank_l, int, (int c, locale_t locale), |
| 122 |
_GL_ARG_NONNULL ((2))); |
| 123 |
# endif |
| 124 |
_GL_CXXALIAS_SYS (isblank_l, int, (int c, locale_t locale)); |
| 125 |
# if __GLIBC__ >= 2 |
| 126 |
_GL_CXXALIASWARN (isblank_l); |
| 127 |
# endif |
| 128 |
#elif defined GNULIB_POSIXCHECK |
| 129 |
# if HAVE_RAW_DECL_ISBLANK_L |
| 130 |
_GL_WARN_ON_USE (isblank_l, "isblank_l is unportable - " |
| 131 |
"use gnulib module isblank_l for portability"); |
| 132 |
# endif |
| 133 |
#endif |
| 134 |
|
| 135 |
/* Return non-zero if c is a control character. */ |
| 136 |
#if @GNULIB_ISCNTRL_L@ |
| 137 |
# if !@HAVE_ISCNTRL_L@ |
| 138 |
_GL_FUNCDECL_SYS (iscntrl_l, int, (int c, locale_t locale), |
| 139 |
_GL_ARG_NONNULL ((2))); |
| 140 |
# endif |
| 141 |
_GL_CXXALIAS_SYS (iscntrl_l, int, (int c, locale_t locale)); |
| 142 |
# if __GLIBC__ >= 2 |
| 143 |
_GL_CXXALIASWARN (iscntrl_l); |
| 144 |
# endif |
| 145 |
#elif defined GNULIB_POSIXCHECK |
| 146 |
# if HAVE_RAW_DECL_ISCNTRL_L |
| 147 |
_GL_WARN_ON_USE (iscntrl_l, "iscntrl_l is unportable - " |
| 148 |
"use gnulib module iscntrl_l for portability"); |
| 149 |
# endif |
| 150 |
#endif |
| 151 |
|
| 152 |
/* Return non-zero if c is a digit. */ |
| 153 |
#if @GNULIB_ISDIGIT_L@ |
| 154 |
# if !@HAVE_ISDIGIT_L@ |
| 155 |
_GL_FUNCDECL_SYS (isdigit_l, int, (int c, locale_t locale), |
| 156 |
_GL_ARG_NONNULL ((2))); |
| 157 |
# endif |
| 158 |
_GL_CXXALIAS_SYS (isdigit_l, int, (int c, locale_t locale)); |
| 159 |
# if __GLIBC__ >= 2 |
| 160 |
_GL_CXXALIASWARN (isdigit_l); |
| 161 |
# endif |
| 162 |
#elif defined GNULIB_POSIXCHECK |
| 163 |
# if HAVE_RAW_DECL_ISDIGIT_L |
| 164 |
_GL_WARN_ON_USE (isdigit_l, "isdigit_l is unportable - " |
| 165 |
"use gnulib module isdigit_l for portability"); |
| 166 |
# endif |
| 167 |
#endif |
| 168 |
|
| 169 |
/* Return non-zero if c is graphic. */ |
| 170 |
#if @GNULIB_ISGRAPH_L@ |
| 171 |
# if !@HAVE_ISGRAPH_L@ |
| 172 |
_GL_FUNCDECL_SYS (isgraph_l, int, (int c, locale_t locale), |
| 173 |
_GL_ARG_NONNULL ((2))); |
| 174 |
# endif |
| 175 |
_GL_CXXALIAS_SYS (isgraph_l, int, (int c, locale_t locale)); |
| 176 |
# if __GLIBC__ >= 2 |
| 177 |
_GL_CXXALIASWARN (isgraph_l); |
| 178 |
# endif |
| 179 |
#elif defined GNULIB_POSIXCHECK |
| 180 |
# if HAVE_RAW_DECL_ISGRAPH_L |
| 181 |
_GL_WARN_ON_USE (isgraph_l, "isgraph_l is unportable - " |
| 182 |
"use gnulib module isgraph_l for portability"); |
| 183 |
# endif |
| 184 |
#endif |
| 185 |
|
| 186 |
/* Return non-zero if c is lowercase. */ |
| 187 |
#if @GNULIB_ISLOWER_L@ |
| 188 |
# if !@HAVE_ISLOWER_L@ |
| 189 |
_GL_FUNCDECL_SYS (islower_l, int, (int c, locale_t locale), |
| 190 |
_GL_ARG_NONNULL ((2))); |
| 191 |
# endif |
| 192 |
_GL_CXXALIAS_SYS (islower_l, int, (int c, locale_t locale)); |
| 193 |
# if __GLIBC__ >= 2 |
| 194 |
_GL_CXXALIASWARN (islower_l); |
| 195 |
# endif |
| 196 |
#elif defined GNULIB_POSIXCHECK |
| 197 |
# if HAVE_RAW_DECL_ISLOWER_L |
| 198 |
_GL_WARN_ON_USE (islower_l, "islower_l is unportable - " |
| 199 |
"use gnulib module islower_l for portability"); |
| 200 |
# endif |
| 201 |
#endif |
| 202 |
|
| 203 |
/* Return non-zero if c is printable. */ |
| 204 |
#if @GNULIB_ISPRINT_L@ |
| 205 |
# if !@HAVE_ISPRINT_L@ |
| 206 |
_GL_FUNCDECL_SYS (isprint_l, int, (int c, locale_t locale), |
| 207 |
_GL_ARG_NONNULL ((2))); |
| 208 |
# endif |
| 209 |
_GL_CXXALIAS_SYS (isprint_l, int, (int c, locale_t locale)); |
| 210 |
# if __GLIBC__ >= 2 |
| 211 |
_GL_CXXALIASWARN (isprint_l); |
| 212 |
# endif |
| 213 |
#elif defined GNULIB_POSIXCHECK |
| 214 |
# if HAVE_RAW_DECL_ISPRINT_L |
| 215 |
_GL_WARN_ON_USE (isprint_l, "isprint_l is unportable - " |
| 216 |
"use gnulib module isprint_l for portability"); |
| 217 |
# endif |
| 218 |
#endif |
| 219 |
|
| 220 |
/* Return non-zero if c is a punctuation or symbol character. */ |
| 221 |
#if @GNULIB_ISPUNCT_L@ |
| 222 |
# if !@HAVE_ISPUNCT_L@ |
| 223 |
_GL_FUNCDECL_SYS (ispunct_l, int, (int c, locale_t locale), |
| 224 |
_GL_ARG_NONNULL ((2))); |
| 225 |
# endif |
| 226 |
_GL_CXXALIAS_SYS (ispunct_l, int, (int c, locale_t locale)); |
| 227 |
# if __GLIBC__ >= 2 |
| 228 |
_GL_CXXALIASWARN (ispunct_l); |
| 229 |
# endif |
| 230 |
#elif defined GNULIB_POSIXCHECK |
| 231 |
# if HAVE_RAW_DECL_ISPUNCT_L |
| 232 |
_GL_WARN_ON_USE (ispunct_l, "ispunct_l is unportable - " |
| 233 |
"use gnulib module ispunct_l for portability"); |
| 234 |
# endif |
| 235 |
#endif |
| 236 |
|
| 237 |
/* Return non-zero if c is white-space. */ |
| 238 |
#if @GNULIB_ISSPACE_L@ |
| 239 |
# if !@HAVE_ISSPACE_L@ |
| 240 |
_GL_FUNCDECL_SYS (isspace_l, int, (int c, locale_t locale), |
| 241 |
_GL_ARG_NONNULL ((2))); |
| 242 |
# endif |
| 243 |
_GL_CXXALIAS_SYS (isspace_l, int, (int c, locale_t locale)); |
| 244 |
# if __GLIBC__ >= 2 |
| 245 |
_GL_CXXALIASWARN (isspace_l); |
| 246 |
# endif |
| 247 |
#elif defined GNULIB_POSIXCHECK |
| 248 |
# if HAVE_RAW_DECL_ISSPACE_L |
| 249 |
_GL_WARN_ON_USE (isspace_l, "isspace_l is unportable - " |
| 250 |
"use gnulib module isspace_l for portability"); |
| 251 |
# endif |
| 252 |
#endif |
| 253 |
|
| 254 |
/* Return non-zero if c is uppercase. */ |
| 255 |
#if @GNULIB_ISUPPER_L@ |
| 256 |
# if !@HAVE_ISUPPER_L@ |
| 257 |
_GL_FUNCDECL_SYS (isupper_l, int, (int c, locale_t locale), |
| 258 |
_GL_ARG_NONNULL ((2))); |
| 259 |
# endif |
| 260 |
_GL_CXXALIAS_SYS (isupper_l, int, (int c, locale_t locale)); |
| 261 |
# if __GLIBC__ >= 2 |
| 262 |
_GL_CXXALIASWARN (isupper_l); |
| 263 |
# endif |
| 264 |
#elif defined GNULIB_POSIXCHECK |
| 265 |
# if HAVE_RAW_DECL_ISUPPER_L |
| 266 |
_GL_WARN_ON_USE (isupper_l, "isupper_l is unportable - " |
| 267 |
"use gnulib module isupper_l for portability"); |
| 268 |
# endif |
| 269 |
#endif |
| 270 |
|
| 271 |
/* Return non-zero if c is a hexadecimal digit. */ |
| 272 |
#if @GNULIB_ISXDIGIT_L@ |
| 273 |
# if !@HAVE_ISXDIGIT_L@ |
| 274 |
_GL_FUNCDECL_SYS (isxdigit_l, int, (int c, locale_t locale), |
| 275 |
_GL_ARG_NONNULL ((2))); |
| 276 |
# endif |
| 277 |
_GL_CXXALIAS_SYS (isxdigit_l, int, (int c, locale_t locale)); |
| 278 |
# if __GLIBC__ >= 2 |
| 279 |
_GL_CXXALIASWARN (isxdigit_l); |
| 280 |
# endif |
| 281 |
#elif defined GNULIB_POSIXCHECK |
| 282 |
# if HAVE_RAW_DECL_ISXDIGIT_L |
| 283 |
_GL_WARN_ON_USE (isxdigit_l, "isxdigit_l is unportable - " |
| 284 |
"use gnulib module isxdigit_l for portability"); |
| 285 |
# endif |
| 286 |
#endif |
| 287 |
|
| 288 |
/* Map c to lowercase. */ |
| 289 |
#if @GNULIB_TOLOWER_L@ |
| 290 |
# if !@HAVE_TOLOWER_L@ |
| 291 |
_GL_FUNCDECL_SYS (tolower_l, int, (int c, locale_t locale), |
| 292 |
_GL_ARG_NONNULL ((2))); |
| 293 |
# endif |
| 294 |
_GL_CXXALIAS_SYS (tolower_l, int, (int c, locale_t locale)); |
| 295 |
# if __GLIBC__ >= 2 |
| 296 |
_GL_CXXALIASWARN (tolower_l); |
| 297 |
# endif |
| 298 |
#elif defined GNULIB_POSIXCHECK |
| 299 |
# if HAVE_RAW_DECL_TOLOWER_L |
| 300 |
_GL_WARN_ON_USE (tolower_l, "tolower_l is unportable - " |
| 301 |
"use gnulib module tolower_l for portability"); |
| 302 |
# endif |
| 303 |
#endif |
| 304 |
|
| 305 |
/* Map c to uppercase. */ |
| 306 |
#if @GNULIB_TOUPPER_L@ |
| 307 |
# if !@HAVE_TOUPPER_L@ |
| 308 |
_GL_FUNCDECL_SYS (toupper_l, int, (int c, locale_t locale), |
| 309 |
_GL_ARG_NONNULL ((2))); |
| 310 |
# endif |
| 311 |
_GL_CXXALIAS_SYS (toupper_l, int, (int c, locale_t locale)); |
| 312 |
# if __GLIBC__ >= 2 |
| 313 |
_GL_CXXALIASWARN (toupper_l); |
| 314 |
# endif |
| 315 |
#elif defined GNULIB_POSIXCHECK |
| 316 |
# if HAVE_RAW_DECL_TOUPPER_L |
| 317 |
_GL_WARN_ON_USE (toupper_l, "toupper_l is unportable - " |
| 318 |
"use gnulib module toupper_l for portability"); |
| 319 |
# endif |
| 320 |
#endif |
| 321 |
|
| 322 |
#endif /* _@GUARD_PREFIX@_CTYPE_H */ |
| 323 |
#endif |
| 324 |
#endif /* _@GUARD_PREFIX@_CTYPE_H */ |