Fix 2008-04-14 regression in asprintf(ptr,"").
* libc/stdio/asnprintf.c (asnprintf, _asnprintf_r): Avoid stdio baggage. * libc/stdio/asniprintf.c (asniprintf, _asniprintf_r): Likewise. * libc/stdio/asiprintf.c (asiprintf, _asiprintf_r): Likewise. * libc/stdio/vasniprintf.c (_vasniprintf_r): Likewise. * libc/stdio/vsnprintf.c (_vsnprintf_r): Likewise. * libc/stdio/vfprintf.c (_VFPRINTF_R) [STRING_ONLY]: Always malloc an initial buffer for asprintf.
This commit is contained in:
parent
661efd2dea
commit
f77a1a8848
@ -1,3 +1,15 @@
|
||||
2008-04-29 Eric Blake <ebb9@byu.net>
|
||||
|
||||
Fix 2008-04-14 regression in asprintf(ptr,"").
|
||||
* libc/stdio/asnprintf.c (asnprintf, _asnprintf_r): Avoid stdio
|
||||
baggage.
|
||||
* libc/stdio/asniprintf.c (asniprintf, _asniprintf_r): Likewise.
|
||||
* libc/stdio/asiprintf.c (asiprintf, _asiprintf_r): Likewise.
|
||||
* libc/stdio/vasniprintf.c (_vasniprintf_r): Likewise.
|
||||
* libc/stdio/vsnprintf.c (_vsnprintf_r): Likewise.
|
||||
* libc/stdio/vfprintf.c (_VFPRINTF_R) [STRING_ONLY]: Always malloc
|
||||
an initial buffer for asprintf.
|
||||
|
||||
2008-04-24 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* libc/include/sys/stat.h: Guard at-functions with !__INSIDE_CYGWIN__.
|
||||
@ -23,7 +35,7 @@
|
||||
|
||||
* libc/include/_ansi.h: _LONG_LONG renamed to _LONG_LONG_TYPE.
|
||||
* libc/include/math.h: Likewise.
|
||||
|
||||
|
||||
2008-04-23 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* libc/include/stdio.h (renameat): Declare for Cygwin.
|
||||
@ -55,31 +67,31 @@
|
||||
2008-04-16 Patrick Mansfield <patmans@us.ibm.com>
|
||||
|
||||
* libc/machine/spu/sys/errno.h: Use _impure_data, not _reent_data.
|
||||
|
||||
|
||||
2008-04-16 Patrick Mansfield <patmans@us.ibm.com>
|
||||
|
||||
* libc/machine/spu/impure.c: Add missing underscore to impure_data.
|
||||
|
||||
|
||||
2008-04-14 Patrick Mansfield <patmans@us.ibm.com>
|
||||
|
||||
* libc/machine/spu/impure.c: New file, supply a non-static _impure_data.
|
||||
* libc/machine/spu/Makefile.am: Add new file impure.c.
|
||||
* libc/machine/spu/Makefile.am: Add new file impure.c.
|
||||
* libc/machine/spu/Makefile.in: Regenerate.
|
||||
* libc/machine/spu/sys/errno.h: Define errno to be _reent_data._errno.
|
||||
|
||||
|
||||
2008-04-14 Jeff Johnston <jjohnstn@redhat.com>
|
||||
|
||||
* libc/stdio/Makefile.am: Build vfprintf.c and vfscanf.c with
|
||||
-DSTRING_ONLY defined with and without -DINTEGER_ONLY defined
|
||||
to build special versions for sprintf/sscanf family functions.
|
||||
* libc/stdio/Makefile.in: Regenerated.
|
||||
* libc/stdio/vfprintf.c[STRING_ONLY][INTEGER_ONLY](_VFPRINTF_R):
|
||||
Redefine to be _svfiprintf_r which is optimized to work with siprintf
|
||||
* libc/stdio/vfprintf.c[STRING_ONLY][INTEGER_ONLY](_VFPRINTF_R):
|
||||
Redefine to be _svfiprintf_r which is optimized to work with siprintf
|
||||
family of functions (i.e. no I/O) and does not support floating-point.
|
||||
[STRING_ONLY][!INTEGER_ONLY](_VFPRINTF_R): Redefine to be
|
||||
_svfprintf_r which is optimized to work with sprintf family of
|
||||
functions and not use I/O.
|
||||
[STRING_ONLY](__sprint_r): New string only version of static function.
|
||||
[STRING_ONLY](__sprint_r): New string only version of static function.
|
||||
designed to work with sprintf family of functions.
|
||||
* libc/stdio/vfscanf.c[STRING_ONLY][INTEGER_ONLY](_SVFSCANF_R):
|
||||
Redefine to be _ssvfiscanf_r which is optimized to work with siscanf
|
||||
@ -135,7 +147,7 @@
|
||||
* libc/include/reent.h: Define _func_r functions in this file to
|
||||
func if REENTRANT_SYSCALLS_PROVIDED and MISSING_SYSCALL_NAMES are
|
||||
defined.
|
||||
|
||||
|
||||
2008-03-27 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* libc/include/sys/unistd.h: Declare lockf(2) and define lockf
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1990, 2007 The Regents of the University of California.
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
@ -40,7 +40,7 @@ _DEFUN(_asiprintf_r, (ptr, strp, fmt),
|
||||
f._bf._size = f._w = 0;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _vfiprintf_r (ptr, &f, fmt, ap);
|
||||
ret = _svfiprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret >= 0)
|
||||
{
|
||||
@ -67,7 +67,7 @@ _DEFUN(asiprintf, (strp, fmt),
|
||||
f._bf._size = f._w = 0;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _vfiprintf_r (_REENT, &f, fmt, ap);
|
||||
ret = _svfiprintf_r (_REENT, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret >= 0)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2007 Eric Blake
|
||||
/* Copyright (C) 2007, 2008 Eric Blake
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* is freely granted, provided that this notice is preserved.
|
||||
*/
|
||||
@ -48,7 +48,7 @@ _DEFUN(_asniprintf_r, (ptr, buf, lenp, fmt),
|
||||
f._bf._size = f._w = len;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _vfiprintf_r (ptr, &f, fmt, ap);
|
||||
ret = _svfiprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
@ -95,7 +95,7 @@ _DEFUN(asniprintf, (buf, lenp, fmt),
|
||||
f._bf._size = f._w = len;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _vfiprintf_r (ptr, &f, fmt, ap);
|
||||
ret = _svfiprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2007 Eric Blake
|
||||
/* Copyright (C) 2007, 2008 Eric Blake
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* is freely granted, provided that this notice is preserved.
|
||||
*/
|
||||
@ -48,7 +48,7 @@ _DEFUN(_asnprintf_r, (ptr, buf, lenp, fmt),
|
||||
f._bf._size = f._w = len;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _vfprintf_r (ptr, &f, fmt, ap);
|
||||
ret = _svfprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
@ -95,7 +95,7 @@ _DEFUN(asnprintf, (buf, lenp, fmt),
|
||||
f._bf._size = f._w = len;
|
||||
f._file = -1; /* No file. */
|
||||
va_start (ap, fmt);
|
||||
ret = _vfprintf_r (ptr, &f, fmt, ap);
|
||||
ret = _svfprintf_r (ptr, &f, fmt, ap);
|
||||
va_end (ap);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2007 Eric Blake
|
||||
/* Copyright (C) 2007, 2008 Eric Blake
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* is freely granted, provided that this notice is preserved.
|
||||
*/
|
||||
@ -47,7 +47,7 @@ _DEFUN(_vasniprintf_r, (ptr, buf, lenp, fmt, ap),
|
||||
}
|
||||
f._bf._size = f._w = len;
|
||||
f._file = -1; /* No file. */
|
||||
ret = _vfiprintf_r (ptr, &f, fmt, ap);
|
||||
ret = _svfiprintf_r (ptr, &f, fmt, ap);
|
||||
if (ret < 0)
|
||||
return NULL;
|
||||
*lenp = ret;
|
||||
|
@ -226,12 +226,12 @@ _DEFUN(__sprint_r, (ptr, fp, uio),
|
||||
if (!str) {
|
||||
/* Free unneeded buffer. */
|
||||
_free_r (ptr, fp->_bf._base);
|
||||
/* Ensure correct errno, even if free
|
||||
/* Ensure correct errno, even if free
|
||||
* changed it. */
|
||||
ptr->_errno = ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
fp->_bf._base = str;
|
||||
fp->_p = str + curpos;
|
||||
fp->_bf._size = newsize;
|
||||
@ -259,7 +259,7 @@ err:
|
||||
return EOF;
|
||||
}
|
||||
|
||||
#else /* !STRING_ONLY */
|
||||
#else /* !STRING_ONLY */
|
||||
/*
|
||||
* Flush out all the vectors defined by the given uio,
|
||||
* then reset it so that it can be reused.
|
||||
@ -425,8 +425,8 @@ union arg_val
|
||||
};
|
||||
|
||||
static union arg_val *
|
||||
_EXFUN(get_arg, (struct _reent *data, int n, char *fmt,
|
||||
va_list *ap, int *numargs, union arg_val *args,
|
||||
_EXFUN(get_arg, (struct _reent *data, int n, char *fmt,
|
||||
va_list *ap, int *numargs, union arg_val *args,
|
||||
int *arg_type, char **last_fmt));
|
||||
#endif /* !_NO_POS_ARGS */
|
||||
|
||||
@ -464,7 +464,7 @@ _EXFUN(get_arg, (struct _reent *data, int n, char *fmt,
|
||||
int _EXFUN(_VFPRINTF_R, (struct _reent *, FILE *, _CONST char *, va_list));
|
||||
|
||||
#ifndef STRING_ONLY
|
||||
int
|
||||
int
|
||||
_DEFUN(VFPRINTF, (fp, fmt0, ap),
|
||||
FILE * fp _AND
|
||||
_CONST char *fmt0 _AND
|
||||
@ -476,7 +476,7 @@ _DEFUN(VFPRINTF, (fp, fmt0, ap),
|
||||
}
|
||||
#endif /* STRING_ONLY */
|
||||
|
||||
int
|
||||
int
|
||||
_DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
|
||||
struct _reent *data _AND
|
||||
FILE * fp _AND
|
||||
@ -629,7 +629,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
|
||||
|
||||
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
|
||||
if (cantwrite (data, fp)) {
|
||||
_funlockfile (fp);
|
||||
_funlockfile (fp);
|
||||
return (EOF);
|
||||
}
|
||||
|
||||
@ -639,6 +639,18 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
|
||||
_funlockfile (fp);
|
||||
return (__sbprintf (data, fp, fmt0, ap));
|
||||
}
|
||||
#else /* STRING_ONLY */
|
||||
/* Create initial buffer if we are called by asprintf family. */
|
||||
if (fp->_flags & __SMBF && !fp->_bf._base)
|
||||
{
|
||||
fp->_bf._base = fp->_p = _malloc_r (data, 64);
|
||||
if (!fp->_p)
|
||||
{
|
||||
data->_errno = ENOMEM;
|
||||
return EOF;
|
||||
}
|
||||
fp->_bf._size = 64;
|
||||
}
|
||||
#endif /* STRING_ONLY */
|
||||
|
||||
fmt = (char *)fmt0;
|
||||
@ -918,7 +930,7 @@ reswitch: switch (ch) {
|
||||
(wchar_t)GET_ARG (N, ap, wint_t),
|
||||
&ps)) == -1) {
|
||||
fp->_flags |= __SERR;
|
||||
goto error;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1096,7 +1108,7 @@ reswitch: switch (ch) {
|
||||
#ifndef _NO_LONGLONG
|
||||
if (flags & QUADINT)
|
||||
*GET_ARG (N, ap, quad_ptr_t) = ret;
|
||||
else
|
||||
else
|
||||
#endif
|
||||
if (flags & LONGINT)
|
||||
*GET_ARG (N, ap, long_ptr_t) = ret;
|
||||
@ -1602,7 +1614,7 @@ exponent(char *p0, int exp, int fmtch)
|
||||
Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
|
||||
The name of Red Hat Incorporated may not be used to endorse
|
||||
or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
@ -1627,24 +1639,24 @@ typedef enum {
|
||||
DOT, /* '.' */
|
||||
STAR, /* '*' */
|
||||
FLAG, /* format flag */
|
||||
OTHER, /* all other chars */
|
||||
OTHER, /* all other chars */
|
||||
MAX_CH_CLASS /* place-holder */
|
||||
} CH_CLASS;
|
||||
|
||||
typedef enum {
|
||||
typedef enum {
|
||||
START, /* start */
|
||||
SFLAG, /* seen a flag */
|
||||
WDIG, /* seen digits in width area */
|
||||
WIDTH, /* processed width */
|
||||
SMOD, /* seen spec modifier */
|
||||
SDOT, /* seen dot */
|
||||
SDOT, /* seen dot */
|
||||
VARW, /* have variable width specifier */
|
||||
VARP, /* have variable precision specifier */
|
||||
PREC, /* processed precision */
|
||||
VWDIG, /* have digits in variable width specification */
|
||||
VPDIG, /* have digits in variable precision specification */
|
||||
DONE, /* done */
|
||||
MAX_STATE, /* place-holder */
|
||||
DONE, /* done */
|
||||
MAX_STATE, /* place-holder */
|
||||
} STATE;
|
||||
|
||||
typedef enum {
|
||||
@ -1669,7 +1681,7 @@ _CONST static CH_CLASS chclass[256] = {
|
||||
/* 30-37 */ ZERO, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT,
|
||||
/* 38-3f */ DIGIT, DIGIT, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
|
||||
/* 40-47 */ OTHER, SPEC, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC,
|
||||
/* 48-4f */ OTHER, OTHER, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC,
|
||||
/* 48-4f */ OTHER, OTHER, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC,
|
||||
/* 50-57 */ OTHER, OTHER, OTHER, SPEC, OTHER, SPEC, OTHER, OTHER,
|
||||
/* 58-5f */ SPEC, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER,
|
||||
/* 60-67 */ OTHER, SPEC, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC,
|
||||
@ -1695,7 +1707,7 @@ _CONST static CH_CLASS chclass[256] = {
|
||||
};
|
||||
|
||||
_CONST static STATE state_table[MAX_STATE][MAX_CH_CLASS] = {
|
||||
/* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */
|
||||
/* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */
|
||||
/* START */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE },
|
||||
/* SFLAG */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE },
|
||||
/* WDIG */ { DONE, DONE, WIDTH, SMOD, DONE, SDOT, DONE, DONE, DONE },
|
||||
@ -1710,7 +1722,7 @@ _CONST static STATE state_table[MAX_STATE][MAX_CH_CLASS] = {
|
||||
};
|
||||
|
||||
_CONST static ACTION action_table[MAX_STATE][MAX_CH_CLASS] = {
|
||||
/* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */
|
||||
/* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */
|
||||
/* START */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
|
||||
/* SFLAG */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
|
||||
/* WDIG */ { NOOP, NOOP, GETPOS, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP },
|
||||
@ -1766,10 +1778,10 @@ _DEFUN(get_arg, (data, n, fmt, ap, numargs_p, args, arg_type, last_fmt),
|
||||
while (*fmt && n >= numargs)
|
||||
{
|
||||
# ifdef _MB_CAPABLE
|
||||
while ((nbytes = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0)
|
||||
while ((nbytes = _mbtowc_r (data, &wc, fmt, MB_CUR_MAX, &wc_state)) > 0)
|
||||
{
|
||||
fmt += nbytes;
|
||||
if (wc == '%')
|
||||
if (wc == '%')
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1990, 2007 The Regents of the University of California.
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
@ -61,7 +61,7 @@ _DEFUN(_vsnprintf_r, (ptr, str, size, fmt, ap),
|
||||
f._bf._base = f._p = (unsigned char *) str;
|
||||
f._bf._size = f._w = (size > 0 ? size - 1 : 0);
|
||||
f._file = -1; /* No file. */
|
||||
ret = _vfprintf_r (ptr, &f, fmt, ap);
|
||||
ret = _svfprintf_r (ptr, &f, fmt, ap);
|
||||
if (ret < EOF)
|
||||
ptr->_errno = EOVERFLOW;
|
||||
if (size > 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user