simplify substitute_path_rule_matches using filename_ncmp
At the time this function was written, there was no filename_ncmp, only FILENAME_CMP. So, in order to do an n-cmp, we had to make a local copy of the first n characters of our string and use that to perform the comparison. This patch simplifies the function's implementation, now that we have filename_ncmp. gdb/ChangeLog: * source.c (substitute_path_rule_matches): Simplify using filename_ncmp instead of FILENAME_CMP. Tested on x86_64-linux.
This commit is contained in:
parent
230cd560c8
commit
486ef3b933
|
@ -1,3 +1,8 @@
|
||||||
|
2014-06-02 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
|
* source.c (substitute_path_rule_matches): Simplify using
|
||||||
|
filename_ncmp instead of FILENAME_CMP.
|
||||||
|
|
||||||
2014-06-02 Joel Brobecker <brobecker@adacore.com>
|
2014-06-02 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
* source.c (substitute_path_rule_matches): Remove trailing spaces.
|
* source.c (substitute_path_rule_matches): Remove trailing spaces.
|
||||||
|
|
11
gdb/source.c
11
gdb/source.c
|
@ -932,21 +932,14 @@ substitute_path_rule_matches (const struct substitute_path_rule *rule,
|
||||||
{
|
{
|
||||||
const int from_len = strlen (rule->from);
|
const int from_len = strlen (rule->from);
|
||||||
const int path_len = strlen (path);
|
const int path_len = strlen (path);
|
||||||
char *path_start;
|
|
||||||
|
|
||||||
if (path_len < from_len)
|
if (path_len < from_len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* The substitution rules are anchored at the start of the path,
|
/* The substitution rules are anchored at the start of the path,
|
||||||
so the path should start with rule->from. There is no filename
|
so the path should start with rule->from. */
|
||||||
comparison routine, so we need to extract the first FROM_LEN
|
|
||||||
characters from PATH first and use that to do the comparison. */
|
|
||||||
|
|
||||||
path_start = alloca (from_len + 1);
|
if (filename_ncmp (path, rule->from, from_len) != 0)
|
||||||
strncpy (path_start, path, from_len);
|
|
||||||
path_start[from_len] = '\0';
|
|
||||||
|
|
||||||
if (FILENAME_CMP (path_start, rule->from) != 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Make sure that the region in the path that matches the substitution
|
/* Make sure that the region in the path that matches the substitution
|
||||||
|
|
Loading…
Reference in New Issue