aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-io.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-07-13 16:01:34 -0600
committerTom Tromey <tom@tromey.com>2019-08-20 16:45:50 -0600
commitb9ad36868f46d5270347ef50fd62fde94d68328b (patch)
tree6962281859638702bcfe090465937a2b6ab51134 /gdb/tui/tui-io.c
parent8e114aab8bdab9a988dfc0afbb3fecc17e2d45b6 (diff)
downloadgdb-b9ad36868f46d5270347ef50fd62fde94d68328b.zip
gdb-b9ad36868f46d5270347ef50fd62fde94d68328b.tar.gz
gdb-b9ad36868f46d5270347ef50fd62fde94d68328b.tar.bz2
Change tui_data_item_window::content to be a unique_xmalloc_ptr
This changes tui_data_item_window::content to be a unique_xmalloc_ptr and fixes up the fallout. It also removes a parameter from tui_expand_tabs, as it was only ever given one value. This also removes some tab-handling code from tui_data_window::display_registers_from. Because the content can only be set by tui_register_format, and because that calls tui_expand_tabs, it's not possible to see a tab here. gdb/ChangeLog 2019-08-20 Tom Tromey <tom@tromey.com> * tui/tui-regs.h (struct tui_data_item_window) <~tui_data_item_window>: Remove. <content>: Now a unique_xmalloc_ptr. * tui/tui-regs.c (tui_register_format): Return a unique_xmalloc_ptr. (tui_get_register): Update. (~tui_data_item_window): Remove. (tui_data_window::display_registers_from, tui_display_register): Update. * tui/tui-io.h (tui_expand_tabs): Update. * tui/tui-io.c (tui_expand_tabs): Return a unique_xmalloc_ptr. Remove "col" parameter.
Diffstat (limited to 'gdb/tui/tui-io.c')
-rw-r--r--gdb/tui/tui-io.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 7bdba3f..ac7f098 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -1050,19 +1050,17 @@ tui_getc (FILE *fp)
return ch;
}
-/* Utility function to expand TABs in a STRING into spaces. STRING
- will be displayed starting at column COL, and is assumed to include
- no newlines. The returned expanded string is malloc'ed. */
+/* See tui-io.h. */
-char *
-tui_expand_tabs (const char *string, int col)
+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 = col, n_adjust = 0, s = string; s; )
+ for (ncol = 0, n_adjust = 0, s = string; s; )
{
s = strpbrk (s, "\t");
if (s)
@@ -1079,7 +1077,7 @@ tui_expand_tabs (const char *string, int col)
ret = q = (char *) xmalloc (strlen (string) + n_adjust + 1);
/* 2. Copy the original string while replacing TABs with spaces. */
- for (ncol = col, s = string; s; )
+ for (ncol = 0, s = string; s; )
{
const char *s1 = strpbrk (s, "\t");
if (s1)
@@ -1101,5 +1099,5 @@ tui_expand_tabs (const char *string, int col)
s = s1;
}
- return ret;
+ return gdb::unique_xmalloc_ptr<char> (ret);
}