aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/StringUtil.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-03-04 20:22:05 +0100
committerMax Kellermann <max@duempel.org>2015-03-04 20:22:05 +0100
commit250332a8d51c6fc79f156da748b02761143fabe6 (patch)
tree2c34624d0e12f5e1e1a5694af511c9558d1d1d68 /src/util/StringUtil.cxx
parent39825c662239c3a9b5e6e4d534557dc40c076a79 (diff)
downloadmpd-250332a8d51c6fc79f156da748b02761143fabe6.tar.gz
mpd-250332a8d51c6fc79f156da748b02761143fabe6.tar.xz
mpd-250332a8d51c6fc79f156da748b02761143fabe6.zip
util/StringUtil: reorder functions
Diffstat (limited to '')
-rw-r--r--src/util/StringUtil.cxx90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/util/StringUtil.cxx b/src/util/StringUtil.cxx
index 107354b6e..bb454e904 100644
--- a/src/util/StringUtil.cxx
+++ b/src/util/StringUtil.cxx
@@ -26,6 +26,51 @@
#include <assert.h>
#include <string.h>
+bool
+StringStartsWith(const char *haystack, const char *needle)
+{
+ const size_t length = strlen(needle);
+ return memcmp(haystack, needle, length) == 0;
+}
+
+bool
+StringEndsWith(const char *haystack, const char *needle)
+{
+ const size_t haystack_length = strlen(haystack);
+ const size_t needle_length = strlen(needle);
+
+ return haystack_length >= needle_length &&
+ memcmp(haystack + haystack_length - needle_length,
+ needle, needle_length) == 0;
+}
+
+const char *
+FindStringSuffix(const char *p, const char *suffix)
+{
+ const size_t p_length = strlen(p);
+ const size_t suffix_length = strlen(suffix);
+
+ if (p_length < suffix_length)
+ return nullptr;
+
+ const char *q = p + p_length - suffix_length;
+ return memcmp(q, suffix, suffix_length) == 0
+ ? q
+ : nullptr;
+}
+
+char *
+CopyString(char *gcc_restrict dest, const char *gcc_restrict src, size_t size)
+{
+ size_t length = strlen(src);
+ if (length >= size)
+ length = size - 1;
+
+ char *p = std::copy_n(src, length, dest);
+ *p = '\0';
+ return p;
+}
+
const char *
StripLeft(const char *p)
{
@@ -79,51 +124,6 @@ Strip(char *p)
}
bool
-StringStartsWith(const char *haystack, const char *needle)
-{
- const size_t length = strlen(needle);
- return memcmp(haystack, needle, length) == 0;
-}
-
-bool
-StringEndsWith(const char *haystack, const char *needle)
-{
- const size_t haystack_length = strlen(haystack);
- const size_t needle_length = strlen(needle);
-
- return haystack_length >= needle_length &&
- memcmp(haystack + haystack_length - needle_length,
- needle, needle_length) == 0;
-}
-
-const char *
-FindStringSuffix(const char *p, const char *suffix)
-{
- const size_t p_length = strlen(p);
- const size_t suffix_length = strlen(suffix);
-
- if (p_length < suffix_length)
- return nullptr;
-
- const char *q = p + p_length - suffix_length;
- return memcmp(q, suffix, suffix_length) == 0
- ? q
- : nullptr;
-}
-
-char *
-CopyString(char *gcc_restrict dest, const char *gcc_restrict src, size_t size)
-{
- size_t length = strlen(src);
- if (length >= size)
- length = size - 1;
-
- char *p = std::copy_n(src, length, dest);
- *p = '\0';
- return p;
-}
-
-bool
string_array_contains(const char *const* haystack, const char *needle)
{
assert(haystack != nullptr);