strftime format checking adjustment
Joseph S. Myers
jsm28@cam.ac.uk
Sat Sep 2 10:29:00 GMT 2000
The handling of the strftime # format flag (a GNU extension) has been
made more consistent in glibc, which means that GCC should now allow
%#b and %#h. This patch changes GCC and the relevant test
accordingly.
Bootstrapped with no regressions on i686-pc-linux-gnu. OK to commit?
gcc/ChangeLog:
2000-09-02 Joseph S. Myers <jsm28@cam.ac.uk>
* c-common.c (time_char_table): Allow %#b and %#h.
gcc/testsuite/ChangeLog:
2000-09-02 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.dg/format-ext-3.c: Test %#b and %#h as formats that should
be accepted.
--- c-common.c.orig Fri Sep 1 22:01:37 2000
+++ c-common.c Sat Sep 2 12:31:56 2000
@@ -1418,8 +1418,7 @@ static const format_char_info scan_char_
static format_char_info time_char_table[] =
{
/* C89 conversion specifiers. */
- { "ABZa", 0, STD_C89, NOLENGTHS, "^#" },
- { "b", 0, STD_C89, NOLENGTHS, "^" },
+ { "ABZab", 0, STD_C89, NOLENGTHS, "^#" },
{ "cx", 0, STD_C89, NOLENGTHS, "3E" },
{ "HIMSUWdmw", 0, STD_C89, NOLENGTHS, "-_0Ow" },
{ "j", 0, STD_C89, NOLENGTHS, "-_0Oow" },
@@ -1435,7 +1434,7 @@ static format_char_info time_char_table[
{ "FRTnrt", 0, STD_C99, NOLENGTHS, "" },
{ "g", 0, STD_C99, NOLENGTHS, "2Oo-_0w" },
{ "G", 0, STD_C99, NOLENGTHS, "-_0Oow" },
- { "h", 0, STD_C99, NOLENGTHS, "^" },
+ { "h", 0, STD_C99, NOLENGTHS, "^#" },
{ "z", 0, STD_C99, NOLENGTHS, "Oo" },
/* GNU conversion specifiers. */
{ "kls", 0, STD_EXT, NOLENGTHS, "-_0Ow" },
--- testsuite/gcc.dg/format-ext-3.c.orig Thu Aug 24 21:35:07 2000
+++ testsuite/gcc.dg/format-ext-3.c Sat Sep 2 16:19:31 2000
@@ -121,12 +121,10 @@
strftime (s, m, "%0P", tp); /* { dg-warning "flag" "bad %P" } */
/* The "^" and "#" flags control the case of the output.
^ (uppercase) makes sense on aAbBhZ; # (change case) makes sense
- on the same (though glibc ignores it on bh for some reason; for now our
- implementation in GCC follows glibc) and on p.
+ on the same and on p.
*/
- strftime (s, m, "%^a%#a%^A%#A%^b%^B%#B%^h%^Z%#Z%#p", tp);
+ strftime (s, m, "%^a%#a%^A%#A%^b%#b%^B%#B%^h%#h%^Z%#Z%#p", tp);
/* Bad usages. */
- strftime (s, m, "%#b", tp); /* { dg-warning "flag" "bad %b" } */
strftime (s, m, "%^C", tp); /* { dg-warning "flag" "bad %C" } */
strftime (s, m, "%#C", tp); /* { dg-warning "flag" "bad %C" } */
strftime (s, m, "%^d", tp); /* { dg-warning "flag" "bad %d" } */
@@ -137,7 +135,6 @@
strftime (s, m, "%#F", tp); /* { dg-warning "flag" "bad %F" } */
strftime (s, m, "%^G", tp); /* { dg-warning "flag" "bad %G" } */
strftime (s, m, "%#G", tp); /* { dg-warning "flag" "bad %G" } */
- strftime (s, m, "%#h", tp); /* { dg-warning "flag" "bad %h" } */
strftime (s, m, "%^H", tp); /* { dg-warning "flag" "bad %H" } */
strftime (s, m, "%#H", tp); /* { dg-warning "flag" "bad %H" } */
strftime (s, m, "%^I", tp); /* { dg-warning "flag" "bad %I" } */
@@ -196,6 +193,9 @@
strftime (s, m, "%#x", tp); /* { dg-warning "flag" "bad %x" } */
strftime (s, m, "%^y", tp); /* { dg-warning "flag" "bad %y" } */
strftime (s, m, "%#y", tp); /* { dg-warning "flag" "bad %y" } */
+ /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 186 } */
+ /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 187 } */
+ /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 188 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 189 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 190 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 191 } */
@@ -203,9 +203,6 @@
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 193 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 194 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 195 } */
- /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 196 } */
- /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 197 } */
- /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 198 } */
/* GCC also accepts the glibc format extensions %P, %k, %l, %s. */
strftime (s, m, "%P%k%l%s", tp);
/* GCC also accepts the glibc extension of the "O" modifier on some
--
Joseph S. Myers
jsm28@cam.ac.uk
More information about the Gcc-patches
mailing list