]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/chartype.h
tableprinter: update of xtypes for tableprinter
[libucw.git] / ucw / chartype.h
index 1770709c3b0d970fa157ab248a0ec23ff2fe4a53..65972ce329c1fa385c113656026ec5f81c527149 100644 (file)
@@ -15,7 +15,8 @@
  * This way we bypass most possible problems with different compilation environments.
  *
  * All functions and macros accept any numbers and if it is necessary, they simply ignore higher bits.
- * It does not matter whether a parameter is signed or unsigned.
+ * It does not matter whether a parameter is signed or uintigned. Parameters are evaluated exactly once,
+ * so they can have side-effects.
  ***/
 
 #define _C_UPPER 1                     /* Upper-case letters */
@@ -32,9 +33,9 @@
 #define _C_WORD (_C_ALNUM | _C_INNER)
 #define _C_WSTART (_C_ALPHA | _C_INNER)
 
-extern const unsigned char _c_cat[256], _c_upper[256], _c_lower[256];
+extern const byte ucw_c_cat[256], ucw_c_upper[256], ucw_c_lower[256];
 
-#define Category(x) (_c_cat[(unsigned char)(x)])
+#define Category(x) (ucw_c_cat[(byte)(x)])
 #define Ccat(x,y) (Category(x) & y)
 
 #define Cupper(x) Ccat(x, _C_UPPER)    /** Checks for an upper-case character (`A-Z`). **/
@@ -49,15 +50,15 @@ extern const unsigned char _c_cat[256], _c_upper[256], _c_lower[256];
 #define Cctrl(x) Ccat(x, _C_CTRL)      /** Checks for control characters (`0x0-0x1F`, `0x7F`). **/
 #define Cspace(x) Cblank(x)
 
-#define Cupcase(x) (_c_upper[(unsigned char)(x)]) /** Convert a letter to upper case, leave non-letter characters unchanged. **/
-#define Clocase(x) (_c_lower[(unsigned char)(x)]) /** Convert a letter to lower case, leave non-letter characters unchanged. **/
+#define Cupcase(x) (ucw_c_upper[(byte)(x)]) /** Convert a letter to upper case, leave non-letter characters unchanged. **/
+#define Clocase(x) (ucw_c_lower[(byte)(x)]) /** Convert a letter to lower case, leave non-letter characters unchanged. **/
 
 /**
  * Compute the value of a valid hexadecimal character (ie. passed the @Cxdigit() check).
  **/
-static inline uns Cxvalue(byte x)
+static inline uint Cxvalue(byte x)
 {
-  return (x < (uns)'A') ? x - '0' : (x & 0xdf) - 'A' + 10;
+  return (x < (uint)'A') ? x - '0' : (x & 0xdf) - 'A' + 10;
 }
 
 #endif