X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Fchartype.h;h=65972ce329c1fa385c113656026ec5f81c527149;hb=1481eca416a467e9952dbc5e4852afe66eaf1256;hp=930bf90e80eb65bd8b68219b2126502b3595967e;hpb=9935e649cbebddb44a21df196fb92ad6e703eb23;p=libucw.git diff --git a/ucw/chartype.h b/ucw/chartype.h index 930bf90e..65972ce3 100644 --- a/ucw/chartype.h +++ b/ucw/chartype.h @@ -14,8 +14,9 @@ * We define our own routines to classify 8-bit characters (based on US-ASCII charset). * This way we bypass most possible problems with different compilation environments. * - * All functions and macros accept any numeric parameters and if it is necessary, they simply ignore higher bits. - * It does not matter whether a parameter is signed or unsigned. + * 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 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