This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Patch for printf's "%If"
On Fri, 19 Dec 2003, Behdad Esfahbod wrote:
> Attached is the patch for gcc-3.3.2 (against Rawhide SRPM build
> actually) to understand %If. Moreover, I removed %Id and friends
> from scanf, as glibc does not support them yet. I will get into
> implementing that if there is no reason not to do that.
There certainly seems to be scanf code that sets and uses an I18N flag.
If this doesn't work, all the more need for documentation and glibc
testcases to show what is supported....
The code now in glibc looks like it supports the 'I' flag on FgGeE
formats, not just %f which your GCC patch would indicate (again, the glibc
manual should say exactly what is supported). Your patch should also have
failed the testsuite when you tested it, as you didn't update the
testcases, and GCC patches need to be against mainline to be considered.
The following patch should correspond to what the code now supports, but
hasn't yet been tested/applied.
2003-12-19 Joseph S. Myers <jsm@polyomino.org.uk>
* c-format.c (print_char_table): Allow 'I' flag on floating point
decimal formats.
testsuite:
2003-12-19 Joseph S. Myers <jsm@polyomino.org.uk>
* gcc.dg/format/ext-1.c: Allow 'I' flag on floating point decimal
formats.
--- GCC/gcc/c-format.c.orig 2003-11-20 15:55:24.000000000 +0000
+++ GCC/gcc/c-format.c 2003-12-19 12:25:15.000000000 +0000
@@ -755,23 +755,23 @@ static const format_flag_pair strfmon_fl
static const format_char_info print_char_table[] =
{
/* C89 conversion specifiers. */
- { "di", 0, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "-wp0 +'I", "i" },
- { "oxX", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0#", "i" },
- { "u", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0'I", "i" },
- { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "" },
- { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "" },
- { "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, T94_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "" },
- { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR" },
- { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "c" },
- { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, T99_IM }, "", "W" },
+ { "di", 0, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, TEX_LL, T99_SST, T99_PD, T99_IM }, "-wp0 +'I", "i" },
+ { "oxX", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0#", "i" },
+ { "u", 0, STD_C89, { T89_UI, T99_UC, T89_US, T89_UL, T9L_ULL, TEX_ULL, T99_ST, T99_UPD, T99_UIM }, "-wp0'I", "i" },
+ { "fgG", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'I", "" },
+ { "eE", 0, STD_C89, { T89_D, BADLEN, BADLEN, T99_D, BADLEN, T89_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#I", "" },
+ { "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, T94_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "" },
+ { "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, T94_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR" },
+ { "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "c" },
+ { "n", 1, STD_C89, { T89_I, T99_SC, T89_S, T89_L, T9L_LL, BADLEN, T99_SST, T99_PD, T99_IM }, "", "W" },
/* C99 conversion specifiers. */
- { "F", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "" },
- { "aA", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "" },
+ { "F", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#'I", "" },
+ { "aA", 0, STD_C99, { T99_D, BADLEN, BADLEN, T99_D, BADLEN, T99_LD, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "" },
/* X/Open conversion specifiers. */
- { "C", 0, STD_EXT, { TEX_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "" },
- { "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R" },
+ { "C", 0, STD_EXT, { TEX_WI, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-w", "" },
+ { "S", 1, STD_EXT, { TEX_W, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "R" },
/* GNU conversion specifiers. */
- { "m", 0, STD_EXT, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "" },
+ { "m", 0, STD_EXT, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "" },
{ NULL, 0, 0, NOLENGTHS, NULL, NULL }
};
--- GCC/gcc/testsuite/gcc.dg/format/ext-1.c.orig 2001-12-21 15:02:31.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/format/ext-1.c 2003-12-19 12:26:24.000000000 +0000
@@ -92,7 +92,7 @@ foo (quad_t q, u_quad_t uq, quad_t *qn,
*/
printf ("%*2$.*1$m", i, i);
printf ("%1$*2$.*1$m", i, i); /* { dg-warning "no argument" "printf %1\$m" } */
- /* As an extension, glibc includes the "I" flag for decimal integer
+ /* As an extension, glibc includes the "I" flag for decimal
formats, to output using the locale's digits (e.g. in Arabic).
In GCC, we require this to be in the standard place for flags, though
glibc allows it also after width or precision.
@@ -102,12 +102,12 @@ foo (quad_t q, u_quad_t uq, quad_t *qn,
printf ("%Ix", u); /* { dg-warning "flag" "bad use of I flag" } */
printf ("%IX", u); /* { dg-warning "flag" "bad use of I flag" } */
printf ("%In", n); /* { dg-warning "flag" "bad use of I flag" } */
- printf ("%If", d); /* { dg-warning "flag" "bad use of I flag" } */
- printf ("%IF", d); /* { dg-warning "flag" "bad use of I flag" } */
- printf ("%Ie", d); /* { dg-warning "flag" "bad use of I flag" } */
- printf ("%IE", d); /* { dg-warning "flag" "bad use of I flag" } */
- printf ("%Ig", d); /* { dg-warning "flag" "bad use of I flag" } */
- printf ("%IG", d); /* { dg-warning "flag" "bad use of I flag" } */
+ printf ("%If", d);
+ printf ("%IF", d);
+ printf ("%Ie", d);
+ printf ("%IE", d);
+ printf ("%Ig", d);
+ printf ("%IG", d);
printf ("%Ia", d); /* { dg-warning "flag" "bad use of I flag" } */
printf ("%IA", d); /* { dg-warning "flag" "bad use of I flag" } */
printf ("%Ic", i); /* { dg-warning "flag" "bad use of I flag" } */
--
Joseph S. Myers
jsm@polyomino.org.uk