From 9074464c14b99872a7ce360c883c1b0dc20c75be Mon Sep 17 00:00:00 2001 From: Geoffrey Keating Date: Wed, 30 Jul 2003 06:43:33 +0000 Subject: [PATCH] cppfiles.c (stack_file): Leave filename as "" rather than "". * cppfiles.c (stack_file): Leave filename as "" rather than "". * line-map.h (linemap_add): Update comments. * line-map.c (linemap_add): Update comments, interpret zero-length filename as "". From-SVN: r69952 --- gcc/ChangeLog | 7 +++++++ gcc/cppfiles.c | 2 -- gcc/line-map.c | 15 ++++++++++++--- gcc/line-map.h | 7 +++++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 54fb2b22922..4bc73f3fdfc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2003-07-29 Geoffrey Keating + + * cppfiles.c (stack_file): Leave filename as "" rather than "". + * line-map.h (linemap_add): Update comments. + * line-map.c (linemap_add): Update comments, interpret zero-length + filename as "". + 2003-07-29 Nathanael Nerode * mkinstalldirs: Import autoconf 2.57 / automake 1.7 version. diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 562b0ab521c..66e4a6a9b0c 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -558,8 +558,6 @@ stack_file (cpp_reader *pfile, _cpp_file *file, bool import) /* Generate the call back. */ fname = file->name; - if (*fname == '\0') - fname = ""; _cpp_do_file_change (pfile, LC_ENTER, fname, 1, sysp); return true; diff --git a/gcc/line-map.c b/gcc/line-map.c index 50c9c881036..f04350d7806 100644 --- a/gcc/line-map.c +++ b/gcc/line-map.c @@ -61,11 +61,17 @@ linemap_free (struct line_maps *set) } /* Add a mapping of logical source line to physical source file and - line number. The text pointed to by TO_FILE must have a lifetime - at least as long as the final call to lookup_line (). + line number. + + The text pointed to by TO_FILE must have a lifetime + at least as long as the final call to lookup_line (). An empty + TO_FILE means standard input. If reason is LC_LEAVE, and + TO_FILE is NULL, then TO_FILE, TO_LINE and SYSP are given their + natural values considering the file we are returning to. FROM_LINE should be monotonic increasing across calls to this - function. */ + function. A call to this function can relocate the previous set of + maps, so any stored line_map pointers should not be used. */ const struct line_map * linemap_add (struct line_maps *set, enum lc_reason reason, @@ -85,6 +91,9 @@ linemap_add (struct line_maps *set, enum lc_reason reason, map = &set->maps[set->used++]; + if (to_file && *to_file == '\0') + to_file = ""; + /* If we don't keep our line maps consistent, we can easily segfault. Don't rely on the client to do it for us. */ if (set->depth == 0) diff --git a/gcc/line-map.h b/gcc/line-map.h index 1176743eede..dcb6f7dca48 100644 --- a/gcc/line-map.h +++ b/gcc/line-map.h @@ -74,8 +74,11 @@ extern void linemap_init (struct line_maps *); extern void linemap_free (struct line_maps *); /* Add a mapping of logical source line to physical source file and - line number. The text pointed to by TO_FILE must have a lifetime - at least as long as the line maps. If reason is LC_LEAVE, and + line number. + + The text pointed to by TO_FILE must have a lifetime + at least as long as the final call to lookup_line (). An empty + TO_FILE means standard input. If reason is LC_LEAVE, and TO_FILE is NULL, then TO_FILE, TO_LINE and SYSP are given their natural values considering the file we are returning to.