/* General utility routines for GDB, the GNU debugger.
Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free
- Software Foundation, Inc.
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GDB.
#include "filenames.h"
#include "symfile.h"
#include "gdb_obstack.h"
+#include "top.h"
#include "inferior.h" /* for signed_pointer_to_address */
va_end (ap);
}
-/* The strerror() function can return NULL for errno values that are
- out of range. Provide a "safe" version that always returns a
- printable string. */
-
-char *
-safe_strerror (int errnum)
-{
- char *msg;
-
- msg = strerror (errnum);
- if (msg == NULL)
- {
- static char buf[32];
- xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum);
- msg = buf;
- }
- return (msg);
-}
-
/* Print the system error message for errno, and also mention STRING
as the file name for which the error was encountered.
Then return to command level. */
{
char *ret = NULL;
int status = vasprintf (&ret, format, ap);
- /* NULL is returned when there was a memory allocation problem. */
- if (ret == NULL)
- nomem (0);
- /* A negative status (the printed length) with a non-NULL buffer
- should never happen, but just to be sure. */
- if (status < 0)
- internal_error (__FILE__, __LINE__,
- _("vasprintf call failed (errno %d)"), errno);
+ /* NULL is returned when there was a memory allocation problem, or
+ any other error (for instance, a bad format string). A negative
+ status (the printed length) with a non-NULL buffer should never
+ happen, but just to be sure. */
+ if (ret == NULL || status < 0)
+ internal_error (__FILE__, __LINE__, _("vasprintf call failed"));
return ret;
}
int ans2;
int retval;
+ /* Automatically answer "yes" if input is not from the user
+ directly, or if the user did not want prompts. */
+ if (!input_from_terminal_p () || !caution)
+ return 1;
+
if (deprecated_query_hook)
{
va_start (args, ctlstr);
return deprecated_query_hook (ctlstr, args);
}
- /* Automatically answer "yes" if input is not from a terminal. */
- if (!input_from_terminal_p ())
- return 1;
-
while (1)
{
wrap_here (""); /* Flush any buffered output */
n_string = "[n]";
}
+ /* Automatically answer the default value if input is not from the user
+ directly, or if the user did not want prompts. */
+ if (!input_from_terminal_p () || !caution)
+ return def_value;
+
if (deprecated_query_hook)
{
return deprecated_query_hook (ctlstr, args);
}
- /* Automatically answer default value if input is not from a terminal. */
- if (!input_from_terminal_p ())
- return def_value;
-
while (1)
{
wrap_here (""); /* Flush any buffered output */