This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Remove fprintf calls in parsers.



The following patch removes the calls to fprintf
inside the p-exp.tab.c file generated
by the bison parser.

This is done by simply defining YYFPRINTF macro.
All use of YYFPRINTF macro generated by bison
seem to use stderr as file parameter,
but this might change in the future...
that is why I added a check for it.

I didn't commit this, because I think that this
should be done for all parsers at the same time.
But this then raises the question of the location of
the pascal_yyfprintf (that would then be renamed to
something like parser_yyfprintf).

Two possibilities: 
-- parse.c seems rather logical,
with a declaration in parser-defs.h

but on the other hand
-- utils.c could also be considered.

I am willing to send a RFA for a common suppression of all
fprintf generated in all parser once the location of
this function is defined.



$ cvs diff -u -p p-exp.y
Index: p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.11
diff -u -p -r1.11 p-exp.y
--- p-exp.y     16 May 2002 09:34:54 -0000      1.11
+++ p-exp.y     16 May 2002 10:07:40 -0000
@@ -107,6 +107,26 @@ Foundation, Inc., 59 Temple Place - Suit
  #define        YYDEBUG 0               /* Default to no yydebug support */
  #endif

+#define YYFPRINTF pascal_yyfprintf
+
+static void pascal_yyfprintf (FILE *, const char *, ...);
+
+static void
+pascal_yyfprintf (FILE *x, const char *y, ...)
+{
+  va_list args;
+  va_start (args, y);
+  if (x == stderr)
+    vfprintf_unfiltered (gdb_stderr, y, args);
+  else
+    {
+      fprintf_unfiltered (gdb_stderr, " Unknown FILE used.\n");
+      vfprintf_unfiltered (gdb_stderr, y, args);
+    }
+  va_end (args);
+}
+
+
  int yyparse (void);

  static int yylex (void);



Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]