Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: dje@google.com (Doug Evans)
To: gdb-patches@sourceware.org
Subject: [RFA] symtab.c: Set "first" to zero.
Date: Tue, 10 Jul 2012 00:33:00 -0000	[thread overview]
Message-ID: <20120710003324.100001E13A1@ruffy2.mtv.corp.google.com> (raw)

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;


             reply	other threads:[~2012-07-10  0:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-10  0:33 Doug Evans [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120710003324.100001E13A1@ruffy2.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox