#include <sys/ioctl.h>
#include <sys/param.h>
#include <pwd.h>
+#include <varargs.h>
+#include <ctype.h>
+#include <string.h>
+
#include "defs.h"
#include "param.h"
#include "signals.h"
#include "gdbcmd.h"
#include "terminal.h"
-#include <varargs.h>
-#include <ctype.h>
-#include <string.h>
#include "bfd.h"
#include "target.h"
#else /* !__GNU_LIBRARY */
#ifndef vfprintf
-#define vfprintf(file, format, ap) _doprnt (format, ap, file)
+/* Can't #define it since language.c needs it (though FIXME it shouldn't) */
+void
+vfprintf (file, format, ap)
+ FILE *file;
+ char *format;
+ va_list ap;
+{
+ _doprnt (format, ap, file);
+}
#endif /* vfprintf */
#ifndef vprintf
/* String to be printed before error messages, if any. */
char *error_pre_print;
+char *warning_pre_print;
\f
/* Add a new cleanup to the cleanup_chain,
and return the previous chain pointer
free (*location);
}
\f
+/* Provide a hook for modules wishing to print their own warning messages
+ to set up the terminal state in a compatible way, without them having
+ to import all the target_<...> macros. */
+
+void
+warning_setup ()
+{
+ target_terminal_ours ();
+ wrap_here(""); /* Force out any buffered output */
+ fflush (stdout);
+}
+
+/* Print a warning message.
+ The first argument STRING is the warning message, used as a fprintf string,
+ and the remaining args are passed as arguments to it.
+ The primary difference between warnings and errors is that a warning
+ does not force the return to command level. */
+
+/* VARARGS */
+void
+warning (va_alist)
+ va_dcl
+{
+ va_list args;
+ char *string;
+
+ va_start (args);
+ target_terminal_ours ();
+ wrap_here(""); /* Force out any buffered output */
+ fflush (stdout);
+ if (warning_pre_print)
+ fprintf (stderr, warning_pre_print);
+ string = va_arg (args, char *);
+ vfprintf (stderr, string, args);
+ fprintf (stderr, "\n");
+ va_end (args);
+}
+
/* Print an error message and return to command level.
The first argument STRING is the error message, used as a fprintf string,
and the remaining args are passed as arguments to it. */
va_start (args);
target_terminal_ours ();
+ wrap_here(""); /* Force out any buffered output */
fflush (stdout);
if (error_pre_print)
fprintf (stderr, error_pre_print);
switch (c)
{
case 'a':
- return '\a';
+ return 007; /* Bell (alert) char */
case 'b':
return '\b';
- case 'e':
+ case 'e': /* Escape character */
return 033;
case 'f':
return '\f';
{
register int c = ch;
- if (c < 040 || (sevenbit_strings && c >= 0177))
+ if (c < 040 || (sevenbit_strings && c >= 0177)) {
switch (c)
{
case '\n':
fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
break;
}
- else
- {
- if (c == '\\' || c == quoter)
- fputs_filtered ("\\", stream);
- fprintf_filtered (stream, "%c", c);
- }
+ } else {
+ if (c == '\\' || c == quoter)
+ fputs_filtered ("\\", stream);
+ fprintf_filtered (stream, "%c", c);
+ }
}
\f
/* Number of lines per page or UINT_MAX if paging is disabled. */
static char *wrap_buffer, *wrap_pointer, *wrap_indent;
static int wrap_column;
-/* Get the number of lines to print with commands like "list".
- This is based on guessing how many long (i.e. more than chars_per_line
- characters) lines there will be. To be completely correct, "list"
- and friends should be rewritten to count characters and see where
- things are wrapping, but that would be a fair amount of work. */
-int
-lines_to_list ()
-{
- /* RMS didn't like the following algorithm. Let's set it back to
- 10 and see if anyone else complains. */
- /* return lines_per_page == UINT_MAX ? 10 : lines_per_page / 2; */
- return 10;
-}
-
/* ARGSUSED */
static void
set_width_command (args, from_tty, c)
If the line is already overfull, we immediately print a newline and
the indentation, and disable further wrapping.
+ If we don't know the width of lines, but we know the page height,
+ we must not wrap words, but should still keep track of newlines
+ that were explicitly printed.
+
INDENT should not contain tabs, as that
will mess up the char count on the next line. FIXME. */
}
wrap_pointer = wrap_buffer;
wrap_buffer[0] = '\0';
- if (chars_printed >= chars_per_line)
+ if (chars_per_line == UINT_MAX) /* No line overflow checking */
+ {
+ wrap_column = 0;
+ }
+ else if (chars_printed >= chars_per_line)
{
puts_filtered ("\n");
puts_filtered (indent);
}
}
+ /* If the output is not a terminal, don't paginate it. */
+ if (!ISATTY (stdout))
+ lines_per_page = UINT_MAX;
+
set_width_command ((char *)NULL, 0, c);
add_show_from_set