bug-gnulib
[Top][All Lists]
Advanced

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

[bug-gnulib] Re: base64: export isbase64


From: Simon Josefsson
Subject: [bug-gnulib] Re: base64: export isbase64
Date: Thu, 20 Jan 2005 13:22:24 +0100
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Simon Josefsson <address@hidden> writes:

> How about this?  I realized that a 'isbase64' function was useful
> externally, and since there is a robust implementation in base64.c,
> why not export it...

I have installed this.

> 2004-12-28  Simon Josefsson  <address@hidden>
>
>       * 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.
>
> Index: base64.h
> ===================================================================
> RCS file: /cvsroot/gnulib/gnulib/lib/base64.h,v
> retrieving revision 1.1
> diff -u -p -u -w -r1.1 base64.h
> --- base64.h  30 Nov 2004 20:46:52 -0000      1.1
> +++ base64.h  28 Dec 2004 01:16:27 -0000
> @@ -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);
>  
> Index: base64.c
> ===================================================================
> RCS file: /cvsroot/gnulib/gnulib/lib/base64.c,v
> retrieving revision 1.1
> diff -u -p -u -w -r1.1 base64.c
> --- base64.c  30 Nov 2004 20:46:52 -0000      1.1
> +++ base64.c  28 Dec 2004 01:16:40 -0000
> @@ -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, 
>  
>    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, 
>       }
>        else
>       {
> -       if (!isb64 (in[2]))
> +       if (!isbase64 (in[2]))
>           break;
>  
>         if (outleft)
> @@ -339,7 +339,7 @@ base64_decode (const char *restrict in, 
>           }
>         else
>           {
> -           if (!isb64 (in[3]))
> +           if (!isbase64 (in[3]))
>               break;
>  
>             if (outleft)




reply via email to

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