public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 2/2] Move streq and compare_cstrings to gdbsupport
Date: Wed, 14 Dec 2022 12:46:06 -0700	[thread overview]
Message-ID: <20221214194606.4141035-3-tromey@adacore.com> (raw)
In-Reply-To: <20221214194606.4141035-1-tromey@adacore.com>

It seems to me that streq and compare_cstrings belong near the other
string utility functions in common-utils.h; and furthermore that streq
ought to be inlined.  This patch makes this change.
---
 gdb/utils.c               |  8 --------
 gdb/utils.h               | 12 ------------
 gdbsupport/common-utils.h | 16 ++++++++++++++++
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/gdb/utils.c b/gdb/utils.c
index 5c110daa4ae..74917f25ab9 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3099,14 +3099,6 @@ strcmp_iw_ordered (const char *string1, const char *string2)
     }
 }
 
-/* See utils.h.  */
-
-bool
-streq (const char *lhs, const char *rhs)
-{
-  return !strcmp (lhs, rhs);
-}
-
 \f
 
 static void
diff --git a/gdb/utils.h b/gdb/utils.h
index ad7c94988b7..509361dc429 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -98,18 +98,6 @@ extern int strcmp_iw (const char *string1, const char *string2);
 
 extern int strcmp_iw_ordered (const char *, const char *);
 
-/* Return true if the strings are equal.  */
-
-extern bool streq (const char *, const char *);
-
-/* Compare C strings for std::sort.  */
-
-static inline bool
-compare_cstrings (const char *str1, const char *str2)
-{
-  return strcmp (str1, str2) < 0;
-}
-
 /* Reset the prompt_for_continue clock.  */
 void reset_prompt_for_continue_wait_time (void);
 /* Return the time spent in prompt_for_continue.  */
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 8a9448a638b..7f5ec584a2e 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -93,6 +93,22 @@ startswith (gdb::string_view string, gdb::string_view pattern)
 	  && strncmp (string.data (), pattern.data (), pattern.length ()) == 0);
 }
 
+/* Return true if the strings are equal.  */
+
+static inline bool
+streq (const char *lhs, const char *rhs)
+{
+  return !strcmp (lhs, rhs);
+}
+
+/* Compare C strings for std::sort.  */
+
+static inline bool
+compare_cstrings (const char *str1, const char *str2)
+{
+  return strcmp (str1, str2) < 0;
+}
+
 ULONGEST strtoulst (const char *num, const char **trailer, int base);
 
 /* Skip leading whitespace characters in INP, returning an updated
-- 
2.34.3


  parent reply	other threads:[~2022-12-14 19:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 19:46 [PATCH 0/2] Two minor cleanups Tom Tromey
2022-12-14 19:46 ` [PATCH 1/2] Remove subset_compare Tom Tromey
2022-12-14 19:46 ` Tom Tromey [this message]
2022-12-14 19:51   ` [PATCH 2/2] Move streq and compare_cstrings to gdbsupport 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=20221214194606.4141035-3-tromey@adacore.com \
    --to=tromey@adacore.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).