struct macro_source_file *file,
int line)
{
- char *fullname;
-
- fullname = macro_source_fullname (file);
- fputs_styled (fullname, file_name_style.style (), stream);
+ std::string fullname = macro_source_fullname (file);
+ fputs_styled (fullname.c_str (), file_name_style.style (), stream);
fprintf_filtered (stream, ":%d\n", line);
- xfree (fullname);
while (file->included_by)
{
fullname = macro_source_fullname (file->included_by);
fputs_filtered (_(" included at "), stream);
- fputs_styled (fullname, file_name_style.style (), stream);
+ fputs_styled (fullname.c_str (), file_name_style.style (), stream);
fprintf_filtered (stream, ":%d\n", file->included_at_line);
- xfree (fullname);
file = file->included_by;
}
}
the new one? */
if (*link && line == (*link)->included_at_line)
{
- char *link_fullname, *source_fullname;
-
/* This means the compiler is emitting bogus debug info. (GCC
circa March 2002 did this.) It also means that the splay
tree ordering function, macro_tree_compare, will abort,
First, squawk. */
- link_fullname = macro_source_fullname (*link);
- source_fullname = macro_source_fullname (source);
+ std::string link_fullname = macro_source_fullname (*link);
+ std::string source_fullname = macro_source_fullname (source);
complaint (_("both `%s' and `%s' allegedly #included at %s:%d"),
- included, link_fullname, source_fullname, line);
- xfree (source_fullname);
- xfree (link_fullname);
+ included, link_fullname.c_str (), source_fullname.c_str (),
+ line);
/* Now, choose a new, unoccupied line number for this
#inclusion, after the alleged #inclusion line. */
if (! same)
{
- char *source_fullname, *found_key_fullname;
-
- source_fullname = macro_source_fullname (source);
- found_key_fullname = macro_source_fullname (found_key->start_file);
+ std::string source_fullname = macro_source_fullname (source);
+ std::string found_key_fullname
+ = macro_source_fullname (found_key->start_file);
complaint (_("macro `%s' redefined at %s:%d; "
"original definition at %s:%d"),
- name, source_fullname, line, found_key_fullname,
+ name, source_fullname.c_str (), line,
+ found_key_fullname.c_str (),
found_key->start_line);
- xfree (found_key_fullname);
- xfree (source_fullname);
}
return found_key;
#definition. */
if (key->end_file)
{
- char *source_fullname, *key_fullname;
-
- source_fullname = macro_source_fullname (source);
- key_fullname = macro_source_fullname (key->end_file);
+ std::string source_fullname = macro_source_fullname (source);
+ std::string key_fullname = macro_source_fullname (key->end_file);
complaint (_("macro '%s' is #undefined twice,"
" at %s:%d and %s:%d"),
- name, source_fullname, line, key_fullname,
+ name, source_fullname.c_str (), line,
+ key_fullname.c_str (),
key->end_line);
- xfree (key_fullname);
- xfree (source_fullname);
}
/* Whether or not we've seen a prior #undefinition, wipe out
if (n)
{
- struct macro_definition *retval;
- char *source_fullname;
-
- source_fullname = macro_source_fullname (source);
- retval = fixup_definition (source_fullname, line,
- (struct macro_definition *) n->value);
- xfree (source_fullname);
- return retval;
+ std::string source_fullname = macro_source_fullname (source);
+ return fixup_definition (source_fullname.c_str (), line,
+ (struct macro_definition *) n->value);
}
else
return 0;
struct macro_for_each_data *datum = (struct macro_for_each_data *) arg;
struct macro_key *key = (struct macro_key *) node->key;
struct macro_definition *def;
- char *key_fullname;
- key_fullname = macro_source_fullname (key->start_file);
- def = fixup_definition (key_fullname, key->start_line,
+ std::string key_fullname = macro_source_fullname (key->start_file);
+ def = fixup_definition (key_fullname.c_str (), key->start_line,
(struct macro_definition *) node->value);
- xfree (key_fullname);
datum->fn (key->name, def, key->start_file, key->start_line);
return 0;
struct macro_for_each_data *datum = (struct macro_for_each_data *) info;
struct macro_key *key = (struct macro_key *) node->key;
struct macro_definition *def;
- char *datum_fullname;
- datum_fullname = macro_source_fullname (datum->file);
- def = fixup_definition (datum_fullname, datum->line,
+ std::string datum_fullname = macro_source_fullname (datum->file);
+ def = fixup_definition (datum_fullname.c_str (), datum->line,
(struct macro_definition *) node->value);
- xfree (datum_fullname);
/* See if this macro is defined before the passed-in line, and
extends past that line. */
/* See macrotab.h for the comment. */
-char *
+std::string
macro_source_fullname (struct macro_source_file *file)
{
const char *comp_dir = NULL;
comp_dir = COMPUNIT_DIRNAME (file->table->compunit_symtab);
if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename))
- return xstrdup (file->filename);
+ return file->filename;
- return concat (comp_dir, SLASH_STRING, file->filename, (char *) NULL);
+ return std::string (comp_dir) + SLASH_STRING + file->filename;
}