Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2. ** $Id: lctype.h,v 1.8 2009/11/19 19:06:52 roberto Exp $
  3. ** 'ctype' functions for Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6.  
  7. #ifndef lctype_h
  8. #define lctype_h
  9.  
  10.  
  11. #include <limits.h>
  12.  
  13. #include "lua.h"
  14.  
  15. #include "llimits.h"
  16.  
  17.  
  18. #define ALPHABIT        0
  19. #define DIGITBIT        1
  20. #define PRINTBIT        2
  21. #define SPACEBIT        3
  22. #define XDIGITBIT       4
  23. #define UPPERBIT        5
  24.  
  25.  
  26. #define MASK(B)         (1 << (B))
  27.  
  28.  
  29. /*
  30. ** add 1 to char to allow index -1 (EOZ)
  31. */
  32. #define testprop(c,p)   (luai_ctype_[(c)+1] & (p))
  33.  
  34. /*
  35. ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
  36. */
  37. #define lislalpha(c)    testprop(c, MASK(ALPHABIT))
  38. #define lislalnum(c)    testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
  39. #define lisupper(c)     testprop(c, MASK(UPPERBIT))
  40. #define lisdigit(c)     testprop(c, MASK(DIGITBIT))
  41. #define lisspace(c)     testprop(c, MASK(SPACEBIT))
  42. #define lisprint(c)     testprop(c, MASK(PRINTBIT))
  43. #define lisxdigit(c)    testprop(c, MASK(XDIGITBIT))
  44.  
  45.  
  46. /* one more entry for 0 and one more for -1 (EOZ) */
  47. LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
  48.  
  49. #endif
  50.  
  51.