mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
vfprintf: Introduce THOUSANDS_SEP_T
This avoids preprocessor conditionals in function declarations.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2015-03-06 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* stdio-common/vfprintf.c (THOUSANDS_SEP_T): New typedef.
|
||||||
|
(group_number, vfprintf): Use it.
|
||||||
|
|
||||||
2015-03-06 Rical Jasan <ricaljasan@pacific.net>
|
2015-03-06 Rical Jasan <ricaljasan@pacific.net>
|
||||||
|
|
||||||
* manual/errno.texi (Error Messages): Complete example function
|
* manual/errno.texi (Error Messages): Complete example function
|
||||||
|
@ -81,6 +81,7 @@
|
|||||||
# define CHAR_T char
|
# define CHAR_T char
|
||||||
# define UCHAR_T unsigned char
|
# define UCHAR_T unsigned char
|
||||||
# define INT_T int
|
# define INT_T int
|
||||||
|
typedef const char *THOUSANDS_SEP_T;
|
||||||
# define L_(Str) Str
|
# define L_(Str) Str
|
||||||
# define ISDIGIT(Ch) ((unsigned int) ((Ch) - '0') < 10)
|
# define ISDIGIT(Ch) ((unsigned int) ((Ch) - '0') < 10)
|
||||||
# define STR_LEN(Str) strlen (Str)
|
# define STR_LEN(Str) strlen (Str)
|
||||||
@ -108,6 +109,7 @@
|
|||||||
/* This is a hack!!! There should be a type uwchar_t. */
|
/* This is a hack!!! There should be a type uwchar_t. */
|
||||||
# define UCHAR_T unsigned int /* uwchar_t */
|
# define UCHAR_T unsigned int /* uwchar_t */
|
||||||
# define INT_T wint_t
|
# define INT_T wint_t
|
||||||
|
typedef wchar_t THOUSANDS_SEP_T;
|
||||||
# define L_(Str) L##Str
|
# define L_(Str) L##Str
|
||||||
# define ISDIGIT(Ch) ((unsigned int) ((Ch) - L'0') < 10)
|
# define ISDIGIT(Ch) ((unsigned int) ((Ch) - L'0') < 10)
|
||||||
# define STR_LEN(Str) __wcslen (Str)
|
# define STR_LEN(Str) __wcslen (Str)
|
||||||
@ -207,25 +209,15 @@ static int printf_unknown (FILE *, const struct printf_info *,
|
|||||||
const void *const *) __THROW;
|
const void *const *) __THROW;
|
||||||
|
|
||||||
/* Group digits of number string. */
|
/* Group digits of number string. */
|
||||||
#ifdef COMPILE_WPRINTF
|
static CHAR_T *group_number (CHAR_T *, CHAR_T *, const char *, THOUSANDS_SEP_T)
|
||||||
static CHAR_T *group_number (CHAR_T *, CHAR_T *, const char *, wchar_t)
|
|
||||||
__THROW internal_function;
|
__THROW internal_function;
|
||||||
#else
|
|
||||||
static CHAR_T *group_number (CHAR_T *, CHAR_T *, const char *, const char *)
|
|
||||||
__THROW internal_function;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* The function itself. */
|
/* The function itself. */
|
||||||
int
|
int
|
||||||
vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||||
{
|
{
|
||||||
/* The character used as thousands separator. */
|
/* The character used as thousands separator. */
|
||||||
#ifdef COMPILE_WPRINTF
|
THOUSANDS_SEP_T thousands_sep = 0;
|
||||||
wchar_t thousands_sep = L'\0';
|
|
||||||
#else
|
|
||||||
const char *thousands_sep = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The string describing the size of groups of digits. */
|
/* The string describing the size of groups of digits. */
|
||||||
const char *grouping;
|
const char *grouping;
|
||||||
@ -2150,12 +2142,7 @@ printf_unknown (FILE *s, const struct printf_info *info,
|
|||||||
static CHAR_T *
|
static CHAR_T *
|
||||||
internal_function
|
internal_function
|
||||||
group_number (CHAR_T *w, CHAR_T *rear_ptr, const char *grouping,
|
group_number (CHAR_T *w, CHAR_T *rear_ptr, const char *grouping,
|
||||||
#ifdef COMPILE_WPRINTF
|
THOUSANDS_SEP_T thousands_sep)
|
||||||
wchar_t thousands_sep
|
|
||||||
#else
|
|
||||||
const char *thousands_sep
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
CHAR_T *src, *s;
|
CHAR_T *src, *s;
|
||||||
|
Reference in New Issue
Block a user