From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by sourceware.org (Postfix) with ESMTPS id F1E61385F3CD for ; Wed, 14 Dec 2022 19:46:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1E61385F3CD Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd30.google.com with SMTP id r72so3994871iod.5 for ; Wed, 14 Dec 2022 11:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XsW5N7uA4qKD92Cf+msCIbsE5nqAB4Ace7KK0qS3Js0=; b=gCdzDSrfWhEiSuNJWpFXq4f6nVg8KJ/p6Nzax/+0FzQFSg6835gt50dgMEpfVP55/v BakcVCLkhZgZHxxqHbpjQ7xsCDOUZVa6y5WKWjbqzAL+a3eksWjQHsh7tZDru0lUvkNJ jjfU5bbLXTDShk06Vn41UE+5RVnUczwyghP9gPDOB+21VBri5uNJZjkgXTqCWOXOMVwB 7RtmXVZUj5zS8kP99fkCpzZv5KXihO4pDsHiNeVm/hziPrd/RFpqKrUuE85ElEPSrtR2 Zk2PAnfRYpTU36H/NAZIFhT0gaFAhWnjntUy6UerbF5mnDxEjaPhsN8pdEUjjKdBvL3P 9rsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XsW5N7uA4qKD92Cf+msCIbsE5nqAB4Ace7KK0qS3Js0=; b=yuknZEzT8OlUVsSkYD3h90Hka0hVqnoK+vzEERn41eODjLzTn/5bxS4fma00/peI46 P5cOkRFbT58tp5ftQrM6FXBi3jsKU/xzfog1SRL2KSBxJjCGeXqYTMxUl5tObRFNF3hu D/eQ9+ls9mZXjC1JOpXS0XIeYqyG+OXPpz/hHFRstxAaTBAlPmOSXE0UpLrQ7nvVpL6d gKT4JKXliaCwBCiZYX9L08a3wj3tWbZsGUcMqBLUa/YVl5THssT4/YEG76m8SpISuIor SF17YsFNKKYtFpcVH3v/z6B3ESub1vSsy+ATBcGhAUcknk3oir1YZGRIK8Ez/QUBSdQv JYxQ== X-Gm-Message-State: ANoB5pkx0ocgYu1NwHw3Zi7ukqnK1/EV0Ec/LzXE6OTgUePyvrGZCR08 hJ3ghRJp7mvdSbKekS3M+tk3fphRuZOnhzN/ X-Google-Smtp-Source: AA0mqf7Mt/meC3Ctc7whuwvXeSu3SGeDKm+WWmh+2l9bZ8BMNIIifHO3/VrqJ6kiOTwZsEsj8J4KPQ== X-Received: by 2002:a05:6602:3687:b0:6e3:8b2:3ea3 with SMTP id bf7-20020a056602368700b006e308b23ea3mr8253594iob.9.1671047176955; Wed, 14 Dec 2022 11:46:16 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id t26-20020a02b19a000000b0036332a07adcsm1956460jah.173.2022.12.14.11.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 11:46:16 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/2] Remove subset_compare Date: Wed, 14 Dec 2022 12:46:05 -0700 Message-Id: <20221214194606.4141035-2-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 In-Reply-To: <20221214194606.4141035-1-tromey@adacore.com> References: <20221214194606.4141035-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: I stumbled across subset_compare today, and after looking at the callers I realized it could be removed and replaced with calls to startswith. --- gdb/stack.c | 6 +++--- gdb/tui/tui-win.c | 4 ++-- gdb/utils.c | 20 -------------------- gdb/utils.h | 2 -- 4 files changed, 5 insertions(+), 27 deletions(-) diff --git a/gdb/stack.c b/gdb/stack.c index 4ad51c2eb50..c7d392842ae 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -2140,17 +2140,17 @@ parse_backtrace_qualifiers (const char *arg, if (this_arg.empty ()) return arg; - if (subset_compare (this_arg.c_str (), "no-filters")) + if (startswith ("no-filters", this_arg)) { if (bt_cmd_opts != nullptr) bt_cmd_opts->no_filters = true; } - else if (subset_compare (this_arg.c_str (), "full")) + else if (startswith ("full", this_arg)) { if (bt_cmd_opts != nullptr) bt_cmd_opts->full = true; } - else if (subset_compare (this_arg.c_str (), "hide")) + else if (startswith ("hide", this_arg)) { if (bt_cmd_opts != nullptr) bt_cmd_opts->hide = true; diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index e24763c0072..bad8ffe0972 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -711,9 +711,9 @@ tui_set_focus_command (const char *arg, int from_tty) struct tui_win_info *win_info = NULL; - if (subset_compare (arg, "next")) + if (startswith ("next", arg)) win_info = tui_next_win (tui_win_with_focus ()); - else if (subset_compare (arg, "prev")) + else if (startswith ("prev", arg)) win_info = tui_prev_win (tui_win_with_focus ()); else win_info = tui_partial_win_by_name (arg); diff --git a/gdb/utils.c b/gdb/utils.c index c37d9add500..5c110daa4ae 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3109,26 +3109,6 @@ streq (const char *lhs, const char *rhs) -/* - ** subset_compare() - ** Answer whether string_to_compare is a full or partial match to - ** template_string. The partial match must be in sequence starting - ** at index 0. - */ -int -subset_compare (const char *string_to_compare, const char *template_string) -{ - int match; - - if (template_string != NULL && string_to_compare != NULL - && strlen (string_to_compare) <= strlen (template_string)) - match = - (startswith (template_string, string_to_compare)); - else - match = 0; - return match; -} - static void show_debug_timestamp (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) diff --git a/gdb/utils.h b/gdb/utils.h index d2acf899ba2..ad7c94988b7 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -102,8 +102,6 @@ extern int strcmp_iw_ordered (const char *, const char *); extern bool streq (const char *, const char *); -extern int subset_compare (const char *, const char *); - /* Compare C strings for std::sort. */ static inline bool -- 2.34.3