2012-07-12 Doug Evans * symtab.c (filename_seen): Set *first to 0. (output_source_filename): Update. Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.316 diff -u -p -r1.316 symtab.c --- symtab.c 29 Jun 2012 22:46:45 -0000 1.316 +++ symtab.c 12 Jul 2012 21:29:52 -0000 @@ -3108,7 +3108,7 @@ operator_chars (char *p, char **end) /* If FILE is not already in the table of files, return zero; otherwise return non-zero. Optionally add FILE to the table if ADD is non-zero. If *FIRST is non-zero, forget the old table - contents. */ + contents and then set *FIRST = 0. */ static int filename_seen (const char *file, int add, int *first) @@ -3128,6 +3128,7 @@ filename_seen (const char *file, int add if (tab == NULL) tab = (const char **) xmalloc (tab_alloc_size * sizeof (*tab)); tab_cur_size = 0; + *first = 0; } /* Is FILE in tab? */ @@ -3157,6 +3158,8 @@ filename_seen (const char *file, int add static void output_source_filename (const char *name, int *first) { + int is_first = *first; + /* Since a single source file can result in several partial symbol tables, we need to avoid printing it more than once. Note: if some of the psymtabs are read in and some are not, it gets @@ -3166,18 +3169,15 @@ output_source_filename (const char *name situation. I'm not sure whether this can also happen for symtabs; it doesn't hurt to check. */ - /* Was NAME already seen? */ + /* Was NAME already seen? + Note: filename_seen resets *first. */ if (filename_seen (name, 1, first)) { /* Yes; don't print it again. */ return; } - /* No; print it and reset *FIRST. */ - if (*first) - { - *first = 0; - } - else + + if (! is_first) { printf_filtered (", "); }