chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
configure.ac: Lightly modernize.
[mLib]
/
codec
/
baseconv.c
diff --git
a/codec/baseconv.c
b/codec/baseconv.c
index bdb850f7d19ca53b2cbf4c9092e8fd7b6758852e..53fceb2818eb4039f83ec24659782d5c168da793 100644
(file)
--- a/
codec/baseconv.c
+++ b/
codec/baseconv.c
@@
-35,6
+35,7
@@
#include "alloc.h"
#include "codec.h"
#include "dstr.h"
#include "alloc.h"
#include "codec.h"
#include "dstr.h"
+#include "macros.h"
#include "sub.h"
#include "base64.h"
#include "sub.h"
#include "base64.h"
@@
-279,7
+280,7
@@
enum {
#define PUTWRAP(x) WRAP({ \
char ch = encodemap[x]; \
#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); \
})
DPUTC(d, ch); \
})
@@
-350,9
+351,9
@@
static int ctxn##_dodecode(ctxn##_ctx *ctx, \
case 0: \
break; \
case CDCF_LOWERC: \
case 0: \
break; \
case CDCF_LOWERC: \
- if (
isupper
(ch)) goto badch; \
+ if (
ISUPPER
(ch)) goto badch; \
default: \
default: \
- ch =
toupper
(ch); \
+ ch =
TOUPPER
(ch); \
} \
x = decodemap[ch]; \
switch (x) { \
} \
x = decodemap[ch]; \
switch (x) { \
@@
-363,8
+364,8
@@
static int ctxn##_dodecode(ctxn##_ctx *ctx, \
case PC: \
if (f & CDCF_IGNEQMID) break; \
if (f & CDCF_NOEQPAD) goto badch; \
case PC: \
if (f & CDCF_IGNEQMID) break; \
if (f & CDCF_NOEQPAD) goto badch; \
- if (st == ST_MAIN &&
\
-
!(f & CDCF_IGNZPAD) && (a & ((1 << nb) - 1)))
\
+ if (st == ST_MAIN &&
!(f & CDCF_IGNZPAD) &&
\
+
((nb && !(nb%wd)) || (a & ((1 << nb) - 1))))
\
return (CDCERR_INVZPAD); \
st = ST_PAD; \
if (!(f & CDCF_IGNEQPAD)) { \
return (CDCERR_INVZPAD); \
st = ST_PAD; \
if (!(f & CDCF_IGNEQPAD)) { \
@@
-386,8
+387,8
@@
static int ctxn##_dodecode(ctxn##_ctx *ctx, \
} \
} \
} else { \
} \
} \
} else { \
- if (st == ST_MAIN &&
\
-
!(f & CDCF_IGNZPAD) && (a & ((1 << nb) - 1)))
\
+ if (st == ST_MAIN &&
!(f & CDCF_IGNZPAD) &&
\
+
((nb && !(nb%wd)) || (a & ((1 << nb) - 1))))
\
return (CDCERR_INVZPAD); \
if (!(f & (CDCF_IGNEQPAD | CDCF_IGNEQMID | CDCF_NOEQPAD)) && nb) \
return (CDCERR_INVEQPAD); \
return (CDCERR_INVZPAD); \
if (!(f & (CDCF_IGNEQPAD | CDCF_IGNEQMID | CDCF_NOEQPAD)) && nb) \
return (CDCERR_INVEQPAD); \