summaryrefslogtreecommitdiff
path: root/gdb/cp-support.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/cp-support.c')
-rw-r--r--gdb/cp-support.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index d409b0b92e7..b0b91fc133f 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -210,7 +210,6 @@ inspect_type (struct demangle_parse_info *info,
int is_anon;
struct type *type;
struct demangle_parse_info *i;
- struct ui_file *buf;
/* Get the real type of the typedef. */
type = check_typedef (otype);
@@ -246,23 +245,21 @@ inspect_type (struct demangle_parse_info *info,
type = last;
}
- buf = mem_fileopen ();
+ string_file buf;
TRY
- {
- type_print (type, "", buf, -1);
- }
-
+ {
+ type_print (type, "", &buf, -1);
+ }
/* If type_print threw an exception, there is little point
in continuing, so just bow out gracefully. */
CATCH (except, RETURN_MASK_ERROR)
{
- ui_file_delete (buf);
return 0;
}
END_CATCH
- name = ui_file_obsavestring (buf, &info->obstack, &len);
- ui_file_delete (buf);
+ len = buf.size ();
+ name = (char *) obstack_copy0 (&info->obstack, buf.c_str (), len);
/* Turn the result into a new tree. Note that this
tree will contain pointers into NAME, so NAME cannot
@@ -319,7 +316,7 @@ replace_typedefs_qualified_name (struct demangle_parse_info *info,
{
long len;
char *name;
- struct ui_file *buf = mem_fileopen ();
+ string_file buf;
struct demangle_component *comp = ret_comp;
/* Walk each node of the qualified name, reconstructing the name of
@@ -333,9 +330,9 @@ replace_typedefs_qualified_name (struct demangle_parse_info *info,
{
struct demangle_component newobj;
- ui_file_write (buf, d_left (comp)->u.s_name.s,
- d_left (comp)->u.s_name.len);
- name = ui_file_obsavestring (buf, &info->obstack, &len);
+ buf.write (d_left (comp)->u.s_name.s, d_left (comp)->u.s_name.len);
+ len = buf.size ();
+ name = (char *) obstack_copy0 (&info->obstack, buf.c_str (), len);
newobj.type = DEMANGLE_COMPONENT_NAME;
newobj.u.s_name.s = name;
newobj.u.s_name.len = len;
@@ -348,12 +345,11 @@ replace_typedefs_qualified_name (struct demangle_parse_info *info,
string and replace the top DEMANGLE_COMPONENT_QUAL_NAME
node. */
- ui_file_rewind (buf);
+ buf.rewind ();
n = cp_comp_to_string (&newobj, 100);
if (n == NULL)
{
/* If something went astray, abort typedef substitutions. */
- ui_file_delete (buf);
return;
}
@@ -378,14 +374,13 @@ replace_typedefs_qualified_name (struct demangle_parse_info *info,
if (name == NULL)
{
/* If something went astray, abort typedef substitutions. */
- ui_file_delete (buf);
return;
}
- fputs_unfiltered (name, buf);
+ buf.puts (name);
xfree (name);
}
- ui_file_write (buf, "::", 2);
+ buf.write ("::", 2);
comp = d_right (comp);
}
@@ -395,8 +390,9 @@ replace_typedefs_qualified_name (struct demangle_parse_info *info,
if (comp->type == DEMANGLE_COMPONENT_NAME)
{
- ui_file_write (buf, comp->u.s_name.s, comp->u.s_name.len);
- name = ui_file_obsavestring (buf, &info->obstack, &len);
+ buf.write (comp->u.s_name.s, comp->u.s_name.len);
+ len = buf.size ();
+ name = (char *) obstack_copy0 (&info->obstack, buf.c_str (), len);
/* Replace the top (DEMANGLE_COMPONENT_QUAL_NAME) node
with a DEMANGLE_COMPONENT_NAME node containing the whole
@@ -408,8 +404,6 @@ replace_typedefs_qualified_name (struct demangle_parse_info *info,
}
else
replace_typedefs (info, comp, finder, data);
-
- ui_file_delete (buf);
}