aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-12-30 09:46:02 -0700
committerTom Tromey <tom@tromey.com>2022-01-26 15:19:13 -0700
commit6c92c339539ec87dc12783e9c8f1688a4a370c03 (patch)
tree5f3d0621646cae14436ab8e63edcf3542c236f86 /gdb/utils.c
parentbbea68079781ac4c2fc941867ee9888585cafb77 (diff)
downloadgdb-6c92c339539ec87dc12783e9c8f1688a4a370c03.zip
gdb-6c92c339539ec87dc12783e9c8f1688a4a370c03.tar.gz
gdb-6c92c339539ec87dc12783e9c8f1688a4a370c03.tar.bz2
Convert wrap_here to use integer parameter
I think it only really makes sense to call wrap_here with an argument consisting solely of spaces. Given this, it seemed better to me that the argument be an int, rather than a string. This patch is the result. Much of it was written by a script.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index 9226689..3a019d7 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -154,7 +154,7 @@ vwarning (const char *string, va_list args)
target_terminal::ours_for_output ();
}
if (filtered_printing_initialized ())
- wrap_here (""); /* Force out any buffered output. */
+ wrap_here (0); /* Force out any buffered output. */
gdb_flush (gdb_stdout);
if (warning_pre_print)
fputs_unfiltered (warning_pre_print, gdb_stderr);
@@ -881,7 +881,7 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
{
target_terminal::scoped_restore_terminal_state term_state;
target_terminal::ours_for_output ();
- wrap_here ("");
+ wrap_here (0);
vfprintf_filtered (gdb_stdout, ctlstr, args);
printf_filtered (_("(%s or %s) [answered %c; "
@@ -1175,9 +1175,8 @@ static bool filter_initialized = false;
already been counted in chars_printed). */
static std::string wrap_buffer;
-/* String to indent by if the wrap occurs. Must not be NULL if wrap_column
- is non-zero. */
-static const char *wrap_indent;
+/* String to indent by if the wrap occurs. */
+static int wrap_indent;
/* Column number on the screen where wrap_buffer begins, or 0 if wrapping
is not in effect. */
@@ -1520,12 +1519,10 @@ get_chars_per_line ()
return chars_per_line;
}
-/* Indicate that if the next sequence of characters overflows the line,
- a newline should be inserted here rather than when it hits the end.
- If INDENT is non-null, it is a string to be printed to indent the
- wrapped part on the next line. INDENT must remain accessible until
- the next call to wrap_here() or until a newline is printed through
- fputs_filtered().
+/* Indicate that if the next sequence of characters overflows the
+ line, a newline should be inserted here rather than when it hits
+ the end. If INDENT is non-zero, it is a number of spaces to be
+ printed to indent the wrapped part on the next line.
If the line is already overfull, we immediately print a newline and
the indentation, and disable further wrapping.
@@ -1534,15 +1531,12 @@ get_chars_per_line ()
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.
-
This routine is guaranteed to force out any output which has been
- squirreled away in the wrap_buffer, so wrap_here ((char *)0) can be
+ squirreled away in the wrap_buffer, so wrap_here (0) can be
used to force out output from the wrap_buffer. */
void
-wrap_here (const char *indent)
+wrap_here (int indent)
{
/* This should have been allocated, but be paranoid anyway. */
gdb_assert (filter_initialized);
@@ -1555,17 +1549,14 @@ wrap_here (const char *indent)
else if (chars_printed >= chars_per_line)
{
puts_filtered ("\n");
- if (indent != NULL)
- puts_filtered (indent);
+ if (indent != 0)
+ puts_filtered (n_spaces (indent));
wrap_column = 0;
}
else
{
wrap_column = chars_printed;
- if (indent == NULL)
- wrap_indent = "";
- else
- wrap_indent = indent;
+ wrap_indent = indent;
wrap_style = applied_style;
}
}
@@ -1672,7 +1663,7 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
{
wrap_buffer.clear ();
wrap_column = 0;
- wrap_indent = "";
+ wrap_indent = 0;
});
/* Go through and output each character. Show line extension
@@ -1777,7 +1768,7 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
/* Now output indentation and wrapped string. */
if (wrap_column)
{
- stream->puts (wrap_indent);
+ stream->puts (n_spaces (wrap_indent));
/* Having finished inserting the wrapping we should
restore the style as it was at the WRAP_COLUMN. */
@@ -1791,14 +1782,9 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
in WRAP_BUFFER. */
applied_style = save_style;
- /* FIXME, this strlen is what prevents wrap_indent from
- containing tabs. However, if we recurse to print it
- and count its chars, we risk trouble if wrap_indent is
- longer than (the user settable) chars_per_line.
- Note also that this can set chars_printed > chars_per_line
+ /* Note that this can set chars_printed > chars_per_line
if we are printing a long string. */
- chars_printed = strlen (wrap_indent)
- + (save_chars - wrap_column);
+ chars_printed = wrap_indent + (save_chars - wrap_column);
wrap_column = 0; /* And disable fancy wrap */
}
else if (did_paginate && stream->can_emit_style_escape ())
@@ -1809,8 +1795,8 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
if (*lineptr == '\n')
{
chars_printed = 0;
- wrap_here ((char *) 0); /* Spit out chars, cancel
- further wraps. */
+ wrap_here (0); /* Spit out chars, cancel
+ further wraps. */
lines_printed++;
/* XXX: The ideal thing would be to call
'stream->putc' here, but we can't because it