diff options
author | Karel Zak | 2013-09-10 12:18:20 +0200 |
---|---|---|
committer | Karel Zak | 2013-09-10 12:18:20 +0200 |
commit | 646e159aa980063cde55704450db0dbd903ea814 (patch) | |
tree | 285e5ea48e7a64a0de41d243f9badb1960c6f2e2 /lib/strutils.c | |
parent | su: fix lastlog and btmp logging (diff) | |
download | kernel-qcow2-util-linux-646e159aa980063cde55704450db0dbd903ea814.tar.gz kernel-qcow2-util-linux-646e159aa980063cde55704450db0dbd903ea814.tar.xz kernel-qcow2-util-linux-646e159aa980063cde55704450db0dbd903ea814.zip |
lib/strutils: optimalize {starts,ends}with()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/strutils.c')
-rw-r--r-- | lib/strutils.c | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/lib/strutils.c b/lib/strutils.c index 95ab5a87e..69b7ba23f 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -686,72 +686,6 @@ int streq_except_trailing_slash(const char *s1, const char *s2) return equal; } -/* - * Match string beginning. - */ -char *startswith(const char *s, const char *prefix) -{ - const char *a, *b; - - assert(s); - assert(prefix); - - a = s, b = prefix; - for (;;) { - if (*b == 0) - return (char *)a; - if (*a != *b) - return NULL; - - a++, b++; - } -} - -/* - * Case insensitive match string beginning. - */ -char *startswith_no_case(const char *s, const char *prefix) -{ - const char *a, *b; - - assert(s); - assert(prefix); - - a = s, b = prefix; - for (;;) { - if (*b == 0) - return (char *)a; - if (tolower(*a) != tolower(*b)) - return NULL; - - a++, b++; - } -} - -/* - * Match string ending. - */ -char *endswith(const char *s, const char *postfix) -{ - size_t sl, pl; - - assert(s); - assert(postfix); - - sl = strlen(s); - pl = strlen(postfix); - - if (pl == 0) - return (char *)s + sl; - - if (sl < pl) - return NULL; - - if (memcmp(s + sl - pl, postfix, pl) != 0) - return NULL; - - return (char *)s + sl - pl; -} #ifdef TEST_PROGRAM |