summaryrefslogtreecommitdiff
path: root/src/core/string.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-03-24 14:04:32 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2012-03-24 14:04:32 +0000
commite541463b9b5764ab7e85a2b06afdf9018419b1b2 (patch)
tree6450ebdae3935f1be9912554594ed5b70dab1d67 /src/core/string.c
parent30bd501a862a81b72b8c1c151ceafa0b79785cbd (diff)
downloadlibdom-e541463b9b5764ab7e85a2b06afdf9018419b1b2.tar.gz
libdom-e541463b9b5764ab7e85a2b06afdf9018419b1b2.tar.bz2
API for comparing dom_string with lwc_string. Caseless version not implemented yet.
svn path=/trunk/libdom/; revision=13592
Diffstat (limited to 'src/core/string.c')
-rw-r--r--src/core/string.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/core/string.c b/src/core/string.c
index a9659cb..8405c27 100644
--- a/src/core/string.c
+++ b/src/core/string.c
@@ -309,6 +309,60 @@ bool dom_string_caseless_isequal(const dom_string *s1, const dom_string *s2)
return true;
}
+
+/**
+ * Case sensitively compare DOM string with lwc_string
+ *
+ * \param s1 The first string to compare
+ * \param s2 The second string to compare
+ * \return true if strings match, false otherwise
+ *
+ * Returns false if either are NULL.
+ */
+bool dom_string_lwc_isequal(const dom_string *s1, lwc_string *s2)
+{
+ size_t len;
+
+ if (s1 == NULL || s2 == NULL)
+ return false;
+
+ if (s1->type == DOM_STRING_INTERNED) {
+ bool match;
+
+ lwc_string_caseless_isequal(s1->data.intern, s2, &match);
+
+ return match;
+ }
+
+ /* Handle non-interend case */
+ len = dom_string_byte_length(s1);
+
+ if (len != lwc_string_length(s2))
+ return false;
+
+ return 0 == memcmp(dom_string_data(s1), lwc_string_data(s2), len);
+}
+
+
+/**
+ * Case insensitively compare DOM string with lwc_string
+ *
+ * \param s1 The first string to compare
+ * \param s2 The second string to compare
+ * \return true if strings match, false otherwise
+ */
+bool dom_string_caseless_lwc_isequal(const dom_string *s1, lwc_string *s2)
+{
+// size_t len;
+
+ if (s1 == NULL || s2 == NULL)
+ return false;
+
+ /* TODO: rest of this */
+ return false;
+}
+
+
/**
* Get the index of the first occurrence of a character in a dom string
*