@@ -466,8 +466,6 @@ macro_include (struct macro_source_file *source,
466466 the new one? */
467467 if (* link && line == (* link )-> included_at_line )
468468 {
469- char * link_fullname , * source_fullname ;
470-
471469 /* This means the compiler is emitting bogus debug info. (GCC
472470 circa March 2002 did this.) It also means that the splay
473471 tree ordering function, macro_tree_compare, will abort,
@@ -476,12 +474,11 @@ macro_include (struct macro_source_file *source,
476474
477475 First, squawk. */
478476
479- link_fullname = macro_source_fullname (* link );
480- source_fullname = macro_source_fullname (source );
477+ std :: string link_fullname = macro_source_fullname (* link );
478+ std :: string source_fullname = macro_source_fullname (source );
481479 complaint (_ ("both `%s' and `%s' allegedly #included at %s:%d" ),
482- included , link_fullname , source_fullname , line );
483- xfree (source_fullname );
484- xfree (link_fullname );
480+ included , link_fullname .c_str (), source_fullname .c_str (),
481+ line );
485482
486483 /* Now, choose a new, unoccupied line number for this
487484 #inclusion, after the alleged #inclusion line. */
@@ -725,16 +722,14 @@ check_for_redefinition (struct macro_source_file *source, int line,
725722
726723 if (! same )
727724 {
728- char * source_fullname , * found_key_fullname ;
729-
730- source_fullname = macro_source_fullname (source );
731- found_key_fullname = macro_source_fullname (found_key -> start_file );
725+ std ::string source_fullname = macro_source_fullname (source );
726+ std ::string found_key_fullname
727+ = macro_source_fullname (found_key -> start_file );
732728 complaint (_ ("macro `%s' redefined at %s:%d; "
733729 "original definition at %s:%d" ),
734- name , source_fullname , line , found_key_fullname ,
730+ name , source_fullname .c_str (), line ,
731+ found_key_fullname .c_str (),
735732 found_key -> start_line );
736- xfree (found_key_fullname );
737- xfree (source_fullname );
738733 }
739734
740735 return found_key ;
@@ -854,16 +849,13 @@ macro_undef (struct macro_source_file *source, int line,
854849 #definition. */
855850 if (key -> end_file )
856851 {
857- char * source_fullname , * key_fullname ;
858-
859- source_fullname = macro_source_fullname (source );
860- key_fullname = macro_source_fullname (key -> end_file );
852+ std ::string source_fullname = macro_source_fullname (source );
853+ std ::string key_fullname = macro_source_fullname (key -> end_file );
861854 complaint (_ ("macro '%s' is #undefined twice,"
862855 " at %s:%d and %s:%d" ),
863- name , source_fullname , line , key_fullname ,
856+ name , source_fullname .c_str (), line ,
857+ key_fullname .c_str (),
864858 key -> end_line );
865- xfree (key_fullname );
866- xfree (source_fullname );
867859 }
868860
869861 /* Whether or not we've seen a prior #undefinition, wipe out
@@ -923,14 +915,9 @@ macro_lookup_definition (struct macro_source_file *source,
923915
924916 if (n )
925917 {
926- struct macro_definition * retval ;
927- char * source_fullname ;
928-
929- source_fullname = macro_source_fullname (source );
930- retval = fixup_definition (source_fullname , line ,
931- (struct macro_definition * ) n -> value );
932- xfree (source_fullname );
933- return retval ;
918+ std ::string source_fullname = macro_source_fullname (source );
919+ return fixup_definition (source_fullname .c_str (), line ,
920+ (struct macro_definition * ) n -> value );
934921 }
935922 else
936923 return 0 ;
@@ -974,12 +961,10 @@ foreach_macro (splay_tree_node node, void *arg)
974961 struct macro_for_each_data * datum = (struct macro_for_each_data * ) arg ;
975962 struct macro_key * key = (struct macro_key * ) node -> key ;
976963 struct macro_definition * def ;
977- char * key_fullname ;
978964
979- key_fullname = macro_source_fullname (key -> start_file );
980- def = fixup_definition (key_fullname , key -> start_line ,
965+ std :: string key_fullname = macro_source_fullname (key -> start_file );
966+ def = fixup_definition (key_fullname . c_str () , key -> start_line ,
981967 (struct macro_definition * ) node -> value );
982- xfree (key_fullname );
983968
984969 datum -> fn (key -> name , def , key -> start_file , key -> start_line );
985970 return 0 ;
@@ -1004,12 +989,10 @@ foreach_macro_in_scope (splay_tree_node node, void *info)
1004989 struct macro_for_each_data * datum = (struct macro_for_each_data * ) info ;
1005990 struct macro_key * key = (struct macro_key * ) node -> key ;
1006991 struct macro_definition * def ;
1007- char * datum_fullname ;
1008992
1009- datum_fullname = macro_source_fullname (datum -> file );
1010- def = fixup_definition (datum_fullname , datum -> line ,
993+ std :: string datum_fullname = macro_source_fullname (datum -> file );
994+ def = fixup_definition (datum_fullname . c_str () , datum -> line ,
1011995 (struct macro_definition * ) node -> value );
1012- xfree (datum_fullname );
1013996
1014997 /* See if this macro is defined before the passed-in line, and
1015998 extends past that line. */
@@ -1083,7 +1066,7 @@ free_macro_table (struct macro_table *table)
10831066
10841067/* See macrotab.h for the comment. */
10851068
1086- char *
1069+ std :: string
10871070macro_source_fullname (struct macro_source_file * file )
10881071{
10891072 const char * comp_dir = NULL ;
@@ -1092,7 +1075,7 @@ macro_source_fullname (struct macro_source_file *file)
10921075 comp_dir = COMPUNIT_DIRNAME (file -> table -> compunit_symtab );
10931076
10941077 if (comp_dir == NULL || IS_ABSOLUTE_PATH (file -> filename ))
1095- return xstrdup ( file -> filename ) ;
1078+ return file -> filename ;
10961079
1097- return concat (comp_dir , SLASH_STRING , file -> filename , ( char * ) NULL ) ;
1080+ return std :: string (comp_dir ) + SLASH_STRING + file -> filename ;
10981081}
0 commit comments