aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-12-14 12:28:32 -0700
committerTom Tromey <tromey@adacore.com>2022-12-15 12:13:35 -0700
commit2e55fbce03a0bbee40032b486fe565bfc2423894 (patch)
treedf6b897deaa72f1a366042b2cdea69c0c15a1220 /gdbsupport
parentc573941878c15ecd8f0985cbe3fb8370abe4c807 (diff)
downloadgdb-2e55fbce03a0bbee40032b486fe565bfc2423894.zip
gdb-2e55fbce03a0bbee40032b486fe565bfc2423894.tar.gz
gdb-2e55fbce03a0bbee40032b486fe565bfc2423894.tar.bz2
Move streq and compare_cstrings to gdbsupport
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>
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/common-utils.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 8a9448a..92d7caa 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) == 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