ctype.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* Copyright (C) 2002 Manuel Novoa III
  2. *
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Library General Public
  5. * License as published by the Free Software Foundation; either
  6. * version 2 of the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Library General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Library General Public
  14. * License along with this library; if not, write to the Free
  15. * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. /* NOTE: It is assumed here and throughout the library that the underlying
  18. * char encoding for the portable C character set is ASCII (host & target). */
  19. #ifndef _CTYPE_H
  20. #define _CTYPE_H
  21. #include <features.h>
  22. #include <bits/uClibc_ctype.h>
  23. __BEGIN_DECLS
  24. extern int isalnum(int c) __THROW;
  25. extern int isalpha(int c) __THROW;
  26. #ifdef __USE_ISOC99
  27. extern int isblank(int c) __THROW;
  28. #endif
  29. extern int iscntrl(int c) __THROW;
  30. extern int isdigit(int c) __THROW;
  31. extern int isgraph(int c) __THROW;
  32. extern int islower(int c) __THROW;
  33. extern int isprint(int c) __THROW;
  34. extern int ispunct(int c) __THROW;
  35. extern int isspace(int c) __THROW;
  36. extern int isupper(int c) __THROW;
  37. extern int isxdigit(int c) __THROW;
  38. extern int tolower(int c) __THROW;
  39. extern int toupper(int c) __THROW;
  40. #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
  41. extern int isascii(int c) __THROW;
  42. extern int toascii(int c) __THROW;
  43. #endif
  44. /* The following are included for compatibility with older versions of
  45. * uClibc; but now they're only visible if MISC funcctionality is requested.
  46. * However, as they are locale-independent, the hidden macro versions are
  47. * always present. */
  48. #ifdef __USE_MISC
  49. extern int isxlower(int c) __THROW; /* uClibc-specific. */
  50. extern int isxupper(int c) __THROW; /* uClibc-specific. */
  51. #endif
  52. /* Next, some ctype macros which are valid for all supported locales. */
  53. /* WARNING: isspace and isblank need to be reverified if more 8-bit codesets
  54. * are added!!! But isdigit and isxdigit are always valid. */
  55. #define __isspace(c) __C_isspace(c)
  56. #define __isblank(c) __C_isblank(c)
  57. #define __isdigit(c) __C_isdigit(c)
  58. #define __isxdigit(c) __C_isxdigit(c)
  59. /* Now some non-ansi/iso c99 macros. */
  60. #define __isascii(c) (((c) & ~0x7f) == 0)
  61. #define __toascii(c) ((c) & 0x7f)
  62. #define _toupper(c) ((c) ^ 0x20)
  63. #define _tolower(c) ((c) | 0x20)
  64. /* For compatibility with older versions of uClibc. Are these ever used? */
  65. #define __isxlower(c) __C_isxlower(c) /* uClibc-specific. */
  66. #define __isxupper(c) __C_isxupper(c) /* uClibc-specific. */
  67. /* Apparently, glibc implements things as macros if __NO_CTYPE isn't defined.
  68. * If we don't have locale support, we'll do the same. Otherwise, we'll
  69. * only use macros for the supported-locale-invariant cases. */
  70. #if 0
  71. /* Currently broken, since masking macros, other than getc and putc, must
  72. * evaluate their args exactly once. Will be fixed by the next release. mjn3 */
  73. /* #ifndef __NO_CTYPE */
  74. #define isdigit(c) __isdigit(c)
  75. #define isxdigit(c) __isxdigit(c)
  76. #define isspace(c) __isspace(c)
  77. #ifdef __USE_ISOC99
  78. #define isblank(c) __isblank(c)
  79. #endif
  80. #if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
  81. #define isascii(c) __isascii(c)
  82. #define toascii(c) __toascii(c)
  83. #endif
  84. #ifdef __USE_MISC
  85. #define isxlower(c) __C_isxlower(c) /* uClibc-specific. */
  86. #define isxupper(c) __C_isxupper(c) /* uClibc-specific. */
  87. #endif
  88. /* TODO - Should test for 8-bit codesets instead, but currently impossible. */
  89. #ifndef __UCLIBC_HAS_LOCALE__
  90. #define isalnum(c) __C_isalnum(c)
  91. #define isalpha(c) __C_isalpha(c)
  92. #define iscntrl(c) __C_iscntrl(c)
  93. #define isgraph(c) __C_isgraph(c)
  94. #define islower(c) __C_islower(c)
  95. #define isprint(c) __C_isprint(c)
  96. #define ispunct(c) __C_ispunct(c)
  97. #define isupper(c) __C_isupper(c)
  98. #define tolower(c) __C_tolower(c)
  99. #define toupper(c) __C_toupper(c)
  100. #endif /* __UCLIBC_HAS_LOCALE__ */
  101. #endif /* __NO_CTYPE */
  102. __END_DECLS
  103. #endif /* _CTYPE_H */