src/lj_char.h - luajit-2.0-src

Global variables defined

Macros defined

Source code

  1. /*
  2. ** Character types.
  3. ** Donated to the public domain.
  4. */

  5. #ifndef _LJ_CHAR_H
  6. #define _LJ_CHAR_H

  7. #include "lj_def.h"

  8. #define LJ_CHAR_CNTRL        0x01
  9. #define LJ_CHAR_SPACE        0x02
  10. #define LJ_CHAR_PUNCT        0x04
  11. #define LJ_CHAR_DIGIT        0x08
  12. #define LJ_CHAR_XDIGIT        0x10
  13. #define LJ_CHAR_UPPER        0x20
  14. #define LJ_CHAR_LOWER        0x40
  15. #define LJ_CHAR_IDENT        0x80
  16. #define LJ_CHAR_ALPHA        (LJ_CHAR_LOWER|LJ_CHAR_UPPER)
  17. #define LJ_CHAR_ALNUM        (LJ_CHAR_ALPHA|LJ_CHAR_DIGIT)
  18. #define LJ_CHAR_GRAPH        (LJ_CHAR_ALNUM|LJ_CHAR_PUNCT)

  19. /* Only pass -1 or 0..255 to these macros. Never pass a signed char! */
  20. #define lj_char_isa(c, t)        ((lj_char_bits+1)[(c)] & t)
  21. #define lj_char_iscntrl(c)        lj_char_isa((c), LJ_CHAR_CNTRL)
  22. #define lj_char_isspace(c)        lj_char_isa((c), LJ_CHAR_SPACE)
  23. #define lj_char_ispunct(c)        lj_char_isa((c), LJ_CHAR_PUNCT)
  24. #define lj_char_isdigit(c)        lj_char_isa((c), LJ_CHAR_DIGIT)
  25. #define lj_char_isxdigit(c)        lj_char_isa((c), LJ_CHAR_XDIGIT)
  26. #define lj_char_isupper(c)        lj_char_isa((c), LJ_CHAR_UPPER)
  27. #define lj_char_islower(c)        lj_char_isa((c), LJ_CHAR_LOWER)
  28. #define lj_char_isident(c)        lj_char_isa((c), LJ_CHAR_IDENT)
  29. #define lj_char_isalpha(c)        lj_char_isa((c), LJ_CHAR_ALPHA)
  30. #define lj_char_isalnum(c)        lj_char_isa((c), LJ_CHAR_ALNUM)
  31. #define lj_char_isgraph(c)        lj_char_isa((c), LJ_CHAR_GRAPH)

  32. #define lj_char_toupper(c)        ((c) - (lj_char_islower(c) >> 1))
  33. #define lj_char_tolower(c)        ((c) + lj_char_isupper(c))

  34. LJ_DATA const uint8_t lj_char_bits[257];

  35. #endif