ctype.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /** @file ctype.c
  2. * @brief The ctype functions
  3. *
  4. * Some ctype functions are not compatible among different OSes.
  5. * So faux library functions use their own versions of some
  6. * ctype functions to unify the behaviour. Really the most of the
  7. * faux ctype functions are only a wrappers for standard functions.
  8. */
  9. #include <ctype.h>
  10. #include "faux/ctype.h"
  11. /** @brief Checks for a digit
  12. *
  13. * The function is same as standard isdigit() but gets char type
  14. * as an argument.
  15. *
  16. * @param [in] c Character to classify.
  17. * @return BOOL_TRUE if char is digit and BOOL_FALSE else.
  18. */
  19. bool_t faux_ctype_isdigit(char c) {
  20. // isdigit() man says that argument must be unsigned char
  21. return isdigit((unsigned char)c) ? BOOL_TRUE : BOOL_FALSE;
  22. }
  23. /** @brief Checks for a white space
  24. *
  25. * The function is same as standard isspace() but gets char type
  26. * as an argument.
  27. *
  28. * @param [in] c Character to classify.
  29. * @return BOOL_TRUE if char is space and BOOL_FALSE else.
  30. */
  31. bool_t faux_ctype_isspace(char c) {
  32. // isspace() man says that argument must be unsigned char
  33. return isspace((unsigned char)c) ? BOOL_TRUE : BOOL_FALSE;
  34. }
  35. /** @brief Converts uppercase characters to lowercase
  36. *
  37. * The function is same as standard tolower() but gets char type
  38. * as an argument.
  39. *
  40. * @param [in] c Character to convert.
  41. * @return Converted character.
  42. */
  43. char faux_ctype_tolower(char c) {
  44. // tolower() man says that argument must be unsigned char
  45. return tolower((unsigned char)c);
  46. }
  47. /** @brief Converts lowercase characters to uppercase
  48. *
  49. * The function is same as standard toupper() but gets char type
  50. * as an argument.
  51. *
  52. * @param [in] c Character to convert.
  53. * @return Converted character.
  54. */
  55. char faux_ctype_toupper(char c)
  56. {
  57. // toupper() man says that argument must be unsigned char
  58. return toupper((unsigned char)c);
  59. }