ctype.c 880 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * File : ctype.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2008, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2008-08-14 Bernard the first version
  13. */
  14. #include <rtthread.h>
  15. #include <sys/types.h>
  16. #if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC)
  17. #include "ctype.h"
  18. int isprint (int ch)
  19. {
  20. ch&=0x7f;
  21. return (ch>=32 && ch<127);
  22. }
  23. int isalpha(int ch)
  24. {
  25. return (unsigned int)((ch | 0x20) - 'a') < 26u;
  26. }
  27. int isdigit (int ch)
  28. {
  29. return (unsigned int)(ch - '0') < 10u;
  30. }
  31. int isspace(int ch)
  32. {
  33. switch(ch)
  34. {
  35. case ' ':
  36. case '\n':
  37. case '\f':
  38. case '\r':
  39. case '\t':
  40. case '\v':
  41. return 1;
  42. default:
  43. return 0;
  44. }
  45. }
  46. #endif