Move streq and compare_cstrings to gdbsupport
authorTom Tromey <tromey@adacore.com>
Wed, 14 Dec 2022 19:28:32 +0000 (12:28 -0700)
committerTom Tromey <tromey@adacore.com>
Thu, 15 Dec 2022 19:13:35 +0000 (12:13 -0700)
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.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/utils.c
gdb/utils.h
gdbsupport/common-utils.h

index 5c110daa4aeb0b4ff2f0a7b43ce0eb66fb438e64..74917f25ab903b82a9a9d38afe161e9e85a06f25 100644 (file)
@@ -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
index ad7c94988b770ec47ab8f2374240e3e13295e7d2..509361dc42955435bed16330f7df549a57f9fe49 100644 (file)
@@ -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.  */
index 8a9448a638bf5c7220559496af5aa3bde8c59a95..92d7caaf1ec0f5d66c17da53367a4fdf00e91376 100644 (file)
@@ -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) == 0;
+}
+
+/* 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