diff options
author | Tom Tromey <tom@tromey.com> | 2020-07-01 21:21:12 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-07-01 21:21:13 -0600 |
commit | 7a02bab704afdc2c46e056da166eaaa025ff4b03 (patch) | |
tree | 77c614e16fb84496aabf50aef85343dfb328d135 /gdb/tui/tui-io.c | |
parent | ea68593bd2c649a73754e150340ba3400c007682 (diff) | |
download | gdb-7a02bab704afdc2c46e056da166eaaa025ff4b03.zip gdb-7a02bab704afdc2c46e056da166eaaa025ff4b03.tar.gz gdb-7a02bab704afdc2c46e056da166eaaa025ff4b03.tar.bz2 |
Remove tui_expand_tabs
tui_expand_tabs only has a single caller. This patch removes this
function, in favor of a tab-expanding variant of string_file. This
simplifies the code somewhat.
gdb/ChangeLog
2020-07-01 Tom Tromey <tom@tromey.com>
* tui/tui-regs.h (struct tui_data_item_window) <content>: Now a
std::string.
* tui/tui-regs.c (class tab_expansion_file): New.
(tab_expansion_file::write): New method.
(tui_register_format): Change return type. Use
tab_expansion_file.
(tui_get_register, tui_data_window::display_registers_from)
(tui_data_item_window::rerender): Update.
* tui/tui-io.h (tui_expand_tabs): Don't declare.
* tui/tui-io.c (tui_expand_tabs): Remove.
Diffstat (limited to 'gdb/tui/tui-io.c')
-rw-r--r-- | gdb/tui/tui-io.c | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 277b560..7698d79 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -1050,55 +1050,3 @@ tui_getc (FILE *fp) return 0; } } - -/* See tui-io.h. */ - -gdb::unique_xmalloc_ptr<char> -tui_expand_tabs (const char *string) -{ - int n_adjust, ncol; - const char *s; - char *ret, *q; - - /* 1. How many additional characters do we need? */ - for (ncol = 0, n_adjust = 0, s = string; s; ) - { - s = strpbrk (s, "\t"); - if (s) - { - ncol += (s - string) + n_adjust; - /* Adjustment for the next tab stop, minus one for the TAB - we replace with spaces. */ - n_adjust += 8 - (ncol % 8) - 1; - s++; - } - } - - /* Allocate the copy. */ - ret = q = (char *) xmalloc (strlen (string) + n_adjust + 1); - - /* 2. Copy the original string while replacing TABs with spaces. */ - for (ncol = 0, s = string; s; ) - { - const char *s1 = strpbrk (s, "\t"); - if (s1) - { - if (s1 > s) - { - strncpy (q, s, s1 - s); - q += s1 - s; - ncol += s1 - s; - } - do { - *q++ = ' '; - ncol++; - } while ((ncol % 8) != 0); - s1++; - } - else - strcpy (q, s); - s = s1; - } - - return gdb::unique_xmalloc_ptr<char> (ret); -} |