mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 14:49:38 +08:00
2006-02-21 Andrew Stubbs <andrew.stubbs@st.com>
* defs.h (directory_switch): Add prototype. * main.c (captured_main): Use directory_switch() instead of directory_command() to add directories from the -d switch. * source.c (directory_switch): New function. (add_path): Use buildargv() to parse spaces in filenames properly. Strip multiple trailing '/' rather than just one.
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
2006-02-21 Andrew Stubbs <andrew.stubbs@st.com>
|
||||||
|
|
||||||
|
* defs.h (directory_switch): Add prototype.
|
||||||
|
* main.c (captured_main): Use directory_switch() instead of
|
||||||
|
directory_command() to add directories from the -d switch.
|
||||||
|
* source.c (directory_switch): New function.
|
||||||
|
(add_path): Use buildargv() to parse spaces in filenames properly.
|
||||||
|
Strip multiple trailing '/' rather than just one.
|
||||||
|
|
||||||
2006-02-21 Andrew Stubbs <andrew.stubbs@st.com>
|
2006-02-21 Andrew Stubbs <andrew.stubbs@st.com>
|
||||||
|
|
||||||
* symfile.c (add_symbol_file_command): Use buildargv(), instead of
|
* symfile.c (add_symbol_file_command): Use buildargv(), instead of
|
||||||
|
@ -611,6 +611,8 @@ extern void add_path (char *, char **, int);
|
|||||||
|
|
||||||
extern void directory_command (char *, int);
|
extern void directory_command (char *, int);
|
||||||
|
|
||||||
|
extern void directory_switch (char *, int);
|
||||||
|
|
||||||
extern char *source_path;
|
extern char *source_path;
|
||||||
|
|
||||||
extern void init_source_path (void);
|
extern void init_source_path (void);
|
||||||
|
@ -667,7 +667,7 @@ extern int gdbtk_test (char *);
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ndir; i++)
|
for (i = 0; i < ndir; i++)
|
||||||
catch_command_errors (directory_command, dirarg[i], 0, RETURN_MASK_ALL);
|
catch_command_errors (directory_switch, dirarg[i], 0, RETURN_MASK_ALL);
|
||||||
xfree (dirarg);
|
xfree (dirarg);
|
||||||
|
|
||||||
if (execarg != NULL
|
if (execarg != NULL
|
||||||
|
81
gdb/source.c
81
gdb/source.c
@ -378,6 +378,15 @@ directory_command (char *dirname, int from_tty)
|
|||||||
forget_cached_source_info ();
|
forget_cached_source_info ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add a path given with the -d command line switch.
|
||||||
|
This will not be quoted so we must not treat spaces as separators. */
|
||||||
|
|
||||||
|
void
|
||||||
|
directory_switch (char *dirname, int from_tty)
|
||||||
|
{
|
||||||
|
add_path (dirname, &source_path, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Add zero or more directories to the front of an arbitrary path. */
|
/* Add zero or more directories to the front of an arbitrary path. */
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -397,56 +406,72 @@ add_path (char *dirname, char **which_path, int parse_separators)
|
|||||||
{
|
{
|
||||||
char *old = *which_path;
|
char *old = *which_path;
|
||||||
int prefix = 0;
|
int prefix = 0;
|
||||||
|
char **argv = NULL;
|
||||||
|
char *arg;
|
||||||
|
int argv_index = 0;
|
||||||
|
|
||||||
if (dirname == 0)
|
if (dirname == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dirname = xstrdup (dirname);
|
if (parse_separators)
|
||||||
make_cleanup (xfree, dirname);
|
{
|
||||||
|
/* This will properly parse the space and tab separators
|
||||||
|
and any quotes that may exist. DIRNAME_SEPARATOR will
|
||||||
|
be dealt with later. */
|
||||||
|
argv = buildargv (dirname);
|
||||||
|
make_cleanup_freeargv (argv);
|
||||||
|
|
||||||
|
if (argv == NULL)
|
||||||
|
nomem (0);
|
||||||
|
|
||||||
|
arg = argv[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arg = xstrdup (dirname);
|
||||||
|
make_cleanup (xfree, arg);
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
char *name = dirname;
|
char *name = arg;
|
||||||
char *p;
|
char *p;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
{
|
{
|
||||||
char *separator = NULL;
|
char *separator = NULL;
|
||||||
char *space = NULL;
|
|
||||||
char *tab = NULL;
|
|
||||||
|
|
||||||
|
/* Spaces and tabs will have been removed by buildargv().
|
||||||
|
The directories will there be split into a list but
|
||||||
|
each entry may still contain DIRNAME_SEPARATOR. */
|
||||||
if (parse_separators)
|
if (parse_separators)
|
||||||
{
|
separator = strchr (name, DIRNAME_SEPARATOR);
|
||||||
separator = strchr (name, DIRNAME_SEPARATOR);
|
|
||||||
space = strchr (name, ' ');
|
|
||||||
tab = strchr (name, '\t');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (separator == 0 && space == 0 && tab == 0)
|
if (separator == 0)
|
||||||
p = dirname = name + strlen (name);
|
p = arg = name + strlen (name);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = 0;
|
p = separator;
|
||||||
if (separator != 0 && (p == 0 || separator < p))
|
arg = p + 1;
|
||||||
p = separator;
|
while (*arg == DIRNAME_SEPARATOR)
|
||||||
if (space != 0 && (p == 0 || space < p))
|
++arg;
|
||||||
p = space;
|
|
||||||
if (tab != 0 && (p == 0 || tab < p))
|
|
||||||
p = tab;
|
|
||||||
dirname = p + 1;
|
|
||||||
while (*dirname == DIRNAME_SEPARATOR
|
|
||||||
|| *dirname == ' '
|
|
||||||
|| *dirname == '\t')
|
|
||||||
++dirname;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If there are no more directories in this argument then start
|
||||||
|
on the next argument next time round the loop (if any). */
|
||||||
|
if (*arg == '\0')
|
||||||
|
arg = parse_separators ? argv[++argv_index] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
|
/* name is the start of the directory.
|
||||||
|
p is the separator (or null) following the end. */
|
||||||
|
|
||||||
|
while (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
|
||||||
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
||||||
/* On MS-DOS and MS-Windows, h:\ is different from h: */
|
/* On MS-DOS and MS-Windows, h:\ is different from h: */
|
||||||
&& !(p == name + 3 && name[1] == ':') /* "d:/" */
|
&& !(p == name + 3 && name[1] == ':') /* "d:/" */
|
||||||
#endif
|
#endif
|
||||||
&& IS_DIR_SEPARATOR (p[-1]))
|
&& IS_DIR_SEPARATOR (p[-1]))
|
||||||
/* Sigh. "foo/" => "foo" */
|
/* Sigh. "foo/" => "foo" */
|
||||||
--p;
|
--p;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
@ -577,7 +602,7 @@ add_path (char *dirname, char **which_path, int parse_separators)
|
|||||||
}
|
}
|
||||||
skip_dup:;
|
skip_dup:;
|
||||||
}
|
}
|
||||||
while (*dirname != '\0');
|
while (arg != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user