utils/macros.h: Add <ctype.h> and `foocmp' helper macros.
[mLib] / codec / baseconv.c
index bdb850f..b7cb0a0 100644 (file)
@@ -35,6 +35,7 @@
 #include "alloc.h"
 #include "codec.h"
 #include "dstr.h"
+#include "macros.h"
 #include "sub.h"
 
 #include "base64.h"
@@ -279,7 +280,7 @@ enum {
 
 #define PUTWRAP(x) WRAP({                                              \
   char ch = encodemap[x];                                              \
-  if (f & CDCF_LOWERC) ch = tolower((unsigned char)ch);                        \
+  if (f & CDCF_LOWERC) ch = TOLOWER(ch);                               \
   DPUTC(d, ch);                                                                \
 })
 
@@ -350,9 +351,9 @@ static int ctxn##_dodecode(ctxn##_ctx *ctx,                         \
        case 0:                                                         \
          break;                                                        \
        case CDCF_LOWERC:                                               \
-         if (isupper(ch)) goto badch;                                  \
+         if (ISUPPER(ch)) goto badch;                                  \
        default:                                                        \
-         ch = toupper(ch);                                             \
+         ch = TOUPPER(ch);                                             \
       }                                                                        \
       x = decodemap[ch];                                               \
       switch (x) {                                                     \