From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ulrich Drepper To: egcs@cygnus.com, Richard Kenner Subject: patch for printf/scanf format checking Date: Wed, 19 Nov 1997 19:21:00 -0000 Message-id: X-SW-Source: 1997-11/msg00653.html Hi, Please apply the following patch which adds a bit better support for the ISO C 9X extensions to printf/scanf. I hope to implement the rest soon but these patches are quite useful since they help to avoid tons of warnings when compiling glibc. 1997-11-19 20:24 Ulrich Drepper * c-common.c (print_char_table): Add a and A to float formats. (scan_char_table): Likewise. (check_format_info): Recognize `a' a allocate flag only if used in the correct context. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- c-common.c.orig Wed Nov 19 17:52:28 1997 +++ c-common.c Wed Nov 19 17:58:47 1997 @@ -929,7 +929,7 @@ /* Two GNU extensions. */ { "Z", 0, T_ST, NULL, NULL, NULL, NULL, "-wp0" }, { "m", 0, T_V, NULL, NULL, NULL, NULL, "-wp" }, - { "feEgG", 0, T_D, NULL, NULL, NULL, T_LD, "-wp0 +#" }, + { "feEgGaA", 0, T_D, NULL, NULL, NULL, T_LD, "-wp0 +#" }, { "c", 0, T_I, NULL, T_W, NULL, NULL, "-w" }, { "C", 0, T_W, NULL, NULL, NULL, NULL, "-w" }, { "s", 1, T_C, NULL, T_W, NULL, NULL, "-wp" }, @@ -942,7 +942,7 @@ static format_char_info scan_char_table[] = { { "di", 1, T_I, T_S, T_L, T_LL, T_LL, "*" }, { "ouxX", 1, T_UI, T_US, T_UL, T_ULL, T_ULL, "*" }, - { "efgEG", 1, T_F, NULL, T_D, NULL, T_LD, "*" }, + { "efgEGaA", 1, T_F, NULL, T_D, NULL, T_LD, "*" }, { "sc", 1, T_C, NULL, T_W, NULL, NULL, "*a" }, { "[", 1, T_C, NULL, NULL, NULL, NULL, "*a" }, { "C", 1, T_W, NULL, NULL, NULL, NULL, "*" }, @@ -1404,10 +1404,15 @@ pedwarn ("ANSI C does not support the `ll' length modifier"); } aflag = 0; - if (*format_chars == 'a') + if (*format_chars == 'a' && info->is_scan) { - aflag = 1; - format_chars++; + if (format_chars[1] == 's' || format_chars[1] == 'S' + || format_chars[1] == '[') + { + /* `a' is used as a flag. */ + aflag = 1; + format_chars++; + } } if (suppressed && length_char != 0) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Thanks, -- Uli ---------------. drepper at gnu.org ,-. Rubensstrasse 5 Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany Cygnus Solutions `--' drepper at cygnus.com `------------------------