[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gnulib] Re: base64
From: |
Simon Josefsson |
Subject: |
[bug-gnulib] Re: base64 |
Date: |
Thu, 25 Nov 2004 15:37:06 +0100 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
Stepan Kasal <address@hidden> writes:
> Hi Jim,
>
> On Thu, Nov 25, 2004 at 03:25:34PM +0100, Jim Meyering wrote:
>> There should be parentheses around each RHS:
>>
>> #define BASE64_CEILING_DIV(n, k) ((n + (k-1)) / k)
>> #define BASE64_LENGTH(inlen) (BASE64_CEILING_DIV(inlen, 3) * 4)
>
> Thank you for correcting me. To make BASE64_CEILING_DIV generally usable,
> one would have to do:
>
> #define BASE64_CEILING_DIV(n, k) (((n) + ((k)-1)) / (k))
> #define BASE64_LENGTH(inlen) (BASE64_CEILING_DIV(inlen, 3) * 4)
>
> but perhaps we can settle with:
>
> #define _BASE64_CEILING_DIV(n, k) ((n + (k-1)) / k)
> #define BASE64_LENGTH(inlen) (_BASE64_CEILING_DIV(inlen, 3) * 4)
What advantage does this have over
#define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
The latter seems simpler to me.
Perhaps the macro name should be BASE64_EXPAND_LENGTH, and there could
be another macro BASE64_COLLAPSE_MAX_LENGTH to compute the longest
possible base64 decoded output. (The correct output length depend on
the number of '=' pads in the input.)
- [bug-gnulib] base64, Simon Josefsson, 2004/11/23
- Re: [bug-gnulib] base64, Bruno Haible, 2004/11/24
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/25
- Re: [bug-gnulib] Re: base64, Stepan Kasal, 2004/11/25
- Re: [bug-gnulib] Re: base64, Jim Meyering, 2004/11/25
- Re: [bug-gnulib] Re: base64, Stepan Kasal, 2004/11/25
- [bug-gnulib] Re: base64,
Simon Josefsson <=
- Re: [bug-gnulib] Re: base64, Stepan Kasal, 2004/11/25
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/25
- Re: [bug-gnulib] Re: base64, Bruno Haible, 2004/11/25
- Re: [bug-gnulib] Re: base64, Paul Eggert, 2004/11/26
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/26
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/26
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/28
- Re: [bug-gnulib] Re: base64, Paul Eggert, 2004/11/28
- [bug-gnulib] Re: base64, Simon Josefsson, 2004/11/29
- Re: [bug-gnulib] Re: base64, Paul Eggert, 2004/11/30