summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-07-12 12:40:28 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-07-12 12:40:28 +0000
commit3980afa794031e82a93c66412e5c6ed07fbc2a78 (patch)
tree41624f1a7eb98c21db78c712af421bdb70e67d60 /src/utils
parentb2fe4fbe5c941e5bccf865536b645725add5e8cf (diff)
downloadlibhubbub-3980afa794031e82a93c66412e5c6ed07fbc2a78.tar.gz
libhubbub-3980afa794031e82a93c66412e5c6ed07fbc2a78.tar.bz2
Fix string comparisons.
svn path=/trunk/hubbub/; revision=8472
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/string.c22
1 files changed, 3 insertions, 19 deletions
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 <stddef.h>
#include <inttypes.h>
#include <stdbool.h>
+#include <string.h>
#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;
}