From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CeFiBLM22WoyIwkAWB0awg (envelope-from ) for ; Wed, 21 Oct 2026 18:03:31 -0400 Received: by simark.ca (Postfix, from userid 112) id 0BFE41E051; Wed, 21 Oct 2026 18:03:31 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7E55B1E04D for ; Wed, 21 Oct 2026 18:03:30 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 699A94BA23D7 for ; Wed, 21 Oct 2026 22:03:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 699A94BA23D7 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E56B44BA2E3C for ; Wed, 21 Oct 2026 22:03:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E56B44BA2E3C Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E56B44BA2E3C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792620185; cv=none; b=vZRiZivM5wuTG3UQsPXdqRD/Rn8WjOfG/ZwwF6DIN7Muxc/VFI6uAuL9aKEirevgV1/aFA2moSNsYDsx06qNnPouQHwwvFI6+lGICzSlaUkv5Nj/VyCvzYyIf7a+O9F9R8oXifdsVwKcptGxd2N2/8Zatfsthe8pVztJCtVKX7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792620185; c=relaxed/simple; bh=KrlAk2fNyK9xrLwV/Wf7fVm3D136VLdqboMlg7Rbstg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=XONOY4iowAW+11AcZ+VbBIEQWq6phnINA4u8mPJitvMtANweSG33H5vTnGohOQP/J4m0YLCdriFV3QYAF2OOT4JJ5uADZUiqvKumjkexTrfEoM12k0wiYkcL4ObFoP7GD/FyOmlVHKg/yAvk53EhCpIyf/5L49qyHsiR04RNrcQ= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E56B44BA2E3C Received: by simark.ca (Postfix) id 82AB41E050; Wed, 21 Oct 2026 18:03:03 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [pushed 2/3] gdb: remove strip_leading_path_elements and count_path_elements Date: Wed, 21 Oct 2026 18:02:45 -0400 Message-ID: <20261021220252.683337-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261021220252.683337-1-simon.marchi@efficios.com> References: <20261021220252.683337-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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 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 gdb_rl_tilde_expand (const char *path); -- 2.56.0