static void lwc_lcase_memcpy(char *target, const char *source, size_t n) { while (n--) { *target++ = dolower(*source++); } }
/** * Case insensitively compare two DOM strings * * \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_isequal(const dom_string *s1, const dom_string *s2) { const uint8_t *d1 = NULL; const uint8_t *d2 = NULL; size_t len; const dom_string_internal *is1 = (dom_string_internal *) s1; const dom_string_internal *is2 = (dom_string_internal *) s2; if (s1 == NULL) is1 = &empty_string; if (s2 == NULL) is2 = &empty_string; if (is1->type == DOM_STRING_INTERNED && is2->type == DOM_STRING_INTERNED) { bool match; if (lwc_string_caseless_isequal(is1->data.intern, is2->data.intern, &match) != lwc_error_ok) return false; return match; } len = dom_string_byte_length((dom_string *) is1); if (len != dom_string_byte_length((dom_string *)is2)) return false; d1 = (const uint8_t *) dom_string_data((dom_string *) is1); d2 = (const uint8_t *) dom_string_data((dom_string *)is2); while (len > 0) { if (dolower(*d1) != dolower(*d2)) return false; d1++; d2++; len--; } return true; }
static int lwc_lcase_strncmp(const char *s1, const char *s2, size_t n) { while (n--) { if (*s1++ != dolower(*s2++)) /** @todo Test this somehow? */ return 1; } return 0; }
static inline lwc_hash lwc_calculate_lcase_hash(const char *str, size_t len) { lwc_hash z = 0x811c9dc5; while (len > 0) { z *= 0x01000193; z ^= dolower(*str++); len--; } return z; }