mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Factor out dom_string_casecmp()
This commit is contained in:
parent
87aad88c96
commit
86c9a37810
@ -154,15 +154,8 @@ dom_node_cmp(struct dom_node_search *search, struct dom_node *node)
|
||||
break;
|
||||
}
|
||||
}
|
||||
{
|
||||
int length = int_min(key->string.length, node->string.length);
|
||||
int string_diff = strncasecmp(key->string.string, node->string.string, length);
|
||||
|
||||
/* If the lengths or strings don't match strncasecmp() does the
|
||||
* job else return which ever is bigger. */
|
||||
|
||||
return string_diff ? string_diff : key->string.length - node->string.length;
|
||||
}
|
||||
return dom_string_casecmp(&key->string, &node->string);
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
@ -16,6 +16,17 @@ set_dom_string(struct dom_string *string, unsigned char *value, uint16_t length)
|
||||
string->length = length;
|
||||
}
|
||||
|
||||
static inline int
|
||||
dom_string_casecmp(struct dom_string *string1, struct dom_string *string2)
|
||||
{
|
||||
size_t length = int_min(string1->length, string2->length);
|
||||
size_t string_diff = strncasecmp(string1->string, string2->string, length);
|
||||
|
||||
/* If the lengths or strings don't match strncasecmp() does the
|
||||
* job else return which ever is bigger. */
|
||||
return string_diff ? string_diff : string1->length - string2->length;
|
||||
}
|
||||
|
||||
#define is_dom_string_set(str) ((str)->string && (str)->length)
|
||||
|
||||
#define done_dom_string(str) mem_free((str)->string);
|
||||
|
Loading…
Reference in New Issue
Block a user