From: Ben Pfaff Date: Thu, 11 Feb 2010 04:00:31 +0000 (-0800) Subject: q2c: Fix format string errors. X-Git-Tag: v0.7.5~141 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54edb8eb43cea865e2d85e5d359e6481f31941e6;p=pspp-builds.git q2c: Fix format string errors. These calls to write blank lines have caused warnings before, so introduce a new function just for the purpose so that any future warnings can be fixed in a single place. --- diff --git a/src/language/lexer/q2c.c b/src/language/lexer/q2c.c index a418866c..cf8aab1b 100644 --- a/src/language/lexer/q2c.c +++ b/src/language/lexer/q2c.c @@ -83,8 +83,6 @@ static char *tokstr; /* Utility functions. */ -static char nullstr[] = ""; - /* Close all open files and delete the output file, on failure. */ static void finish_up (void) @@ -974,6 +972,19 @@ dump (int indention, const char *format, ...) indent += BASE_INDENT * indention; } +/* Writes a blank line to the output file and adjusts 'indent' by BASE_INDENT + * INDENTION characters. + + (This is only useful because GCC complains about using "" as a format + string, for whatever reason.) */ +static void +dump_blank_line (int indention) +{ + oln++; + indent += BASE_INDENT * indention; + putc ('\n', out); +} + /* Write the structure members for specifier SPEC to the output file. SBC is the including subcommand. */ static void @@ -1088,7 +1099,7 @@ dump_declarations (void) if (f) { dump (-1, "};"); - dump (-1, nullstr); + dump_blank_line (-1); } } @@ -1122,7 +1133,7 @@ dump_declarations (void) dump (0, "%s%scount", st_upper (prefix), st_upper (sbc->prefix)); dump (-1, "};"); - dump (-1, nullstr); + dump_blank_line (-1); } } } @@ -1139,7 +1150,7 @@ dump_declarations (void) int f = 0; if (sbc != subcommands) - dump (0, nullstr); + dump_blank_line (0); dump (0, "/* %s subcommand. */", sbc->name); dump (0, "int sbc_%s;", st_lower (sbc->name)); @@ -1217,7 +1228,7 @@ dump_declarations (void) } dump (-1, "};"); - dump (-1, nullstr); + dump_blank_line (-1); } /* Write out prototypes for custom_*() functions as necessary. */ @@ -1240,7 +1251,7 @@ dump_declarations (void) } if (seen) - dump (0, nullstr); + dump_blank_line (0); } /* Prototypes for parsing and freeing functions. */ @@ -1250,7 +1261,7 @@ dump_declarations (void) make_identifier (cmdname), make_identifier (cmdname)); dump (0, "static void free_%s (struct cmd_%s *);", make_identifier (cmdname), make_identifier (cmdname)); - dump (0, nullstr); + dump_blank_line (0); } } @@ -1912,13 +1923,13 @@ dump_parser (int persistent) dump (0, "break;"); dump (-2, "}"); outdent (); - dump (0, nullstr); + dump_blank_line (0); dump (1, "if (lex_token (lexer) != '.')"); dump (1, "{"); dump (0, "lex_error (lexer, _(\"expecting end of command\"));"); dump (0, "goto lossage;"); dump (-1, "}"); - dump (0, nullstr); + dump_blank_line (0); outdent (); @@ -1937,19 +1948,19 @@ dump_parser (int persistent) sbc->name); dump (0, "goto lossage;"); dump (-1, "}"); - dump (0, nullstr); + dump_blank_line (0); } } } dump (-1, "return true;"); - dump (0, nullstr); + dump_blank_line (0); dump (-1, "lossage:"); indent (); dump (0, "free_%s (p);", make_identifier (cmdname)); dump (0, "return false;"); dump (-1, "}"); - dump (0, nullstr); + dump_blank_line (0); } @@ -1959,7 +1970,7 @@ dump_header (void) { indent = 0; dump (0, "/* %s\t\t-*- mode: c; buffer-read-only: t -*-", ofn); - dump (0, nullstr); + dump_blank_line (0); dump (0, " Generated by q2c from %s.", ifn); dump (0, " Do not modify!"); dump (0, " */"); @@ -2123,14 +2134,14 @@ main (int argc, char *argv[]) dump (0, "#include "); dump (0, "#include "); dump (0, "#include "); - dump (0, nullstr); + dump_blank_line (0); dump (0, "#include \"xalloc.h\""); - dump (0, nullstr); + dump_blank_line (0); dump (0, "#include \"gettext.h\""); dump (0, "#define _(msgid) gettext (msgid)"); - dump (0, nullstr); + dump_blank_line (0); } else if (!strcmp (directive, "declarations")) dump_declarations ();