aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-12-29 09:00:51 +0000
committerAndrew Burgess <aburgess@redhat.com>2024-09-07 21:48:34 +0100
commit3debc0b3480369d13149ea05cdbf61b6acd0ffdc (patch)
tree6be641aa9f9170e0634caa664a4bb74e211a745a /gdbsupport
parent4764e22161c68806444a6484cc5314b56071c647 (diff)
downloadgdb-3debc0b3480369d13149ea05cdbf61b6acd0ffdc.zip
gdb-3debc0b3480369d13149ea05cdbf61b6acd0ffdc.tar.gz
gdb-3debc0b3480369d13149ea05cdbf61b6acd0ffdc.tar.bz2
gdb: add another overload of startswith
We already have one overload of the startswith function that takes a std::string_view for both arguments. A later patch in this series is going to be improved by having an overload that takes one argument as a std::string_view and the other argument as a plain 'char *'. This commit adds the new overload, but doesn't make use of it (yet). There should be no user visible changes after this commit.
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/common-utils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 23cd40c..2fb2291 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -100,6 +100,16 @@ startswith (std::string_view string, std::string_view pattern)
&& strncmp (string.data (), pattern.data (), pattern.length ()) == 0);
}
+/* Version of startswith that takes a string_view for only one of its
+ arguments. Return true if STR starts with PREFIX, otherwise return
+ false. */
+
+static inline bool
+startswith (const char *str, const std::string_view &prefix)
+{
+ return strncmp (str, prefix.data (), prefix.length ()) == 0;
+}
+
/* Return true if the strings are equal. */
static inline bool