* stdio-common/printf-parse.h: Include string.h and wchar.h.

(__find_specwc): Change into __extern_always_inline function.
	(__find_specmb): Likewise.  Remove ps argument.  Use __strchrnul.
	(__parse_one_specmb): Remove ps argument.
	* stdio-common/vfprintf.c (vfprintf): Remove mbstate variable.
	Adjust __find_specmb and __parse_one_specmb callers.
	* stdio-common/printf-prs.c (parse_printf_format): Likewise.
	* stdio-common/printf-parsemb.c (__find_specwc, __find_specmb):
	Removed.
	(__parse_one_specmb): Remove ps argument, adjust __find_specmb
	caller.
This commit is contained in:
Ulrich Drepper 2007-10-10 20:14:12 +00:00
parent 59d430c680
commit c06b7169e4
5 changed files with 38 additions and 56 deletions

View File

@ -1,3 +1,17 @@
2007-10-10 Jakub Jelinek <jakub@redhat.com>
* stdio-common/printf-parse.h: Include string.h and wchar.h.
(__find_specwc): Change into __extern_always_inline function.
(__find_specmb): Likewise. Remove ps argument. Use __strchrnul.
(__parse_one_specmb): Remove ps argument.
* stdio-common/vfprintf.c (vfprintf): Remove mbstate variable.
Adjust __find_specmb and __parse_one_specmb callers.
* stdio-common/printf-prs.c (parse_printf_format): Likewise.
* stdio-common/printf-parsemb.c (__find_specwc, __find_specmb):
Removed.
(__parse_one_specmb): Remove ps argument, adjust __find_specmb
caller.
2007-10-09 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/cacheinfo.c (init_cacheinfo): Work around problem

View File

@ -1,5 +1,6 @@
/* Internal header for parsing printf format strings.
Copyright (C) 1995-1999, 2000, 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 1995-1999, 2000, 2002, 2003, 2007
Free Software Foundation, Inc.
This file is part of th GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -20,6 +21,8 @@
#include <printf.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <wchar.h>
struct printf_spec
@ -86,11 +89,17 @@ extern printf_function **__printf_function_table attribute_hidden;
/* Find the next spec in FORMAT, or the end of the string. Returns
a pointer into FORMAT, to a '%' or a '\0'. */
extern const unsigned char *__find_specmb (const UCHAR_T *format,
mbstate_t *ps) attribute_hidden;
__extern_always_inline const unsigned char *
__find_specmb (const unsigned char *format)
{
return (const unsigned char *) __strchrnul ((const char *) format, '%');
}
extern const unsigned int *__find_specwc (const UCHAR_T *format)
attribute_hidden;
__extern_always_inline const unsigned int *
__find_specwc (const unsigned int *format)
{
return (const unsigned int *) __wcschrnul ((const wchar_t *) format, L'%');
}
/* FORMAT must point to a '%' at the beginning of a spec. Fills in *SPEC
@ -100,8 +109,7 @@ extern const unsigned int *__find_specwc (const UCHAR_T *format)
remains the highest argument index used. */
extern size_t __parse_one_specmb (const unsigned char *format, size_t posn,
struct printf_spec *spec,
size_t *max_ref_arg, mbstate_t *ps)
attribute_hidden;
size_t *max_ref_arg) attribute_hidden;
extern size_t __parse_one_specwc (const unsigned int *format, size_t posn,
struct printf_spec *spec,

View File

@ -46,35 +46,6 @@
/* Find the next spec in FORMAT, or the end of the string. Returns
a pointer into FORMAT, to a '%' or a '\0'. */
const UCHAR_T *
#ifdef COMPILE_WPRINTF
__find_specwc (const UCHAR_T *format)
#else
__find_specmb (const UCHAR_T *format, mbstate_t *ps)
#endif
{
#ifdef COMPILE_WPRINTF
return (const UCHAR_T *) __wcschrnul ((const CHAR_T *) format, L'%');
#else
while (*format != L_('\0') && *format != L_('%'))
{
int len;
/* Remove any hints of a wrong encoding. */
ps->__count = 0;
if (! isascii (*format)
&& (len = __mbrlen ((const CHAR_T *) format, MB_CUR_MAX, ps)) > 0)
format += len;
else
++format;
}
return format;
#endif
}
/* FORMAT must point to a '%' at the beginning of a spec. Fills in *SPEC
with the parsed details. POSN is the number of arguments already
consumed. At most MAXTYPES - POSN types are filled in TYPES. Return
@ -87,8 +58,7 @@ __parse_one_specwc (const UCHAR_T *format, size_t posn,
struct printf_spec *spec, size_t *max_ref_arg)
#else
__parse_one_specmb (const UCHAR_T *format, size_t posn,
struct printf_spec *spec, size_t *max_ref_arg,
mbstate_t *ps)
struct printf_spec *spec, size_t *max_ref_arg)
#endif
{
unsigned int n;
@ -403,7 +373,7 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
#ifdef COMPILE_WPRINTF
spec->next_fmt = __find_specwc (format);
#else
spec->next_fmt = __find_specmb (format, ps);
spec->next_fmt = __find_specmb (format);
#endif
}

View File

@ -1,5 +1,5 @@
/* Copyright (C) 1991, 1992, 1995, 1996, 1999, 2000, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
/* Copyright (C) 1991, 1992, 1995, 1996, 1999, 2000, 2002, 2003, 2004, 2005,
2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -66,17 +66,16 @@ parse_printf_format (fmt, n, argtypes)
size_t nargs; /* Number of arguments. */
size_t max_ref_arg; /* Highest index used in a positional arg. */
struct printf_spec spec;
mbstate_t mbstate;
const unsigned char *f = (const unsigned char *) fmt;
nargs = 0;
max_ref_arg = 0;
/* Search for format specifications. */
for (f = __find_specmb (f, &mbstate); *f != '\0'; f = spec.next_fmt)
for (f = __find_specmb (f); *f != '\0'; f = spec.next_fmt)
{
/* Parse this spec. */
nargs += __parse_one_specmb (f, nargs, &spec, &max_ref_arg, &mbstate);
nargs += __parse_one_specmb (f, nargs, &spec, &max_ref_arg);
/* If the width is determined by an argument this is an int. */
if (spec.width_arg != -1 && (size_t) spec.width_arg < n)

View File

@ -209,11 +209,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
CHAR_T *workstart = NULL;
CHAR_T *workend;
/* State for restartable multibyte character handling functions. */
#ifndef COMPILE_WPRINTF
mbstate_t mbstate;
#endif
/* We have to save the original argument pointer. */
va_list ap_save;
@ -1294,11 +1289,8 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
/* Find the first format specifier. */
f = lead_str_end = __find_specwc ((const UCHAR_T *) format);
#else
/* Put state for processing format string in initial state. */
memset (&mbstate, '\0', sizeof (mbstate_t));
/* Find the first format specifier. */
f = lead_str_end = __find_specmb ((const UCHAR_T *) format, &mbstate);
f = lead_str_end = __find_specmb ((const UCHAR_T *) format);
#endif
/* Lock stream. */
@ -1591,7 +1583,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
#ifdef COMPILE_WPRINTF
f = __find_specwc ((end_of_spec = ++f));
#else
f = __find_specmb ((end_of_spec = ++f), &mbstate);
f = __find_specmb ((end_of_spec = ++f));
#endif
/* Write the following constant string. */
@ -1674,8 +1666,7 @@ do_positional:
#ifdef COMPILE_WPRINTF
nargs += __parse_one_specwc (f, nargs, &specs[nspecs], &max_ref_arg);
#else
nargs += __parse_one_specmb (f, nargs, &specs[nspecs], &max_ref_arg,
&mbstate);
nargs += __parse_one_specmb (f, nargs, &specs[nspecs], &max_ref_arg);
#endif
}