* utils.c (error_begin): Make static.
[deliverable/binutils-gdb.git] / gdb / utils.c
index 83d1a97523902278ca95fc48ac520934a5404297..c3e5a5058899ebebbc16428036974d434866a32d 100644 (file)
 
 #include "inferior.h" /* for signed_pointer_to_address */
 
+#include <sys/param.h>         /* For MAXPATHLEN */
+
 #include <readline/readline.h>
 
 #ifdef USE_MMALLOC
 #include "mmalloc.h"
 #endif
 
-#ifndef MALLOC_INCOMPATIBLE
 #ifdef NEED_DECLARATION_MALLOC
 extern PTR malloc ();
 #endif
@@ -70,7 +71,6 @@ extern PTR realloc ();
 #ifdef NEED_DECLARATION_FREE
 extern void free ();
 #endif
-#endif
 
 #undef XMALLOC
 #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
@@ -554,23 +554,28 @@ discard_all_intermediate_continuations (void)
 
 \f
 
-/* Print a warning message.  Way to use this is to call warning_begin,
-   output the warning message (use unfiltered output to gdb_stderr),
-   ending in a newline.  There is not currently a warning_end that you
-   call afterwards, but such a thing might be added if it is useful
-   for a GUI to separate warning messages from other output.
-
-   FIXME: Why do warnings use unfiltered output and errors filtered?
-   Is this anything other than a historical accident?  */
+/* Print a warning message.  The first argument STRING is the warning
+   message, used as an fprintf format string, the second is the
+   va_list of arguments for that string.  A warning is unfiltered (not
+   paginated) so that the user does not need to page through each
+   screen full of warnings when there are lots of them.  */
 
 void
-warning_begin (void)
+vwarning (const char *string, va_list args)
 {
-  target_terminal_ours ();
-  wrap_here ("");              /* Force out any buffered output */
-  gdb_flush (gdb_stdout);
-  if (warning_pre_print)
-    fprintf_unfiltered (gdb_stderr, warning_pre_print);
+  if (warning_hook)
+    (*warning_hook) (string, args);
+  else
+    {
+      target_terminal_ours ();
+      wrap_here ("");          /* Force out any buffered output */
+      gdb_flush (gdb_stdout);
+      if (warning_pre_print)
+       fprintf_unfiltered (gdb_stderr, warning_pre_print);
+      vfprintf_unfiltered (gdb_stderr, string, args);
+      fprintf_unfiltered (gdb_stderr, "\n");
+      va_end (args);
+    }
 }
 
 /* Print a warning message.
@@ -584,15 +589,8 @@ warning (const char *string,...)
 {
   va_list args;
   va_start (args, string);
-  if (warning_hook)
-    (*warning_hook) (string, args);
-  else
-    {
-      warning_begin ();
-      vfprintf_unfiltered (gdb_stderr, string, args);
-      fprintf_unfiltered (gdb_stderr, "\n");
-      va_end (args);
-    }
+  vwarning (string, args);
+  va_end (args);
 }
 
 /* Start the printing of an error message.  Way to use this is to call
@@ -602,7 +600,7 @@ warning (const char *string,...)
    error() provides a convenient way to do this for the special case
    that the error message can be formatted with a single printf call,
    but this is more general.  */
-void
+static void
 error_begin (void)
 {
   if (error_begin_hook)
@@ -2538,7 +2536,13 @@ char *
 gdb_realpath (const char *filename)
 {
 #ifdef HAVE_REALPATH
+#if defined (PATH_MAX)
   char buf[PATH_MAX];
+#elif defined (MAXPATHLEN)
+  char buf[MAXPATHLEN];
+#else
+#error "Neither PATH_MAX nor MAXPATHLEN defined"
+#endif
   char *rp = realpath (filename, buf);
   return xstrdup (rp ? rp : filename);
 #else
This page took 0.029648 seconds and 4 git commands to generate.