Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] symtab.c: Set "first" to zero.
@ 2012-07-10  0:33 Doug Evans
  2012-07-10 16:01 ` Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Doug Evans @ 2012-07-10  0:33 UTC (permalink / raw)
  To: gdb-patches

Hi.

The "first" argument to filename_seen is used to control the
initialization of the data structure used to track whether
a file name has been seen yet.
But these two routines don't set it to zero after calling
filename_seen so the data structure is continually reinitialized
resulting in duplicate names in the output.
The completion machinery does its own duplicate elimination so
the effect of this bug is hidden.  I just noticed it while browsing the code.

Ok to check in?

2012-07-09  Doug Evans  <dje@google.com>

	* symtab.c (maybe_add_partial_symtab_filename): Set "first" to zero
	after calling filename_seen.
	(make_source_files_completion_list): Ditto.

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	9 Jul 2012 23:46:45 -0000
@@ -4576,6 +4576,7 @@ maybe_add_partial_symtab_filename (const
 	  && filename_ncmp (base_name, data->text, data->text_len) == 0)
 	add_filename_to_list (base_name, data->text, data->word, data->list);
     }
+  *data->first = 0;
 }
 
 /* Return a vector of all source files whose names begin with matching
@@ -4623,6 +4624,7 @@ make_source_files_completion_list (char 
 	      && filename_ncmp (base_name, text, text_len) == 0)
 	    add_filename_to_list (base_name, text, word, &list);
 	}
+      first = 0;
     }
 
   datum.first = &first;


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-07-13 18:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-10  0:33 [RFA] symtab.c: Set "first" to zero Doug Evans
2012-07-10 16:01 ` Tom Tromey
2012-07-10 17:26   ` Doug Evans
2012-07-12 21:33   ` Doug Evans
2012-07-13 14:57     ` Tom Tromey
2012-07-13 17:39       ` Doug Evans
2012-07-13 17:48         ` Tom Tromey
2012-07-13 18:41           ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox