Update gnulib.
* lib/Makefile.am, lib/alloca.in.h, lib/argmatch.c, lib/argmatch.h, lib/argp-ba.c, lib/argp-eexst.c, lib/argp-fmtstream.c, lib/argp-fmtstream.h, lib/argp-fs-xinl.c, lib/argp-help.c, lib/argp-namefrob.h, lib/argp-parse.c, lib/argp-pin.c, lib/argp-pv.c, lib/argp-pvh.c, lib/argp-xinl.c, lib/argp.h, lib/asnprintf.c, lib/basename-lgpl.c, lib/c-ctype.c, lib/c-ctype.h, lib/c-strcase.h, lib/c-strcasecmp.c, lib/c-strcaseeq.h, lib/c-strncasecmp.c, lib/config.charset, lib/dirname-lgpl.c, lib/dirname.h, lib/dosname.h, lib/errno.in.h, lib/error.c, lib/error.h, lib/exitfail.c, lib/exitfail.h, lib/fcntl.in.h, lib/float+.h, lib/float.c, lib/float.in.h, lib/getopt.c, lib/getopt.in.h, lib/getopt1.c, lib/getopt_int.h, lib/gettext.h, lib/gettimeofday.c, lib/intprops.h, lib/isatty.c, lib/itold.c, lib/localcharset.c, lib/localcharset.h, lib/lstat.c, lib/malloc.c, lib/mbrtowc.c, lib/mbsinit.c, lib/memchr.c, lib/mempcpy.c, lib/mkstemp.c, lib/mkstemps.c, lib/msvc-inval.c, lib/msvc-inval.h, lib/msvc-nothrow.c, lib/msvc-nothrow.h, lib/pathmax.h, lib/printf-args.c, lib/printf-args.h, lib/printf-parse.c, lib/printf-parse.h, lib/progname.c, lib/progname.h, lib/quote.h, lib/quotearg.c, lib/quotearg.h, lib/rawmemchr.c, lib/ref-add.sin, lib/ref-del.sin, lib/secure_getenv.c, lib/size_max.h, lib/sleep.c, lib/stat.c, lib/stdalign.in.h, lib/stdbool.in.h, lib/stddef.in.h, lib/stdint.in.h, lib/stdio.in.h, lib/stdlib.in.h, lib/stpcpy.c, lib/strcasecmp.c, lib/strchrnul.c, lib/streq.h, lib/strerror-override.c, lib/strerror-override.h, lib/strerror.c, lib/string.in.h, lib/strings.in.h, lib/stripslash.c, lib/strncasecmp.c, lib/strndup.c, lib/strnlen.c, lib/strverscmp.c, lib/sys_stat.in.h, lib/sys_time.in.h, lib/sys_types.in.h, lib/sys_wait.in.h, lib/sysexits.in.h, lib/tempname.c, lib/tempname.h, lib/time.in.h, lib/unistd.c, lib/unistd.in.h, lib/vasnprintf.c, lib/vasnprintf.h, lib/verify.h, lib/vsnprintf.c, lib/wchar.in.h, lib/wctype.in.h, lib/xalloc-die.c, lib/xalloc-oversized.h, lib/xalloc.h, lib/xmalloc.c, lib/xsize.h, m4/00gnulib.m4, m4/absolute-header.m4, m4/alloca.m4, m4/argp.m4, m4/codeset.m4, m4/configmake.m4, m4/dirname.m4, m4/double-slash-root.m4, m4/errno_h.m4, m4/error.m4, m4/exponentd.m4, m4/extensions.m4, m4/extern-inline.m4, m4/fcntl-o.m4, m4/fcntl_h.m4, m4/float_h.m4, m4/getopt.m4, m4/gettimeofday.m4, m4/glibc21.m4, m4/gnulib-cache.m4, m4/gnulib-common.m4, m4/gnulib-comp.m4, m4/gnulib-tool.m4, m4/include_next.m4, m4/intmax_t.m4, m4/inttypes_h.m4, m4/isatty.m4, m4/largefile.m4, m4/localcharset.m4, m4/locale-fr.m4, m4/locale-ja.m4, m4/locale-zh.m4, m4/longlong.m4, m4/lstat.m4, m4/malloc.m4, m4/math_h.m4, m4/mbrtowc.m4, m4/mbsinit.m4, m4/mbstate_t.m4, m4/memchr.m4, m4/mempcpy.m4, m4/mkstemp.m4, m4/mkstemps.m4, m4/mmap-anon.m4, m4/msvc-inval.m4, m4/msvc-nothrow.m4, m4/multiarch.m4, m4/nocrash.m4, m4/off_t.m4, m4/pathmax.m4, m4/printf.m4, m4/quote.m4, m4/quotearg.m4, m4/rawmemchr.m4, m4/secure_getenv.m4, m4/size_max.m4, m4/sleep.m4, m4/ssize_t.m4, m4/stat.m4, m4/stdalign.m4, m4/stdbool.m4, m4/stddef_h.m4, m4/stdint.m4, m4/stdint_h.m4, m4/stdio_h.m4, m4/stdlib_h.m4, m4/stpcpy.m4, m4/strcase.m4, m4/strchrnul.m4, m4/strerror.m4, m4/string_h.m4, m4/strings_h.m4, m4/strndup.m4, m4/strnlen.m4, m4/strverscmp.m4, m4/sys_socket_h.m4, m4/sys_stat_h.m4, m4/sys_time_h.m4, m4/sys_types_h.m4, m4/sys_wait_h.m4, m4/sysexits.m4, m4/tempname.m4, m4/time_h.m4, m4/unistd_h.m4, m4/vasnprintf.m4, m4/vsnprintf.m4, m4/warn-on-use.m4, m4/wchar_h.m4, m4/wchar_t.m4, m4/wctype_h.m4, m4/wint_t.m4, m4/xalloc.m4, m4/xsize.m4, tools/snippet/arg-nonnull.h, tools/snippet/c++defs.h, tools/snippet/warn-on-use.h: Update.
This commit is contained in:
parent
e206b5ef33
commit
4a7733823e
215 changed files with 1609 additions and 1210 deletions
199
lib/vasnprintf.c
199
lib/vasnprintf.c
|
|
@ -1,5 +1,5 @@
|
|||
/* vsprintf with automatic memory allocation.
|
||||
Copyright (C) 1999, 2002-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2002-2015 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
|
||||
|
|
@ -1886,7 +1886,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
else
|
||||
{
|
||||
do
|
||||
result[length++] = (unsigned char) *cp++;
|
||||
result[length++] = *cp++;
|
||||
while (--n > 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1957,15 +1957,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
|
||||
abort ();
|
||||
arg = a.arg[dp->width_arg_index].a.a_int;
|
||||
width = arg;
|
||||
if (arg < 0)
|
||||
{
|
||||
/* "A negative field width is taken as a '-' flag
|
||||
followed by a positive field width." */
|
||||
flags |= FLAG_LEFT;
|
||||
width = (unsigned int) (-arg);
|
||||
width = -width;
|
||||
}
|
||||
else
|
||||
width = arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2073,8 +2072,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
characters = 0;
|
||||
}
|
||||
|
||||
if (has_width && width > characters
|
||||
&& !(dp->flags & FLAG_LEFT))
|
||||
if (characters < width && !(dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - characters;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2127,8 +2125,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
}
|
||||
# endif
|
||||
|
||||
if (has_width && width > characters
|
||||
&& (dp->flags & FLAG_LEFT))
|
||||
if (characters < width && (dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - characters;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2201,8 +2198,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
characters = 0;
|
||||
}
|
||||
|
||||
if (has_width && width > characters
|
||||
&& !(dp->flags & FLAG_LEFT))
|
||||
if (characters < width && !(dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - characters;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2255,8 +2251,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
}
|
||||
# endif
|
||||
|
||||
if (has_width && width > characters
|
||||
&& (dp->flags & FLAG_LEFT))
|
||||
if (characters < width && (dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - characters;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2329,8 +2324,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
characters = 0;
|
||||
}
|
||||
|
||||
if (has_width && width > characters
|
||||
&& !(dp->flags & FLAG_LEFT))
|
||||
if (characters < width && !(dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - characters;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2383,8 +2377,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
}
|
||||
# endif
|
||||
|
||||
if (has_width && width > characters
|
||||
&& (dp->flags & FLAG_LEFT))
|
||||
if (characters < width && (dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - characters;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2435,15 +2428,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
|
||||
abort ();
|
||||
arg = a.arg[dp->width_arg_index].a.a_int;
|
||||
width = arg;
|
||||
if (arg < 0)
|
||||
{
|
||||
/* "A negative field width is taken as a '-' flag
|
||||
followed by a positive field width." */
|
||||
flags |= FLAG_LEFT;
|
||||
width = (unsigned int) (-arg);
|
||||
width = -width;
|
||||
}
|
||||
else
|
||||
width = arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2573,8 +2565,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
characters = 0;
|
||||
}
|
||||
|
||||
if (has_width && width > characters
|
||||
&& !(dp->flags & FLAG_LEFT))
|
||||
if (characters < width && !(dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - characters;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2635,8 +2626,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
}
|
||||
}
|
||||
|
||||
if (has_width && width > characters
|
||||
&& (dp->flags & FLAG_LEFT))
|
||||
if (characters < width && (dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - characters;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2827,8 +2817,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
/* w doesn't matter. */
|
||||
w = 0;
|
||||
|
||||
if (has_width && width > w
|
||||
&& !(dp->flags & FLAG_LEFT))
|
||||
if (w < width && !(dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - w;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2911,8 +2900,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
length += tmpdst_len;
|
||||
# endif
|
||||
|
||||
if (has_width && width > w
|
||||
&& (dp->flags & FLAG_LEFT))
|
||||
if (w < width && (dp->flags & FLAG_LEFT))
|
||||
{
|
||||
size_t n = width - w;
|
||||
ENSURE_ALLOCATION (xsum (length, n));
|
||||
|
|
@ -2939,17 +2927,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
{
|
||||
arg_type type = a.arg[dp->arg_index].type;
|
||||
int flags = dp->flags;
|
||||
int has_width;
|
||||
size_t width;
|
||||
int has_precision;
|
||||
size_t precision;
|
||||
size_t tmp_length;
|
||||
size_t count;
|
||||
DCHAR_T tmpbuf[700];
|
||||
DCHAR_T *tmp;
|
||||
DCHAR_T *pad_ptr;
|
||||
DCHAR_T *p;
|
||||
|
||||
has_width = 0;
|
||||
width = 0;
|
||||
if (dp->width_start != dp->width_end)
|
||||
{
|
||||
|
|
@ -2960,15 +2947,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
|
||||
abort ();
|
||||
arg = a.arg[dp->width_arg_index].a.a_int;
|
||||
width = arg;
|
||||
if (arg < 0)
|
||||
{
|
||||
/* "A negative field width is taken as a '-' flag
|
||||
followed by a positive field width." */
|
||||
flags |= FLAG_LEFT;
|
||||
width = (unsigned int) (-arg);
|
||||
width = -width;
|
||||
}
|
||||
else
|
||||
width = arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2978,7 +2964,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
width = xsum (xtimes (width, 10), *digitp++ - '0');
|
||||
while (digitp != dp->width_end);
|
||||
}
|
||||
has_width = 1;
|
||||
}
|
||||
|
||||
has_precision = 0;
|
||||
|
|
@ -3354,11 +3339,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
abort ();
|
||||
# endif
|
||||
}
|
||||
|
||||
/* The generated string now extends from tmp to p, with the
|
||||
zero padding insertion point being at pad_ptr. */
|
||||
if (has_width && p - tmp < width)
|
||||
count = p - tmp;
|
||||
|
||||
if (count < width)
|
||||
{
|
||||
size_t pad = width - (p - tmp);
|
||||
size_t pad = width - count;
|
||||
DCHAR_T *end = p + pad;
|
||||
|
||||
if (flags & FLAG_LEFT)
|
||||
|
|
@ -3391,28 +3379,26 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
p = end;
|
||||
}
|
||||
|
||||
{
|
||||
size_t count = p - tmp;
|
||||
count = p - tmp;
|
||||
|
||||
if (count >= tmp_length)
|
||||
/* tmp_length was incorrectly calculated - fix the
|
||||
code above! */
|
||||
abort ();
|
||||
if (count >= tmp_length)
|
||||
/* tmp_length was incorrectly calculated - fix the
|
||||
code above! */
|
||||
abort ();
|
||||
|
||||
/* Make room for the result. */
|
||||
if (count >= allocated - length)
|
||||
{
|
||||
size_t n = xsum (length, count);
|
||||
/* Make room for the result. */
|
||||
if (count >= allocated - length)
|
||||
{
|
||||
size_t n = xsum (length, count);
|
||||
|
||||
ENSURE_ALLOCATION (n);
|
||||
}
|
||||
ENSURE_ALLOCATION (n);
|
||||
}
|
||||
|
||||
/* Append the result. */
|
||||
memcpy (result + length, tmp, count * sizeof (DCHAR_T));
|
||||
if (tmp != tmpbuf)
|
||||
free (tmp);
|
||||
length += count;
|
||||
}
|
||||
/* Append the result. */
|
||||
memcpy (result + length, tmp, count * sizeof (DCHAR_T));
|
||||
if (tmp != tmpbuf)
|
||||
free (tmp);
|
||||
length += count;
|
||||
}
|
||||
#endif
|
||||
#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
|
||||
|
|
@ -3446,8 +3432,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
arg_type type = a.arg[dp->arg_index].type;
|
||||
# endif
|
||||
int flags = dp->flags;
|
||||
int has_width;
|
||||
size_t width;
|
||||
size_t count;
|
||||
int has_precision;
|
||||
size_t precision;
|
||||
size_t tmp_length;
|
||||
|
|
@ -3456,7 +3442,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
DCHAR_T *pad_ptr;
|
||||
DCHAR_T *p;
|
||||
|
||||
has_width = 0;
|
||||
width = 0;
|
||||
if (dp->width_start != dp->width_end)
|
||||
{
|
||||
|
|
@ -3467,15 +3452,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
|
||||
abort ();
|
||||
arg = a.arg[dp->width_arg_index].a.a_int;
|
||||
width = arg;
|
||||
if (arg < 0)
|
||||
{
|
||||
/* "A negative field width is taken as a '-' flag
|
||||
followed by a positive field width." */
|
||||
flags |= FLAG_LEFT;
|
||||
width = (unsigned int) (-arg);
|
||||
width = -width;
|
||||
}
|
||||
else
|
||||
width = arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3485,7 +3469,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
width = xsum (xtimes (width, 10), *digitp++ - '0');
|
||||
while (digitp != dp->width_end);
|
||||
}
|
||||
has_width = 1;
|
||||
}
|
||||
|
||||
has_precision = 0;
|
||||
|
|
@ -3925,9 +3908,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
digits without trailing zeroes. */
|
||||
if (exponent >= 0)
|
||||
{
|
||||
size_t count = exponent + 1;
|
||||
size_t ecount = exponent + 1;
|
||||
/* Note: count <= precision = ndigits. */
|
||||
for (; count > 0; count--)
|
||||
for (; ecount > 0; ecount--)
|
||||
*p++ = digits[--ndigits];
|
||||
if ((flags & FLAG_ALT) || ndigits > nzeroes)
|
||||
{
|
||||
|
|
@ -3941,10 +3924,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
}
|
||||
else
|
||||
{
|
||||
size_t count = -exponent - 1;
|
||||
size_t ecount = -exponent - 1;
|
||||
*p++ = '0';
|
||||
*p++ = decimal_point_char ();
|
||||
for (; count > 0; count--)
|
||||
for (; ecount > 0; ecount--)
|
||||
*p++ = '0';
|
||||
while (ndigits > nzeroes)
|
||||
{
|
||||
|
|
@ -4395,9 +4378,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
digits without trailing zeroes. */
|
||||
if (exponent >= 0)
|
||||
{
|
||||
size_t count = exponent + 1;
|
||||
/* Note: count <= precision = ndigits. */
|
||||
for (; count > 0; count--)
|
||||
size_t ecount = exponent + 1;
|
||||
/* Note: ecount <= precision = ndigits. */
|
||||
for (; ecount > 0; ecount--)
|
||||
*p++ = digits[--ndigits];
|
||||
if ((flags & FLAG_ALT) || ndigits > nzeroes)
|
||||
{
|
||||
|
|
@ -4411,10 +4394,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
}
|
||||
else
|
||||
{
|
||||
size_t count = -exponent - 1;
|
||||
size_t ecount = -exponent - 1;
|
||||
*p++ = '0';
|
||||
*p++ = decimal_point_char ();
|
||||
for (; count > 0; count--)
|
||||
for (; ecount > 0; ecount--)
|
||||
*p++ = '0';
|
||||
while (ndigits > nzeroes)
|
||||
{
|
||||
|
|
@ -4542,9 +4525,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
|
||||
/* The generated string now extends from tmp to p, with the
|
||||
zero padding insertion point being at pad_ptr. */
|
||||
if (has_width && p - tmp < width)
|
||||
count = p - tmp;
|
||||
|
||||
if (count < width)
|
||||
{
|
||||
size_t pad = width - (p - tmp);
|
||||
size_t pad = width - count;
|
||||
DCHAR_T *end = p + pad;
|
||||
|
||||
if (flags & FLAG_LEFT)
|
||||
|
|
@ -4577,36 +4562,36 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
p = end;
|
||||
}
|
||||
|
||||
{
|
||||
size_t count = p - tmp;
|
||||
count = p - tmp;
|
||||
|
||||
if (count >= tmp_length)
|
||||
/* tmp_length was incorrectly calculated - fix the
|
||||
code above! */
|
||||
abort ();
|
||||
if (count >= tmp_length)
|
||||
/* tmp_length was incorrectly calculated - fix the
|
||||
code above! */
|
||||
abort ();
|
||||
|
||||
/* Make room for the result. */
|
||||
if (count >= allocated - length)
|
||||
{
|
||||
size_t n = xsum (length, count);
|
||||
/* Make room for the result. */
|
||||
if (count >= allocated - length)
|
||||
{
|
||||
size_t n = xsum (length, count);
|
||||
|
||||
ENSURE_ALLOCATION (n);
|
||||
}
|
||||
ENSURE_ALLOCATION (n);
|
||||
}
|
||||
|
||||
/* Append the result. */
|
||||
memcpy (result + length, tmp, count * sizeof (DCHAR_T));
|
||||
if (tmp != tmpbuf)
|
||||
free (tmp);
|
||||
length += count;
|
||||
}
|
||||
/* Append the result. */
|
||||
memcpy (result + length, tmp, count * sizeof (DCHAR_T));
|
||||
if (tmp != tmpbuf)
|
||||
free (tmp);
|
||||
length += count;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
arg_type type = a.arg[dp->arg_index].type;
|
||||
int flags = dp->flags;
|
||||
#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
|
||||
#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
|
||||
int has_width;
|
||||
#endif
|
||||
#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
|
||||
size_t width;
|
||||
#endif
|
||||
#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
|
||||
|
|
@ -4635,8 +4620,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
TCHAR_T *tmp;
|
||||
#endif
|
||||
|
||||
#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
|
||||
#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
|
||||
has_width = 0;
|
||||
#endif
|
||||
#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
|
||||
width = 0;
|
||||
if (dp->width_start != dp->width_end)
|
||||
{
|
||||
|
|
@ -4647,15 +4634,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
|
||||
abort ();
|
||||
arg = a.arg[dp->width_arg_index].a.a_int;
|
||||
width = arg;
|
||||
if (arg < 0)
|
||||
{
|
||||
/* "A negative field width is taken as a '-' flag
|
||||
followed by a positive field width." */
|
||||
flags |= FLAG_LEFT;
|
||||
width = (unsigned int) (-arg);
|
||||
width = -width;
|
||||
}
|
||||
else
|
||||
width = arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -4665,7 +4651,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
width = xsum (xtimes (width, 10), *digitp++ - '0');
|
||||
while (digitp != dp->width_end);
|
||||
}
|
||||
#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
|
||||
has_width = 1;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -4805,7 +4793,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
{
|
||||
const FCHAR_T *mp = dp->width_start;
|
||||
do
|
||||
*fbp++ = (unsigned char) *mp++;
|
||||
*fbp++ = *mp++;
|
||||
while (--n > 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -4826,7 +4814,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
{
|
||||
const FCHAR_T *mp = dp->precision_start;
|
||||
do
|
||||
*fbp++ = (unsigned char) *mp++;
|
||||
*fbp++ = *mp++;
|
||||
while (--n > 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -5153,7 +5141,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
size_t tmp_length =
|
||||
MAX_ROOM_NEEDED (&a, dp->arg_index,
|
||||
dp->conversion, type, flags,
|
||||
has_width ? width : 0,
|
||||
width,
|
||||
has_precision,
|
||||
precision, pad_ourselves);
|
||||
|
||||
|
|
@ -5191,18 +5179,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
/* SNPRINTF or sprintf failed. Save and use the errno
|
||||
that it has set, if any. */
|
||||
int saved_errno = errno;
|
||||
if (saved_errno == 0)
|
||||
{
|
||||
if (dp->conversion == 'c' || dp->conversion == 's')
|
||||
saved_errno = EILSEQ;
|
||||
else
|
||||
saved_errno = EINVAL;
|
||||
}
|
||||
|
||||
if (!(result == resultbuf || result == NULL))
|
||||
free (result);
|
||||
if (buf_malloced != NULL)
|
||||
free (buf_malloced);
|
||||
CLEANUP ();
|
||||
errno =
|
||||
(saved_errno != 0
|
||||
? saved_errno
|
||||
: (dp->conversion == 'c' || dp->conversion == 's'
|
||||
? EILSEQ
|
||||
: EINVAL));
|
||||
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -5391,7 +5382,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
tmpsrc += count;
|
||||
tmpdst += count;
|
||||
for (n = count; n > 0; n--)
|
||||
*--tmpdst = (unsigned char) *--tmpsrc;
|
||||
*--tmpdst = *--tmpsrc;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue