r13592 tlsa - in /trunk/libdom: include/dom/core/string.h src/core/string.c

netsurf at semichrome.net netsurf at semichrome.net
Sat Mar 24 14:04:32 GMT 2012


Author: tlsa
Date: Sat Mar 24 09:04:32 2012
New Revision: 13592

URL: http://source.netsurf-browser.org?rev=13592&view=rev
Log:
API for comparing dom_string with lwc_string. Caseless version not implemented yet.

Modified:
    trunk/libdom/include/dom/core/string.h
    trunk/libdom/src/core/string.c

Modified: trunk/libdom/include/dom/core/string.h
URL: http://source.netsurf-browser.org/trunk/libdom/include/dom/core/string.h?rev=13592&r1=13591&r2=13592&view=diff
==============================================================================
--- trunk/libdom/include/dom/core/string.h (original)
+++ trunk/libdom/include/dom/core/string.h Sat Mar 24 09:04:32 2012
@@ -37,6 +37,11 @@
 bool dom_string_isequal(const dom_string *s1, const dom_string *s2);
 /* Case insensitively compare two DOM strings */
 bool dom_string_caseless_isequal(const dom_string *s1, const dom_string *s2);
+
+/* Case sensitively compare DOM string and lwc_string */
+bool dom_string_lwc_isequal(const dom_string *s1, lwc_string *s2);
+/* Case insensitively compare DOM string and lwc_string */
+bool dom_string_caseless_lwc_isequal(const dom_string *s1, lwc_string *s2);
 
 /* Get the index of the first occurrence of a character in a dom string */
 uint32_t dom_string_index(dom_string *str, uint32_t chr);

Modified: trunk/libdom/src/core/string.c
URL: http://source.netsurf-browser.org/trunk/libdom/src/core/string.c?rev=13592&r1=13591&r2=13592&view=diff
==============================================================================
--- trunk/libdom/src/core/string.c (original)
+++ trunk/libdom/src/core/string.c Sat Mar 24 09:04:32 2012
@@ -309,6 +309,60 @@
 	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 
  * 




More information about the netsurf-commits mailing list