2004-07-28 Andrew Cagney <cagney@gnu.org>
[platform/upstream/binutils.git] / gdb / complaints.c
index 4758008..4c9ea14 100644 (file)
@@ -1,7 +1,7 @@
 /* Support for complaint handling during symbol reading in GDB.
 
-   Copyright 1990, 1991, 1992, 1993, 1995, 1998, 1999, 2000, 2002 Free
-   Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993, 1995, 1998, 1999, 2000, 2002,
+   2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -60,6 +60,15 @@ struct complain
   struct complain *next;
 };
 
+/* The explanatory message that should accompany the complaint.  The
+   message is in two parts - pre and post - that are printed around
+   the complaint text.  */
+struct explanation
+{
+  const char *prefix;
+  const char *postfix;
+};
+
 struct complaints
 {
   struct complain *root;
@@ -75,20 +84,21 @@ struct complaints
   /* The explanatory messages that should accompany the complaint.
      NOTE: cagney/2002-08-14: In a desperate attempt at being vaguely
      i18n friendly, this is an array of two messages.  When present,
-     EXPLANATION[SERIES] is used to wrap the message.  */
-  const char **explanation;
+     the PRE and POST EXPLANATION[SERIES] are used to wrap the
+     message.  */
+  const struct explanation *explanation;
 };
 
 static struct complain complaint_sentinel;
 
 /* The symbol table complaint table.  */
 
-static const char *symfile_explanations[] = {
-  "During symbol reading, %s.",
-  "During symbol reading...%s...",
-  "%s...",
-  "%s...",
-  NULL
+static struct explanation symfile_explanations[] = {
+  { "During symbol reading, ", "." },
+  { "During symbol reading...", "..."},
+  { "", "..."},
+  { "", "..."},
+  { NULL, NULL }
 };
 
 static struct complaints symfile_complaint_book = {
@@ -176,8 +186,8 @@ vcomplaint (struct complaints **c, const char *file, int line, const char *fmt,
 
   if (complaint->file != NULL)
     internal_vwarning (complaint->file, complaint->line, complaint->fmt, args);
-  else if (warning_hook)
-    (*warning_hook) (complaint->fmt, args);
+  else if (deprecated_warning_hook)
+    (*deprecated_warning_hook) (complaint->fmt, args);
   else
     {
       if (complaints->explanation == NULL)
@@ -187,20 +197,20 @@ vcomplaint (struct complaints **c, const char *file, int line, const char *fmt,
        {
          char *msg;
          struct cleanup *cleanups;
-         xvasprintf (&msg, complaint->fmt, args);
+         msg = xstrvprintf (complaint->fmt, args);
          cleanups = make_cleanup (xfree, msg);
          wrap_here ("");
          if (series != SUBSEQUENT_MESSAGE)
            begin_line ();
-         fprintf_filtered (gdb_stderr,
-                           complaints->explanation[series],
-                           msg);
+         fprintf_filtered (gdb_stderr, "%s%s%s",
+                           complaints->explanation[series].prefix, msg,
+                           complaints->explanation[series].postfix);
          /* Force a line-break after any isolated message.  For the
              other cases, clear_complaints() takes care of any missing
              trailing newline, the wrap_here() is just a hint.  */
          if (series == ISOLATED_MESSAGE)
            /* It would be really nice to use begin_line() here.
-              Unfortunatly that function doesn't track GDB_STDERR and
+              Unfortunately that function doesn't track GDB_STDERR and
               consequently will sometimes supress a line when it
               shouldn't.  */
            fputs_filtered ("\n", gdb_stderr);
@@ -282,7 +292,7 @@ clear_complaints (struct complaints **c, int less_verbose, int noisy)
       break;
     case SUBSEQUENT_MESSAGE:
       /* It would be really nice to use begin_line() here.
-         Unfortunatly that function doesn't track GDB_STDERR and
+         Unfortunately that function doesn't track GDB_STDERR and
          consequently will sometimes supress a line when it shouldn't.  */
       fputs_unfiltered ("\n", gdb_stderr);
       break;
@@ -302,9 +312,11 @@ void
 _initialize_complaints (void)
 {
   add_setshow_cmd ("complaints", class_support, var_zinteger,
-                  &stop_whining,
-                  "Set max number of complaints about incorrect symbols.",
-                  "Show max number of complaints about incorrect symbols.",
+                  &stop_whining, "\
+Set max number of complaints about incorrect symbols.", "\
+Show max number of complaints about incorrect symbols.", "\
+Set to zero to disable incorrect symbol complaints.", "\
+Max number of complaints about incorrect symbols is %s.",
                   NULL, NULL,
                   &setlist, &showlist);