* [pushed 1/3] gdb: remove strcmp_iw_ordered
@ 2026-10-21 22:02 Simon Marchi
2026-10-21 22:02 ` [pushed 2/3] gdb: remove strip_leading_path_elements and count_path_elements Simon Marchi
2026-10-21 22:02 ` [pushed 3/3] gdb: remove demangler_vwarning Simon Marchi
0 siblings, 2 replies; 3+ messages in thread
From: Simon Marchi @ 2026-10-21 22:02 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
strcmp_iw_ordered has been unused since commit b3f7f1e9d974 ("gdb:
remove psymtab.{c,h}", 2026-02-27). Remove it.
Change-Id: I80cd927a346159c04a95aadcf9501bc3d5edafa6
---
gdb/utils.c | 115 ----------------------------------------------------
gdb/utils.h | 2 -
2 files changed, 117 deletions(-)
diff --git a/gdb/utils.c b/gdb/utils.c
index 5deecdbba942..b644a936312b 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3142,121 +3142,6 @@ strcmp_iw (const char *string1, const char *string2)
strncmp_iw_mode::MATCH_PARAMS, language_minimal);
}
-/* This is like strcmp except that it ignores whitespace and treats
- '(' as the first non-NULL character in terms of ordering. Like
- strcmp (and unlike strcmp_iw), it returns negative if STRING1 <
- STRING2, 0 if STRING2 = STRING2, and positive if STRING1 > STRING2
- according to that ordering.
-
- If a list is sorted according to this function and if you want to
- find names in the list that match some fixed NAME according to
- strcmp_iw(LIST_ELT, NAME), then the place to start looking is right
- where this function would put NAME.
-
- This function must be neutral to the CASE_SENSITIVITY setting as the user
- may choose it during later lookup. Therefore this function always sorts
- primarily case-insensitively and secondarily case-sensitively.
-
- Here are some examples of why using strcmp to sort is a bad idea:
-
- Whitespace example:
-
- Say your partial symtab contains: "foo<char *>", "goo". Then, if
- we try to do a search for "foo<char*>", strcmp will locate this
- after "foo<char *>" and before "goo". Then lookup_partial_symbol
- will start looking at strings beginning with "goo", and will never
- see the correct match of "foo<char *>".
-
- Parenthesis example:
-
- In practice, this is less like to be an issue, but I'll give it a
- shot. Let's assume that '$' is a legitimate character to occur in
- symbols. (Which may well even be the case on some systems.) Then
- say that the partial symbol table contains "foo$" and "foo(int)".
- strcmp will put them in this order, since '$' < '('. Now, if the
- user searches for "foo", then strcmp will sort "foo" before "foo$".
- Then lookup_partial_symbol will notice that strcmp_iw("foo$",
- "foo") is false, so it won't proceed to the actual match of
- "foo(int)" with "foo". */
-
-int
-strcmp_iw_ordered (const char *string1, const char *string2)
-{
- const char *saved_string1 = string1, *saved_string2 = string2;
- enum case_sensitivity case_pass = case_sensitive_off;
-
- for (;;)
- {
- /* C1 and C2 are valid only if *string1 != '\0' && *string2 != '\0'.
- Provide stub characters if we are already at the end of one of the
- strings. */
- char c1 = 'X', c2 = 'X';
-
- while (*string1 != '\0' && *string2 != '\0')
- {
- while (c_isspace (*string1))
- string1++;
- while (c_isspace (*string2))
- string2++;
-
- switch (case_pass)
- {
- case case_sensitive_off:
- c1 = c_tolower (*string1);
- c2 = c_tolower (*string2);
- break;
- case case_sensitive_on:
- c1 = *string1;
- c2 = *string2;
- break;
- }
- if (c1 != c2)
- break;
-
- if (*string1 != '\0')
- {
- string1++;
- string2++;
- }
- }
-
- switch (*string1)
- {
- /* Characters are non-equal unless they're both '\0'; we want to
- make sure we get the comparison right according to our
- comparison in the cases where one of them is '\0' or '('. */
- case '\0':
- if (*string2 == '\0')
- break;
- else
- return -1;
- case '(':
- if (*string2 == '\0')
- return 1;
- else
- return -1;
- default:
- if (*string2 == '\0' || *string2 == '(')
- return 1;
- else if (c1 > c2)
- return 1;
- else if (c1 < c2)
- return -1;
- /* PASSTHRU */
- }
-
- if (case_pass == case_sensitive_on)
- return 0;
-
- /* Otherwise the strings were equal in case insensitive way, make
- a more fine grained comparison in a case sensitive way. */
-
- case_pass = case_sensitive_on;
- string1 = saved_string1;
- string2 = saved_string2;
- }
-}
-
\f
static void
diff --git a/gdb/utils.h b/gdb/utils.h
index 07d707ce9cf0..5aac6f0b33a8 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -87,8 +87,6 @@ extern int strncmp_iw (const char *string1, const char *string2,
therefore be avoided if a more suitable language is available. */
extern int strcmp_iw (const char *string1, const char *string2);
-extern int strcmp_iw_ordered (const char *, const char *);
-
/* Reset the prompt_for_continue clock. */
void reset_prompt_for_continue_wait_time (void);
/* Return the time spent in prompt_for_continue. */
base-commit: 4f1619d9d9d06f94e55f2bbe6e27b288714118d0
--
2.56.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pushed 2/3] gdb: remove strip_leading_path_elements and count_path_elements
2026-10-21 22:02 [pushed 1/3] gdb: remove strcmp_iw_ordered Simon Marchi
@ 2026-10-21 22:02 ` Simon Marchi
2026-10-21 22:02 ` [pushed 3/3] gdb: remove demangler_vwarning Simon Marchi
1 sibling, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2026-10-21 22:02 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
strip_leading_path_elements has been unused since commit 5ed98c177f9a
("gdb: introduce '**' for skip globs", 2026-02-04).
count_path_elements was only referred to by the comment of
strip_leading_path_elements. Remove them both.
Change-Id: I2a452238da51eb3e6bf574d1b2203c9a877ba3c1
---
gdb/utils.c | 77 -----------------------------------------------------
gdb/utils.h | 4 ---
2 files changed, 81 deletions(-)
diff --git a/gdb/utils.c b/gdb/utils.c
index b644a936312b..63ded1b4a323 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3435,83 +3435,6 @@ gdb_filename_fnmatch (const char *pattern, const char *string, int flags)
return fnmatch (pattern, string, flags);
}
-/* Return the number of path elements in PATH.
- / = 1
- /foo = 2
- /foo/ = 2
- foo/bar = 2
- foo/ = 1 */
-
-int
-count_path_elements (const char *path)
-{
- int count = 0;
- const char *p = path;
-
- if (HAS_DRIVE_SPEC (p))
- {
- p = STRIP_DRIVE_SPEC (p);
- ++count;
- }
-
- while (*p != '\0')
- {
- if (IS_DIR_SEPARATOR (*p))
- ++count;
- ++p;
- }
-
- /* Backup one if last character is /, unless it's the only one. */
- if (p > path + 1 && IS_DIR_SEPARATOR (p[-1]))
- --count;
-
- /* Add one for the file name, if present. */
- if (p > path && !IS_DIR_SEPARATOR (p[-1]))
- ++count;
-
- return count;
-}
-
-/* Remove N leading path elements from PATH.
- N must be non-negative.
- If PATH has more than N path elements then return NULL.
- If PATH has exactly N path elements then return "".
- See count_path_elements for a description of how we do the counting. */
-
-const char *
-strip_leading_path_elements (const char *path, int n)
-{
- int i = 0;
- const char *p = path;
-
- gdb_assert (n >= 0);
-
- if (n == 0)
- return p;
-
- if (HAS_DRIVE_SPEC (p))
- {
- p = STRIP_DRIVE_SPEC (p);
- ++i;
- }
-
- while (i < n)
- {
- while (*p != '\0' && !IS_DIR_SEPARATOR (*p))
- ++p;
- if (*p == '\0')
- {
- if (i + 1 == n)
- return "";
- return NULL;
- }
- ++p;
- ++i;
- }
-
- return p;
-}
-
/* See utils.h. */
gdb::unique_xmalloc_ptr<char>
diff --git a/gdb/utils.h b/gdb/utils.h
index 5aac6f0b33a8..7e2de3ba7949 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -133,10 +133,6 @@ extern int gdb_filename_fnmatch (const char *pattern, const char *string,
std::string gdb_ldirname (const char *filename);
-extern int count_path_elements (const char *path);
-
-extern const char *strip_leading_path_elements (const char *path, int n);
-
/* Wrapper around readline's tilde_expand, to return a unique pointer. */
extern gdb::unique_xmalloc_ptr<char> gdb_rl_tilde_expand (const char *path);
--
2.56.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pushed 3/3] gdb: remove demangler_vwarning
2026-10-21 22:02 [pushed 1/3] gdb: remove strcmp_iw_ordered Simon Marchi
2026-10-21 22:02 ` [pushed 2/3] gdb: remove strip_leading_path_elements and count_path_elements Simon Marchi
@ 2026-10-21 22:02 ` Simon Marchi
1 sibling, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2026-10-21 22:02 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
demangler_vwarning is only used in utils.c, by demangler_warning.
Remove it and inline its content in demangler_warning.
Change-Id: Ice44984063ff47cd2dfa9cb24c58fce1a2b53ba7
---
gdb/utils.c | 12 +++---------
gdb/utils.h | 4 ----
2 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/gdb/utils.c b/gdb/utils.c
index 63ded1b4a323..b3ba01d0e47d 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -532,18 +532,12 @@ static struct internal_problem demangler_warning_problem = {
};
void
-demangler_vwarning (const char *file, int line, const char *fmt, va_list ap)
-{
- internal_vproblem (&demangler_warning_problem, file, line, fmt, ap);
-}
-
-void
-demangler_warning (const char *file, int line, const char *string, ...)
+demangler_warning (const char *file, int line, const char *fmt, ...)
{
va_list ap;
- va_start (ap, string);
- demangler_vwarning (file, line, string, ap);
+ va_start (ap, fmt);
+ internal_vproblem (&demangler_warning_problem, file, line, fmt, ap);
va_end (ap);
}
diff --git a/gdb/utils.h b/gdb/utils.h
index 7e2de3ba7949..7e59037bf5f5 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -315,10 +315,6 @@ extern void (*deprecated_error_begin_hook) (void);
extern const char *warning_pre_print;
-extern void demangler_vwarning (const char *file, int line,
- const char *, va_list ap)
- ATTRIBUTE_PRINTF (3, 0);
-
extern void demangler_warning (const char *file, int line,
const char *, ...) ATTRIBUTE_PRINTF (3, 4);
--
2.56.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-21 22:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 22:02 [pushed 1/3] gdb: remove strcmp_iw_ordered Simon Marchi
2026-10-21 22:02 ` [pushed 2/3] gdb: remove strip_leading_path_elements and count_path_elements Simon Marchi
2026-10-21 22:02 ` [pushed 3/3] gdb: remove demangler_vwarning Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox