ctype.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* ctype.c
  2. * Character classification and conversion
  3. * Copyright (C) 2000 Lineo, Inc.
  4. * Written by Erik Andersen
  5. * This file is part of the uClibc C library and is distributed
  6. * under the GNU Library General Public License.
  7. */
  8. #define USE_CTYPE_C_FUNCTIONS
  9. #include <ctype.h>
  10. #ifdef L_isalnum
  11. int
  12. isalnum( int c )
  13. {
  14. return (isalpha(c) || isdigit(c));
  15. }
  16. #endif
  17. #ifdef L_isalpha
  18. int
  19. isalpha( int c )
  20. {
  21. return (isupper(c) || islower(c));
  22. }
  23. #endif
  24. #ifdef L_isascii
  25. int
  26. isascii( int c )
  27. {
  28. return (c > 0 && c <= 0x7f);
  29. }
  30. #endif
  31. #ifdef L_iscntrl
  32. int
  33. iscntrl( int c )
  34. {
  35. return ((c > 0) && ((c <= 0x1f) || (c == 0x7f)));
  36. }
  37. #endif
  38. #ifdef L_isdigit
  39. int
  40. isdigit( int c )
  41. {
  42. return (c >= '0' && c <= '9');
  43. }
  44. #endif
  45. #ifdef L_isgraph
  46. int
  47. isgraph( int c )
  48. {
  49. return (c != ' ' && isprint(c));
  50. }
  51. #endif
  52. #ifdef L_islower
  53. int
  54. islower( int c )
  55. {
  56. return (c >= 'a' && c <= 'z');
  57. }
  58. #endif
  59. #ifdef L_isprint
  60. int
  61. isprint( int c )
  62. {
  63. return (c >= ' ' && c <= '~');
  64. }
  65. #endif
  66. #ifdef L_ispunct
  67. int
  68. ispunct( int c )
  69. {
  70. return ((c > ' ' && c <= '~') && !isalnum(c));
  71. }
  72. #endif
  73. #ifdef L_isspace
  74. int
  75. isspace( int c )
  76. {
  77. return (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||
  78. c == '\t' || c == '\v');
  79. }
  80. #endif
  81. #ifdef L_isupper
  82. int
  83. isupper( int c )
  84. {
  85. return (c >= 'A' && c <= 'Z');
  86. }
  87. #endif
  88. #ifdef L_isxdigit
  89. int
  90. isxdigit( int c )
  91. {
  92. return (isxupper(c) || isxlower(c));
  93. }
  94. #endif
  95. #ifdef L_isxlower
  96. int
  97. isxlower( int c )
  98. {
  99. return (isdigit(c) || (c >= 'a' && c <= 'f'));
  100. }
  101. #endif
  102. #ifdef L_isxupper
  103. int
  104. isxupper( int c )
  105. {
  106. return (isdigit(c) || (c >= 'A' && c <= 'F'));
  107. }
  108. #endif
  109. #ifdef L_toascii
  110. int
  111. toascii( int c )
  112. {
  113. return (c & 0x7f);
  114. }
  115. #endif
  116. #ifdef L_tolower
  117. int
  118. tolower( int c )
  119. {
  120. return (isupper(c) ? ( c - 'A' + 'a') : (c));
  121. }
  122. #endif
  123. #ifdef L_toupper
  124. int
  125. toupper( int c )
  126. {
  127. return (islower(c) ? (c - 'a' + 'A') : (c));
  128. }
  129. #endif