* base64.h (isbase64): Add.
authorSimon Josefsson <simon@josefsson.org>
Thu, 20 Jan 2005 12:22:11 +0000 (12:22 +0000)
committerSimon Josefsson <simon@josefsson.org>
Thu, 20 Jan 2005 12:22:11 +0000 (12:22 +0000)
* base64.c (isb64): Rename to isbase64, use to_uchar instead of
using a unsigned prototype, don't inline.
(base64_decode): Use it.

lib/ChangeLog
lib/base64.c
lib/base64.h

index f2b6288..1d835f7 100644 (file)
@@ -1,3 +1,11 @@
+2004-12-28  Simon Josefsson  <jas@extundo.com>
+
+       * base64.h (isbase64): Add.
+
+       * base64.c (isb64): Rename to isbase64, use to_uchar instead of
+       using a unsigned prototype, don't inline.
+       (base64_decode): Use it.
+
 2005-01-19  Bruno Haible  <bruno@clisp.org>
 
        * sh-quote.h: New file, from GNU gettext.
index 97b6019..98d933a 100644 (file)
@@ -274,10 +274,10 @@ static const signed char b64[0x100] = {
   B64 (252), B64 (253), B64 (254), B64 (255)
 };
 
-static inline bool
-isb64 (unsigned char ch)
+bool
+isbase64 (char ch)
 {
-  return ch <= 255 && 0 <= b64[ch];
+  return to_uchar (ch) <= 255 && 0 <= b64[to_uchar (ch)];
 }
 
 /* Decode base64 encoded input array IN of length INLEN to output
@@ -295,7 +295,7 @@ base64_decode (const char *restrict in, size_t inlen,
 
   while (inlen >= 2)
     {
-      if (!isb64 (in[0]) || !isb64 (in[1]))
+      if (!isbase64 (in[0]) || !isbase64 (in[1]))
        break;
 
       if (outleft)
@@ -319,7 +319,7 @@ base64_decode (const char *restrict in, size_t inlen,
        }
       else
        {
-         if (!isb64 (in[2]))
+         if (!isbase64 (in[2]))
            break;
 
          if (outleft)
@@ -339,7 +339,7 @@ base64_decode (const char *restrict in, size_t inlen,
            }
          else
            {
-             if (!isb64 (in[3]))
+             if (!isbase64 (in[3]))
                break;
 
              if (outleft)
index 99c3bb0..6c5c7ba 100644 (file)
@@ -29,6 +29,8 @@
    integer >= n/k, i.e., the ceiling of n/k.  */
 #define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
 
+extern bool isbase64 (char ch);
+
 extern void base64_encode (const char *restrict in, size_t inlen,
                           char *restrict out, size_t outlen);