projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
error, filevercmp: no 'static inline'
[gnulib.git]
/
lib
/
base64.c
diff --git
a/lib/base64.c
b/lib/base64.c
index
89e83e6
..
a328e1f
100644
(file)
--- a/
lib/base64.c
+++ b/
lib/base64.c
@@
-1,5
+1,5
@@
/* base64.c -- Encode binary data using printable characters.
/* base64.c -- Encode binary data using printable characters.
- Copyright (C) 1999-2001, 2004-2006, 2009-201
1
Free Software Foundation, Inc.
+ Copyright (C) 1999-2001, 2004-2006, 2009-201
2
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-12,14
+12,13
@@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program; if not, see <http://www.gnu.org/licenses/>. */
/* Written by Simon Josefsson. Partially adapted from GNU MailUtils
* (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
* from Paul Eggert, Bruno Haible, and Stepan Kasal.
*
/* Written by Simon Josefsson. Partially adapted from GNU MailUtils
* (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
* from Paul Eggert, Bruno Haible, and Stepan Kasal.
*
- * See also RFC
3548 <http://www.ietf.org/rfc/rfc35
48.txt>.
+ * See also RFC
4648 <http://www.ietf.org/rfc/rfc46
48.txt>.
*
* Be careful with error checking. Here is how you would typically
* use these functions:
*
* Be careful with error checking. Here is how you would typically
* use these functions:
@@
-53,16
+52,8
@@
#include <string.h>
#include <string.h>
-/* The attribute __const__ was added in gcc 2.95. */
-#undef _GL_ATTRIBUTE_CONST
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
-# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
-#else
-# define _GL_ATTRIBUTE_CONST /* empty */
-#endif
-
/* C89 compliant way to cast 'char' to 'unsigned char'. */
/* C89 compliant way to cast 'char' to 'unsigned char'. */
-static
inline
unsigned char
+static unsigned char
to_uchar (char ch)
{
return ch;
to_uchar (char ch)
{
return ch;
@@
-303,7
+294,7
@@
static const signed char b64[0x100] = {
/* Return true if CH is a character from the Base64 alphabet, and
false otherwise. Note that '=' is padding and not considered to be
part of the alphabet. */
/* Return true if CH is a character from the Base64 alphabet, and
false otherwise. Note that '=' is padding and not considered to be
part of the alphabet. */
-bool
_GL_ATTRIBUTE_CONST
+bool
isbase64 (char ch)
{
return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)];
isbase64 (char ch)
{
return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)];
@@
-323,7
+314,7
@@
base64_decode_ctx_init (struct base64_decode_context *ctx)
and return CTX->buf. In either case, advance *IN to point to the byte
after the last one processed, and set *N_NON_NEWLINE to the number of
verified non-newline bytes accessible through the returned pointer. */
and return CTX->buf. In either case, advance *IN to point to the byte
after the last one processed, and set *N_NON_NEWLINE to the number of
verified non-newline bytes accessible through the returned pointer. */
-static
inline
char *
+static char *
get_4 (struct base64_decode_context *ctx,
char const *restrict *in, char const *restrict in_end,
size_t *n_non_newline)
get_4 (struct base64_decode_context *ctx,
char const *restrict *in, char const *restrict in_end,
size_t *n_non_newline)
@@
-377,7
+368,7
@@
get_4 (struct base64_decode_context *ctx,
as many bytes as possible are written to *OUT. On return, advance
*OUT to point to the byte after the last one written, and decrement
*OUTLEN to reflect the number of bytes remaining in *OUT. */
as many bytes as possible are written to *OUT. On return, advance
*OUT to point to the byte after the last one written, and decrement
*OUTLEN to reflect the number of bytes remaining in *OUT. */
-static
inline
bool
+static bool
decode_4 (char const *restrict in, size_t inlen,
char *restrict *outp, size_t *outleft)
{
decode_4 (char const *restrict in, size_t inlen,
char *restrict *outp, size_t *outleft)
{
@@
-560,10
+551,10
@@
base64_decode_alloc_ctx (struct base64_decode_context *ctx,
{
/* This may allocate a few bytes too many, depending on input,
but it's not worth the extra CPU time to compute the exact size.
{
/* This may allocate a few bytes too many, depending on input,
but it's not worth the extra CPU time to compute the exact size.
- The exact size is 3 *
inlen / 4, minus 1 if the input ends
- with "=" and minus another 1 if the input ends with "==".
+ The exact size is 3 *
(inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
+
input ends
with "=" and minus another 1 if the input ends with "==".
Dividing before multiplying avoids the possibility of overflow. */
Dividing before multiplying avoids the possibility of overflow. */
- size_t needlen = 3 * (inlen / 4) +
2
;
+ size_t needlen = 3 * (inlen / 4) +
3
;
*out = malloc (needlen);
if (!*out)
*out = malloc (needlen);
if (!*out)