Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [pushed 2/3] gdb: remove strip_leading_path_elements and count_path_elements
Date: Wed, 21 Oct 2026 18:02:45 -0400	[thread overview]
Message-ID: <20261021220252.683337-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20261021220252.683337-1-simon.marchi@efficios.com>

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


  reply	other threads:[~2026-10-21 22:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 22:02 [pushed 1/3] gdb: remove strcmp_iw_ordered Simon Marchi
2026-10-21 22:02 ` Simon Marchi [this message]
2026-10-21 22:02 ` [pushed 3/3] gdb: remove demangler_vwarning Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261021220252.683337-2-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox