diff options
author | Tom Tromey <tom@tromey.com> | 2023-04-04 12:50:03 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-05-05 07:49:43 -0600 |
commit | 02601231fdd91a7bd4837ce202906ea2ce661489 (patch) | |
tree | c9745539b4869c0f70b698b8ac0e4366618154c1 /gdb/utils.c | |
parent | 4891c459927d9a9c0f516c35e2d9d4ce212dd06e (diff) | |
download | gdb-02601231fdd91a7bd4837ce202906ea2ce661489.zip gdb-02601231fdd91a7bd4837ce202906ea2ce661489.tar.gz gdb-02601231fdd91a7bd4837ce202906ea2ce661489.tar.bz2 |
Simplify auto_load_expand_dir_vars and remove substitute_path_component
This simplifies auto_load_expand_dir_vars to first split the string,
then do any needed substitutions. This was suggested by Simon, and is
much simpler than the current approach.
Then this patch also removes substitute_path_component, as it is no
longer called. This is nice because it helps with the long term goal
of removing utils.h.
Regression tested on x86-64 Fedora 36.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index 3af54ec..0347496 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3346,51 +3346,6 @@ parse_pid_to_attach (const char *args) return pid; } -/* Substitute all occurrences of string FROM by string TO in *STRINGP. *STRINGP - must come from xrealloc-compatible allocator and it may be updated. FROM - needs to be delimited by IS_DIR_SEPARATOR or DIRNAME_SEPARATOR (or be - located at the start or end of *STRINGP. */ - -void -substitute_path_component (char **stringp, const char *from, const char *to) -{ - char *string = *stringp, *s; - const size_t from_len = strlen (from); - const size_t to_len = strlen (to); - - for (s = string;;) - { - s = strstr (s, from); - if (s == NULL) - break; - - if ((s == string || IS_DIR_SEPARATOR (s[-1]) - || s[-1] == DIRNAME_SEPARATOR) - && (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len]) - || s[from_len] == DIRNAME_SEPARATOR)) - { - char *string_new; - - string_new - = (char *) xrealloc (string, (strlen (string) + to_len + 1)); - - /* Relocate the current S pointer. */ - s = s - string + string_new; - string = string_new; - - /* Replace from by to. */ - memmove (&s[to_len], &s[from_len], strlen (&s[from_len]) + 1); - memcpy (s, to, to_len); - - s += to_len; - } - else - s++; - } - - *stringp = string; -} - #ifdef HAVE_WAITPID #ifdef SIGALRM |