X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fprintf-parse.h;h=709cea8eed64cc4c1f2f13ec9d27d8cbb62904dd;hb=88236bad53d1dd5e6b8a592a724736bbd9db7851;hp=229693d27921a1758ced80f0a4c5e3345389a307;hpb=cce88f340d0244526f5aa5e183d257ece66ce6fc;p=gnulib.git diff --git a/lib/printf-parse.h b/lib/printf-parse.h index 229693d27..709cea8ee 100644 --- a/lib/printf-parse.h +++ b/lib/printf-parse.h @@ -1,5 +1,6 @@ /* Parse printf format string. - Copyright (C) 1999, 2002-2003, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2012 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 @@ -22,23 +23,33 @@ ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. STATIC Set to 'static' to declare the function static. */ +#if HAVE_FEATURES_H +# include /* for __GLIBC__, __UCLIBC__ */ +#endif + #include "printf-args.h" /* Flags */ -#define FLAG_GROUP 1 /* ' flag */ -#define FLAG_LEFT 2 /* - flag */ -#define FLAG_SHOWSIGN 4 /* + flag */ -#define FLAG_SPACE 8 /* space flag */ -#define FLAG_ALT 16 /* # flag */ -#define FLAG_ZERO 32 +#define FLAG_GROUP 1 /* ' flag */ +#define FLAG_LEFT 2 /* - flag */ +#define FLAG_SHOWSIGN 4 /* + flag */ +#define FLAG_SPACE 8 /* space flag */ +#define FLAG_ALT 16 /* # flag */ +#define FLAG_ZERO 32 +#if __GLIBC__ >= 2 && !defined __UCLIBC__ +# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */ +#endif /* arg_index value indicating that no argument is consumed. */ -#define ARG_NONE (~(size_t)0) +#define ARG_NONE (~(size_t)0) /* xxx_directive: A parsed directive. xxx_directives: A parsed format string. */ +/* Number of directly allocated directives (no malloc() needed). */ +#define N_DIRECT_ALLOC_DIRECTIVES 7 + /* A parsed directive. */ typedef struct { @@ -51,7 +62,7 @@ typedef struct const char* precision_start; const char* precision_end; size_t precision_arg_index; - char conversion; /* d i o u x X f e E g G c s p n U % but not C S */ + char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } char_directive; @@ -63,6 +74,7 @@ typedef struct char_directive *dir; size_t max_width_length; size_t max_precision_length; + char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; } char_directives; @@ -80,7 +92,7 @@ typedef struct const uint8_t* precision_start; const uint8_t* precision_end; size_t precision_arg_index; - uint8_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */ + uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u8_directive; @@ -92,6 +104,7 @@ typedef struct u8_directive *dir; size_t max_width_length; size_t max_precision_length; + u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; } u8_directives; @@ -107,7 +120,7 @@ typedef struct const uint16_t* precision_start; const uint16_t* precision_end; size_t precision_arg_index; - uint16_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */ + uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u16_directive; @@ -119,6 +132,7 @@ typedef struct u16_directive *dir; size_t max_width_length; size_t max_precision_length; + u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; } u16_directives; @@ -134,7 +148,7 @@ typedef struct const uint32_t* precision_start; const uint32_t* precision_end; size_t precision_arg_index; - uint32_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */ + uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u32_directive; @@ -146,6 +160,7 @@ typedef struct u32_directive *dir; size_t max_width_length; size_t max_precision_length; + u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES]; } u32_directives; @@ -163,10 +178,10 @@ extern int u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a); extern int u16_printf_parse (const uint16_t *format, u16_directives *d, - arguments *a); + arguments *a); extern int u32_printf_parse (const uint32_t *format, u32_directives *d, - arguments *a); + arguments *a); #else # ifdef STATIC STATIC