diff options
author | John-Mark Bell <jmb@netsurf-browser.org> | 2012-07-15 01:39:25 +0100 |
---|---|---|
committer | John-Mark Bell <jmb@netsurf-browser.org> | 2012-07-15 01:39:25 +0100 |
commit | 1ecc94b187a94859fb347cd5f585d721e7d6e8be (patch) | |
tree | 43ba725e2954b5b163d856f7261f4e60874b3b3c | |
parent | fa3da41a941a149cff8e507d4882c84abc88f6e9 (diff) | |
download | netsurf-1ecc94b187a94859fb347cd5f585d721e7d6e8be.tar.gz netsurf-1ecc94b187a94859fb347cd5f585d721e7d6e8be.tar.bz2 |
Use case insensitive string comparisions for nodes
-rw-r--r-- | desktop/save_complete.c | 22 | ||||
-rw-r--r-- | desktop/tree_url_node.c | 13 | ||||
-rw-r--r-- | render/box_construct.c | 16 | ||||
-rw-r--r-- | render/html.c | 14 |
4 files changed, 35 insertions, 30 deletions
diff --git a/desktop/save_complete.c b/desktop/save_complete.c index 33234ce2c..0ac64b515 100644 --- a/desktop/save_complete.c +++ b/desktop/save_complete.c @@ -589,28 +589,28 @@ bool rewrite_urls(xmlNode *n, const char *base, /* ignore */ } /* 1 */ - else if (strcmp((const char *) n->name, "object") == 0) { + else if (strcasecmp((const char *) n->name, "object") == 0) { if (!rewrite_url(n, "data", base, list)) return false; } /* 2 */ - else if (strcmp((const char *) n->name, "a") == 0 || - strcmp((const char *) n->name, "area") == 0 || - strcmp((const char *) n->name, "link") == 0) { + else if (strcasecmp((const char *) n->name, "a") == 0 || + strcasecmp((const char *) n->name, "area") == 0 || + strcasecmp((const char *) n->name, "link") == 0) { if (!rewrite_url(n, "href", base, list)) return false; } /* 3 */ - else if (strcmp((const char *) n->name, "frame") == 0 || - strcmp((const char *) n->name, "iframe") == 0 || - strcmp((const char *) n->name, "input") == 0 || - strcmp((const char *) n->name, "img") == 0 || - strcmp((const char *) n->name, "script") == 0) { + else if (strcasecmp((const char *) n->name, "frame") == 0 || + strcasecmp((const char *) n->name, "iframe") == 0 || + strcasecmp((const char *) n->name, "input") == 0 || + strcasecmp((const char *) n->name, "img") == 0 || + strcasecmp((const char *) n->name, "script") == 0) { if (!rewrite_url(n, "src", base, list)) return false; } /* 4 */ - else if (strcmp((const char *) n->name, "style") == 0) { + else if (strcasecmp((const char *) n->name, "style") == 0) { unsigned int len; xmlChar *content; @@ -642,7 +642,7 @@ bool rewrite_urls(xmlNode *n, const char *base, return true; } /* 5 */ - else if (strcmp((const char *) n->name, "base") == 0) { + else if (strcasecmp((const char *) n->name, "base") == 0) { /* simply remove any <base> tags from the document */ xmlUnlinkNode(n); xmlFreeNode(n); diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c index 380ba43b9..d477249c9 100644 --- a/desktop/tree_url_node.c +++ b/desktop/tree_url_node.c @@ -470,7 +470,7 @@ static xmlNode *tree_url_find_xml_element(xmlNode *node, const char *name) for (xmlnode = node->children; xmlnode && !(xmlnode->type == XML_ELEMENT_NODE && - strcmp((const char *) xmlnode->name, name) == 0); + strcasecmp((const char *) xmlnode->name, name) == 0); xmlnode = xmlnode->next) ; @@ -498,7 +498,7 @@ static void tree_url_load_entry(xmlNode *li, struct tree *tree, for (xmlnode = li->children; xmlnode; xmlnode = xmlnode->next) { /* The li must contain an "a" element */ if (xmlnode->type == XML_ELEMENT_NODE && - strcmp((const char *)xmlnode->name, "a") == 0) { + strcasecmp((const char *)xmlnode->name, "a") == 0) { url1 = (char *)xmlGetProp(xmlnode, (const xmlChar *) "href"); title = (char *)xmlNodeGetContent(xmlnode); @@ -590,12 +590,12 @@ static void tree_url_load_directory(xmlNode *ul, struct tree *tree, if (xmlnode->type != XML_ELEMENT_NODE) continue; - if (strcmp((const char *)xmlnode->name, "li") == 0) { + if (strcasecmp((const char *)xmlnode->name, "li") == 0) { /* entry */ tree_url_load_entry(xmlnode, tree, directory, callback, callback_data); - } else if (strcmp((const char *)xmlnode->name, "h4") == 0) { + } else if (strcasecmp((const char *)xmlnode->name, "h4") == 0) { /* directory */ bool dir_is_default = false; title = (char *) xmlNodeGetContent(xmlnode ); @@ -610,7 +610,7 @@ static void tree_url_load_directory(xmlNode *ul, struct tree *tree, xmlnode = xmlnode->next) ; if ((xmlnode == NULL) || - strcmp((const char *)xmlnode->name, "ul") != 0) { + strcasecmp((const char *)xmlnode->name, "ul") != 0) { /* next element isn't expected ul */ free(title); warn_user("TreeLoadError", "(Expected " @@ -620,7 +620,8 @@ static void tree_url_load_directory(xmlNode *ul, struct tree *tree, id = xmlGetProp(xmlnode, (const xmlChar *) "id"); if (id != NULL) { - if(strcmp((const char *)id, "default") == 0) + if (strcasecmp((const char *)id, + "default") == 0) dir_is_default = true; xmlFree(id); } diff --git a/render/box_construct.c b/render/box_construct.c index 0044f6e21..b968e0e4f 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -1939,7 +1939,7 @@ bool box_object(BOX_SPECIAL_PARAMS) return false; } - if (strcmp(dom_string_data(name), "param") != 0) { + if (strcasecmp(dom_string_data(name), "param") != 0) { /* The first non-param child is the start of * the alt html. Therefore, we should break * out of this loop. */ @@ -2192,9 +2192,11 @@ bool box_create_frameset(struct content_html_frames *f, dom_node *n, } if (type != DOM_ELEMENT_NODE || - (strcmp(dom_string_data(name), + (strcasecmp( + dom_string_data(name), "frame") != 0 && - strcmp(dom_string_data(name), + strcasecmp( + dom_string_data(name), "frameset") != 0)) { err = dom_node_get_next_sibling(c, &next); @@ -2225,7 +2227,7 @@ bool box_create_frameset(struct content_html_frames *f, dom_node *n, return false; } - if (strcmp(dom_string_data(s), "frameset") == 0) { + if (strcasecmp(dom_string_data(s), "frameset") == 0) { dom_string_unref(s); frame->border = 0; if (box_create_frameset(frame, c, @@ -2699,14 +2701,14 @@ bool box_select(BOX_SPECIAL_PARAMS) return false; } - if (strcmp(dom_string_data(name), "option") == 0) { + if (strcasecmp(dom_string_data(name), "option") == 0) { dom_string_unref(name); if (box_select_add_option(gadget, c) == false) { dom_node_unref(c); goto no_memory; } - } else if (strcmp(dom_string_data(name), "optgroup") == 0) { + } else if (strcasecmp(dom_string_data(name), "optgroup") == 0) { dom_string_unref(name); err = dom_node_get_first_child(c, &c2); @@ -2725,7 +2727,7 @@ bool box_select(BOX_SPECIAL_PARAMS) return false; } - if (strcmp(dom_string_data(c2_name), + if (strcasecmp(dom_string_data(c2_name), "option") == 0) { dom_string_unref(c2_name); diff --git a/render/html.c b/render/html.c index 946555f6e..8c5c76b8e 100644 --- a/render/html.c +++ b/render/html.c @@ -997,7 +997,8 @@ static bool html_meta_refresh(html_content *c, dom_node *head) } /* Recurse into noscript elements */ - if (strcmp(dom_string_data(name), "noscript") == 0) { + if (strcasecmp(dom_string_data(name), + "noscript") == 0) { if (html_meta_refresh(c, n) == false) { /* Some error occurred */ dom_node_unref(n); @@ -1007,7 +1008,8 @@ static bool html_meta_refresh(html_content *c, dom_node *head) dom_node_unref(n); return true; } - } else if (strcmp(dom_string_data(name), "meta") == 0) { + } else if (strcasecmp(dom_string_data(name), + "meta") == 0) { if (html_meta_refresh_process_element(c, n) == false) { /* Some error occurred */ @@ -1436,7 +1438,7 @@ html_process_style_element(html_content *c, /* type='text/css', or not present (invalid but common) */ exc = dom_element_get_attribute(style, html_dom_string_type, &val); if (exc == DOM_NO_ERR && val != NULL) { - if (strcmp(dom_string_data(val), "text/css") != 0) { + if (strcasecmp(dom_string_data(val), "text/css") != 0) { dom_string_unref(val); return true; } @@ -1683,14 +1685,14 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx) hlcache_child_context child; /* deal with style nodes */ - if (strcmp(dom_string_data(name), "style") == 0) { + if (strcasecmp(dom_string_data(name), "style") == 0) { if (!html_process_style_element(ctx->c, &ctx->count, node)) return false; return true; } /* if it is not a link node skip it */ - if (strcmp(dom_string_data(name), "LINK") != 0) { + if (strcasecmp(dom_string_data(name), "link") != 0) { return true; } @@ -1713,7 +1715,7 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx) /* type='text/css' or not present */ exc = dom_element_get_attribute(node, html_dom_string_type, &type_attr); if (exc == DOM_NO_ERR && type_attr != NULL) { - if (strcmp(dom_string_data(type_attr), "text/css") != 0) { + if (strcasecmp(dom_string_data(type_attr), "text/css") != 0) { dom_string_unref(type_attr); return true; } |