ctype.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 uC-Libc 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. int
  11. isalnum( int c )
  12. {
  13. return (isalpha(c) || isdigit(c));
  14. }
  15. int
  16. isalpha( int c )
  17. {
  18. return (isupper(c) || islower(c));
  19. }
  20. int
  21. isascii( int c )
  22. {
  23. return (c > 0 && c <= 0x7f);
  24. }
  25. int
  26. iscntrl( int c )
  27. {
  28. return ((c > 0) && ((c <= 0x1f) || (c == 0x7f)));
  29. }
  30. int
  31. isdigit( int c )
  32. {
  33. return (c >= '0' && c <= '9');
  34. }
  35. int
  36. isgraph( int c )
  37. {
  38. return (c != ' ' && isprint(c));
  39. }
  40. int
  41. islower( int c )
  42. {
  43. return (c >= 'a' && c <= 'z');
  44. }
  45. int
  46. isprint( int c )
  47. {
  48. return (c >= ' ' && c <= '~');
  49. }
  50. int
  51. ispunct( int c )
  52. {
  53. return ((c > ' ' && c <= '~') && !isalnum(c));
  54. }
  55. int
  56. isspace( int c )
  57. {
  58. return (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||
  59. c == '\t' || c == '\v');
  60. }
  61. int
  62. isupper( int c )
  63. {
  64. return (c >= 'A' && c <= 'Z');
  65. }
  66. int
  67. isxdigit( int c )
  68. {
  69. return (isxupper(c) || isxlower(c));
  70. }
  71. int
  72. isxlower( int c )
  73. {
  74. return (isdigit(c) || (c >= 'a' && c <= 'f'));
  75. }
  76. int
  77. isxupper( int c )
  78. {
  79. return (isdigit(c) || (c >= 'A' && c <= 'F'));
  80. }
  81. int
  82. toascii( int c )
  83. {
  84. return (c & 0x7f);
  85. }
  86. int
  87. tolower( int c )
  88. {
  89. return (isupper(c) ? ( c - 'A' + 'a') : (c));
  90. }
  91. int
  92. toupper( int c )
  93. {
  94. return (islower(c) ? (c - 'a' + 'A') : (c));
  95. }