bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Portablity bug in base64.c


From: Larry Jones
Subject: Portablity bug in base64.c
Date: Thu, 22 Jun 2006 11:53:17 -0400 (EDT)

Some older preprocessors substitue macro parameter names that occur in
character constants or string literals.  This breaks base64.c since it
uses x as a parameter name in a macro that has a 'x' character constant
in its expansion.  Here's a fix:

Index: base64.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/lib/base64.c,v
retrieving revision 1.3
diff -u -u -r1.3 base64.c
--- base64.c    25 Apr 2006 14:48:46 -0000      1.3
+++ base64.c    22 Jun 2006 15:14:06 -0000
@@ -150,71 +150,71 @@
    1003.1-2001 require that char and unsigned char are 8-bit
    quantities, though, taking care of that problem.  But this may be a
    potential problem on non-POSIX C99 platforms.  */
-#define B64(x)                                 \
-  ((x) == 'A' ? 0                              \
-   : (x) == 'B' ? 1                            \
-   : (x) == 'C' ? 2                            \
-   : (x) == 'D' ? 3                            \
-   : (x) == 'E' ? 4                            \
-   : (x) == 'F' ? 5                            \
-   : (x) == 'G' ? 6                            \
-   : (x) == 'H' ? 7                            \
-   : (x) == 'I' ? 8                            \
-   : (x) == 'J' ? 9                            \
-   : (x) == 'K' ? 10                           \
-   : (x) == 'L' ? 11                           \
-   : (x) == 'M' ? 12                           \
-   : (x) == 'N' ? 13                           \
-   : (x) == 'O' ? 14                           \
-   : (x) == 'P' ? 15                           \
-   : (x) == 'Q' ? 16                           \
-   : (x) == 'R' ? 17                           \
-   : (x) == 'S' ? 18                           \
-   : (x) == 'T' ? 19                           \
-   : (x) == 'U' ? 20                           \
-   : (x) == 'V' ? 21                           \
-   : (x) == 'W' ? 22                           \
-   : (x) == 'X' ? 23                           \
-   : (x) == 'Y' ? 24                           \
-   : (x) == 'Z' ? 25                           \
-   : (x) == 'a' ? 26                           \
-   : (x) == 'b' ? 27                           \
-   : (x) == 'c' ? 28                           \
-   : (x) == 'd' ? 29                           \
-   : (x) == 'e' ? 30                           \
-   : (x) == 'f' ? 31                           \
-   : (x) == 'g' ? 32                           \
-   : (x) == 'h' ? 33                           \
-   : (x) == 'i' ? 34                           \
-   : (x) == 'j' ? 35                           \
-   : (x) == 'k' ? 36                           \
-   : (x) == 'l' ? 37                           \
-   : (x) == 'm' ? 38                           \
-   : (x) == 'n' ? 39                           \
-   : (x) == 'o' ? 40                           \
-   : (x) == 'p' ? 41                           \
-   : (x) == 'q' ? 42                           \
-   : (x) == 'r' ? 43                           \
-   : (x) == 's' ? 44                           \
-   : (x) == 't' ? 45                           \
-   : (x) == 'u' ? 46                           \
-   : (x) == 'v' ? 47                           \
-   : (x) == 'w' ? 48                           \
-   : (x) == 'x' ? 49                           \
-   : (x) == 'y' ? 50                           \
-   : (x) == 'z' ? 51                           \
-   : (x) == '0' ? 52                           \
-   : (x) == '1' ? 53                           \
-   : (x) == '2' ? 54                           \
-   : (x) == '3' ? 55                           \
-   : (x) == '4' ? 56                           \
-   : (x) == '5' ? 57                           \
-   : (x) == '6' ? 58                           \
-   : (x) == '7' ? 59                           \
-   : (x) == '8' ? 60                           \
-   : (x) == '9' ? 61                           \
-   : (x) == '+' ? 62                           \
-   : (x) == '/' ? 63                           \
+#define B64(xx)                                        \
+  ((xx) == 'A' ? 0                             \
+   : (xx) == 'B' ? 1                           \
+   : (xx) == 'C' ? 2                           \
+   : (xx) == 'D' ? 3                           \
+   : (xx) == 'E' ? 4                           \
+   : (xx) == 'F' ? 5                           \
+   : (xx) == 'G' ? 6                           \
+   : (xx) == 'H' ? 7                           \
+   : (xx) == 'I' ? 8                           \
+   : (xx) == 'J' ? 9                           \
+   : (xx) == 'K' ? 10                          \
+   : (xx) == 'L' ? 11                          \
+   : (xx) == 'M' ? 12                          \
+   : (xx) == 'N' ? 13                          \
+   : (xx) == 'O' ? 14                          \
+   : (xx) == 'P' ? 15                          \
+   : (xx) == 'Q' ? 16                          \
+   : (xx) == 'R' ? 17                          \
+   : (xx) == 'S' ? 18                          \
+   : (xx) == 'T' ? 19                          \
+   : (xx) == 'U' ? 20                          \
+   : (xx) == 'V' ? 21                          \
+   : (xx) == 'W' ? 22                          \
+   : (xx) == 'X' ? 23                          \
+   : (xx) == 'Y' ? 24                          \
+   : (xx) == 'Z' ? 25                          \
+   : (xx) == 'a' ? 26                          \
+   : (xx) == 'b' ? 27                          \
+   : (xx) == 'c' ? 28                          \
+   : (xx) == 'd' ? 29                          \
+   : (xx) == 'e' ? 30                          \
+   : (xx) == 'f' ? 31                          \
+   : (xx) == 'g' ? 32                          \
+   : (xx) == 'h' ? 33                          \
+   : (xx) == 'i' ? 34                          \
+   : (xx) == 'j' ? 35                          \
+   : (xx) == 'k' ? 36                          \
+   : (xx) == 'l' ? 37                          \
+   : (xx) == 'm' ? 38                          \
+   : (xx) == 'n' ? 39                          \
+   : (xx) == 'o' ? 40                          \
+   : (xx) == 'p' ? 41                          \
+   : (xx) == 'q' ? 42                          \
+   : (xx) == 'r' ? 43                          \
+   : (xx) == 's' ? 44                          \
+   : (xx) == 't' ? 45                          \
+   : (xx) == 'u' ? 46                          \
+   : (xx) == 'v' ? 47                          \
+   : (xx) == 'w' ? 48                          \
+   : (xx) == 'x' ? 49                          \
+   : (xx) == 'y' ? 50                          \
+   : (xx) == 'z' ? 51                          \
+   : (xx) == '0' ? 52                          \
+   : (xx) == '1' ? 53                          \
+   : (xx) == '2' ? 54                          \
+   : (xx) == '3' ? 55                          \
+   : (xx) == '4' ? 56                          \
+   : (xx) == '5' ? 57                          \
+   : (xx) == '6' ? 58                          \
+   : (xx) == '7' ? 59                          \
+   : (xx) == '8' ? 60                          \
+   : (xx) == '9' ? 61                          \
+   : (xx) == '+' ? 62                          \
+   : (xx) == '/' ? 63                          \
    : -1)
 
 static const signed char b64[0x100] = {

-Larry Jones

I'll be a hulking, surly teen-ager before you know it!! -- Calvin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]