ctype.c 857 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include <libc/ctype.h>
  2. int isprint(int c)
  3. {
  4. if (c >= 0x20 && c <= 0x7e)
  5. {
  6. return 1;
  7. }
  8. return 0;
  9. }
  10. int islower(int c)
  11. {
  12. if (c >= 'a' && c <= 'z')
  13. {
  14. return 1;
  15. }
  16. return 0;
  17. }
  18. int isupper(int c)
  19. {
  20. if (c >= 'A' && c <= 'Z')
  21. {
  22. return 1;
  23. }
  24. return 0;
  25. }
  26. int isalpha(int c)
  27. {
  28. if (islower(c) || isupper(c))
  29. {
  30. return 1;
  31. }
  32. return 0;
  33. }
  34. int isdigit(int c)
  35. {
  36. if (c >= '0' && c <= '9')
  37. {
  38. return 1;
  39. }
  40. return 0;
  41. }
  42. int toupper(int c)
  43. {
  44. if (c >= 'a' && c <= 'z')
  45. {
  46. return c - 'a' + 'A';
  47. }
  48. return c;
  49. }
  50. int tolower(int c)
  51. {
  52. if (c >= 'A' && c <= 'Z')
  53. {
  54. return c - 'A' + 'a';
  55. }
  56. return c;
  57. }
  58. int isspace(int c)
  59. {
  60. return (c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == ' ');
  61. }