From 3980afa794031e82a93c66412e5c6ed07fbc2a78 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 12 Jul 2009 12:40:28 +0000 Subject: Fix string comparisons. svn path=/trunk/hubbub/; revision=8472 --- src/utils/string.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'src/utils/string.c') diff --git a/src/utils/string.c b/src/utils/string.c index e35bec6..e216a55 100644 --- a/src/utils/string.c +++ b/src/utils/string.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "utils/string.h" @@ -22,17 +23,10 @@ bool hubbub_string_match(const uint8_t *a, size_t a_len, const uint8_t *b, size_t b_len) { - const uint8_t *s1, *s2; - if (a_len != b_len) return false; - for (s1 = a, s2 = b; b_len > 0; s1++, s2++, b_len--) - { - if (*s1 != *s2) return false; - } - - return true; + return strncmp((const char *) a, (const char *) b, b_len) == 0; } /** @@ -46,18 +40,8 @@ bool hubbub_string_match(const uint8_t *a, size_t a_len, bool hubbub_string_match_ci(const uint8_t *a, size_t a_len, const uint8_t *b, size_t b_len) { - uint8_t z1, z2; - const uint8_t *s1, *s2; - if (a_len != b_len) return false; - for (s1 = a, s2 = b; b_len > 0; s1++, s2++, b_len--) - { - z1 = (*s1 & ~0x20); - z2 = (*s2 & ~0x20); - if (z1 != z2) return false; - } - - return true; + return strncasecmp((const char *) a, (const char *) b, b_len) == 0; } -- cgit v1.2.3