aboutsummaryrefslogtreecommitdiff
path: root/gdb/source.c
diff options
context:
space:
mode:
authorEdjunior Barbosa Machado <emachado@linux.vnet.ibm.com>2014-01-07 17:03:06 -0200
committerEdjunior Barbosa Machado <emachado@linux.vnet.ibm.com>2014-01-07 17:03:06 -0200
commit5e3f4fab9ab17362d758871ad9371042918c9374 (patch)
tree041835d162d8171582e49f0a3006df36359ded3d /gdb/source.c
parent6104cb7ae77a9514ada188ded4095eed39ce267e (diff)
downloadgdb-5e3f4fab9ab17362d758871ad9371042918c9374.zip
gdb-5e3f4fab9ab17362d758871ad9371042918c9374.tar.gz
gdb-5e3f4fab9ab17362d758871ad9371042918c9374.tar.bz2
Fix dir command for duplicated paths and add a new testcase.
gdb/ChangeLog: 2014-01-07 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> * source.c (add_path): Fix check for duplicated paths in the previously included paths. gdb/testsuite/ChangeLog: 2014-01-07 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.base/source-dir.exp: New file.
Diffstat (limited to 'gdb/source.c')
-rw-r--r--gdb/source.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/gdb/source.c b/gdb/source.c
index b75a7b4..c112765 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -574,17 +574,33 @@ add_path (char *dirname, char **which_path, int parse_separators)
char tinybuf[2];
p = *which_path;
- /* FIXME: we should use realpath() or its work-alike
- before comparing. Then all the code above which
- removes excess slashes and dots could simply go away. */
- if (!filename_cmp (p, name))
+ while (1)
{
- /* Found it in the search path, remove old copy. */
- if (p > *which_path)
- p--; /* Back over leading separator. */
- if (prefix > p - *which_path)
- goto skip_dup; /* Same dir twice in one cmd. */
- memmove (p, &p[len + 1], strlen (&p[len + 1]) + 1); /* Copy from next \0 or : */
+ /* FIXME: we should use realpath() or its work-alike
+ before comparing. Then all the code above which
+ removes excess slashes and dots could simply go away. */
+ if (!filename_ncmp (p, name, len)
+ && (p[len] == '\0' || p[len] == DIRNAME_SEPARATOR))
+ {
+ /* Found it in the search path, remove old copy. */
+ if (p > *which_path)
+ {
+ /* Back over leading separator. */
+ p--;
+ }
+ if (prefix > p - *which_path)
+ {
+ /* Same dir twice in one cmd. */
+ goto skip_dup;
+ }
+ /* Copy from next '\0' or ':'. */
+ memmove (p, &p[len + 1], strlen (&p[len + 1]) + 1);
+ }
+ p = strchr (p, DIRNAME_SEPARATOR);
+ if (p != 0)
+ ++p;
+ else
+ break;
}
tinybuf[0] = DIRNAME_SEPARATOR;