1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Merge branch 'elinks-0.12' into elinks-0.13

Conflicts:
	src/session/download.c
This commit is contained in:
Kalle Olavi Niemitalo 2008-11-01 22:39:17 +02:00 committed by Kalle Olavi Niemitalo
commit 5c2fada371
61 changed files with 509 additions and 262 deletions

View File

@ -351,6 +351,10 @@ M. K. Srikant <srix@vsnl.com>
M. Levinson <levinsm@users.sourceforge.net>
Python scripting fixes
M. Vefa Bicakci <bicave@superonline.com>
Licenses modifications under "GPL version 2 or any later version."
Locale-independent case-insensitive comparisons
Malcolm Parsons <malcolm.parsons@gmail.com>
Typo fixes

3
NEWS
View File

@ -301,6 +301,9 @@ To be released as 0.11.6.
* critical bug 1053: fix crash if a download finishes after ELinks has
closed the terminal from which the download was started
* major bug 1004: ignore locales when comparing HTML element names and
similar strings, so e.g. ``title'' matches ``TITLE'' even in the
Turkish locale
ELinks 0.11.5:
--------------

View File

@ -556,7 +556,7 @@ test_search(struct listbox_item *item, void *data_, int *offset)
assert(ctx->title && ctx->url);
ctx->found = (*ctx->title && strcasestr(bm->title, ctx->title))
|| (*ctx->url && strcasestr(bm->url, ctx->url));
|| (*ctx->url && c_strcasestr(bm->url, ctx->url));
if (ctx->found) *offset = 0;
}

4
src/cache/dialogs.c vendored
View File

@ -193,8 +193,8 @@ match_cache_entry(struct listbox_item *item, struct terminal *term,
{
struct cache_entry *cached = item->udata;
if (strcasestr(struri(cached->uri), text)
|| (cached->head && strcasestr(cached->head, text)))
if (c_strcasestr(struri(cached->uri), text)
|| (cached->head && c_strcasestr(cached->head, text)))
return LISTBOX_MATCH_OK;
return LISTBOX_MATCH_NO;

View File

@ -321,7 +321,7 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc)
for (method = 0; remote_methods[method].name; method++) {
unsigned char *name = remote_methods[method].name;
if (!strlcasecmp(command, len, name, -1))
if (!c_strlcasecmp(command, len, name, -1))
break;
}
@ -359,7 +359,7 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc)
if (remote_argc < 1)
break;
if (!strcasecmp(remote_argv[0], "openBrowser")) {
if (!c_strcasecmp(remote_argv[0], "openBrowser")) {
remote_session_flags = SES_REMOTE_NEW_WINDOW;
}
break;
@ -450,7 +450,7 @@ print_full_help_inner(struct option *tree, unsigned char *path,
|| (option->flags & OPT_HIDDEN))
continue;
if (!capt && !strncasecmp(option->name, "_template_", 10))
if (!capt && !c_strncasecmp(option->name, "_template_", 10))
capt = (unsigned char *) N_("Template option folder");
if (!capt) {

View File

@ -18,6 +18,7 @@
#include "main/event.h"
#include "main/module.h"
#include "terminal/kbd.h"
#include "util/conv.h"
#include "util/memory.h"
#include "util/string.h"
@ -363,7 +364,7 @@ read_key(const unsigned char *key_str)
return key_str[0];
for (key = key_table; key->str; key++)
if (!strcasecmp(key->str, key_str))
if (!c_strcasecmp(key->str, key_str))
return key->num;
return KBD_UNDEF;
@ -380,17 +381,17 @@ parse_keystroke(const unsigned char *s, struct term_event_keyboard *kbd)
{
kbd->modifier = KBD_MOD_NONE;
while (1) {
if (!strncasecmp(s, "Shift", 5) && (s[5] == '-' || s[5] == '+')) {
if (!c_strncasecmp(s, "Shift", 5) && (s[5] == '-' || s[5] == '+')) {
/* Shift+a == shiFt-a == Shift-a */
kbd->modifier |= KBD_MOD_SHIFT;
s += 6;
} else if (!strncasecmp(s, "Ctrl", 4) && (s[4] == '-' || s[4] == '+')) {
} else if (!c_strncasecmp(s, "Ctrl", 4) && (s[4] == '-' || s[4] == '+')) {
/* Ctrl+a == ctRl-a == Ctrl-a */
kbd->modifier |= KBD_MOD_CTRL;
s += 5;
} else if (!strncasecmp(s, "Alt", 3) && (s[3] == '-' || s[3] == '+')) {
} else if (!c_strncasecmp(s, "Alt", 3) && (s[3] == '-' || s[3] == '+')) {
/* Alt+a == aLt-a == Alt-a */
kbd->modifier |= KBD_MOD_ALT;
s += 4;
@ -430,7 +431,7 @@ parse_keystroke(const unsigned char *s, struct term_event_keyboard *kbd)
* and instead make kbd_ev_lookup() or its callers
* search for different variants of the keystroke if
* the original one is not bound to any action. */
kbd->key = toupper(kbd->key);
kbd->key = c_toupper(kbd->key);
}
return (kbd->key == KBD_UNDEF) ? -1 : 0;

View File

@ -143,7 +143,7 @@ get_cookie_server(unsigned char *host, int hostlen)
/* XXX: We must count with cases like "x.co" vs "x.co.uk"
* below! */
int cslen = strlen(cs->host);
int cmp = strncasecmp(cs->host, host, hostlen);
int cmp = c_strncasecmp(cs->host, host, hostlen);
if (!sort_spot && (cmp > 0 || (cmp == 0 && cslen > hostlen))) {
/* This is the first @cs with name greater than @host,
@ -234,13 +234,13 @@ is_domain_security_ok(unsigned char *domain, unsigned char *server, int server_l
/* Match domain and server.. */
/* XXX: Hmm, can't we use strlcasecmp() here? --pasky */
/* XXX: Hmm, can't we use c_strlcasecmp() here? --pasky */
if (domain_len > server_len) return 0;
/* Ensure that the domain is atleast a substring of the server before
* continuing. */
if (strncasecmp(domain, server + server_len - domain_len, domain_len))
if (c_strncasecmp(domain, server + server_len - domain_len, domain_len))
return 0;
/* Allow domains which are same as servers. --<rono@sentuny.com.au> */
@ -499,8 +499,8 @@ accept_cookie(struct cookie *cookie)
struct cookie *c, *next;
foreachsafe (c, next, cookies) {
if (strcasecmp(c->name, cookie->name)
|| strcasecmp(c->domain, cookie->domain))
if (c_strcasecmp(c->name, cookie->name)
|| c_strcasecmp(c->domain, cookie->domain))
continue;
delete_cookie(c);
@ -513,7 +513,7 @@ accept_cookie(struct cookie *cookie)
/* XXX: This crunches CPU too. --pasky */
foreach (cd, c_domains)
if (!strcasecmp(cd->domain, cookie->domain))
if (!c_strcasecmp(cd->domain, cookie->domain))
return;
domain_len = strlen(cookie->domain);
@ -535,11 +535,11 @@ delete_cookie(struct cookie *c)
struct cookie *d;
foreach (d, cookies)
if (!strcasecmp(d->domain, c->domain))
if (!c_strcasecmp(d->domain, c->domain))
goto end;
foreach (cd, c_domains) {
if (!strcasecmp(cd->domain, c->domain)) {
if (!c_strcasecmp(cd->domain, c->domain)) {
del_from_list(cd);
mem_free(cd);
break;

View File

@ -287,7 +287,7 @@ scan_css_token(struct scanner *scanner, struct scanner_token *token)
} else if (first_char == '!') {
scan_css(scanner, string, CSS_CHAR_WHITESPACE);
if (!strncasecmp(string, "important", 9)) {
if (!c_strncasecmp(string, "important", 9)) {
type = CSS_TOKEN_IMPORTANT;
string += 9;
}

View File

@ -38,7 +38,7 @@ find_css_selector(struct css_selector_set *sels,
foreach_css_selector (selector, sels) {
if (type != selector->type || rel != selector->relation)
continue;
if (strlcasecmp(name, namelen, selector->name, -1))
if (c_strlcasecmp(name, namelen, selector->name, -1))
continue;
return selector;
}

View File

@ -191,7 +191,7 @@ find_tag(struct document *document, unsigned char *name, int namelen)
struct tag *tag;
foreach (tag, document->tags)
if (!strlcasecmp(tag->name, -1, name, namelen))
if (!c_strlcasecmp(tag->name, -1, name, namelen))
return tag->y;
return -1;

View File

@ -54,22 +54,22 @@ done_dom_renderer(struct dom_renderer *renderer)
static void
get_doctype(struct dom_renderer *renderer, struct cache_entry *cached)
{
if (!strcasecmp("application/rss+xml", cached->content_type)) {
if (!c_strcasecmp("application/rss+xml", cached->content_type)) {
renderer->doctype = SGML_DOCTYPE_RSS;
} else if (!strcasecmp("application/docbook+xml",
cached->content_type)) {
} else if (!c_strcasecmp("application/docbook+xml",
cached->content_type)) {
renderer->doctype = SGML_DOCTYPE_DOCBOOK;
} else if (!strcasecmp("application/xbel+xml", cached->content_type)
|| !strcasecmp("application/x-xbel", cached->content_type)
|| !strcasecmp("application/xbel", cached->content_type)) {
} else if (!c_strcasecmp("application/xbel+xml", cached->content_type)
|| !c_strcasecmp("application/x-xbel", cached->content_type)
|| !c_strcasecmp("application/xbel", cached->content_type)) {
renderer->doctype = SGML_DOCTYPE_XBEL;
} else {
assertm(!strcasecmp("text/html", cached->content_type)
|| !strcasecmp("application/xhtml+xml",
cached->content_type),
assertm(!c_strcasecmp("text/html", cached->content_type)
|| !c_strcasecmp("application/xhtml+xml",
cached->content_type),
"Couldn't resolve doctype '%s'", cached->content_type);
renderer->doctype = SGML_DOCTYPE_HTML;

View File

@ -137,7 +137,7 @@ find_fd(struct session *ses, unsigned char *name,
foreachback (doc_view, ses->scrn_frames) {
if (doc_view->used) continue;
if (strcasecmp(doc_view->name, name)) continue;
if (c_strcasecmp(doc_view->name, name)) continue;
doc_view->used = 1;
doc_view->depth = depth;

View File

@ -94,7 +94,7 @@ get_target(struct document_options *options, unsigned char *a)
if (!v) return NULL;
if (!*v || !strcasecmp(v, "_self")) {
if (!*v || !c_strcasecmp(v, "_self")) {
mem_free_set(&v, stracpy(options->framename));
}
@ -341,7 +341,7 @@ search_for_url_param(unsigned char *str, unsigned char **ret)
/* Returns now if string @str is empty. */
if (!*str) return HEADER_PARAM_NOT_FOUND;
p = strcasestr(str, "url");
p = c_strcasestr(str, "url");
if (!p) return HEADER_PARAM_NOT_FOUND;
p += 3;
@ -551,7 +551,7 @@ look_for_map(unsigned char **pos, unsigned char *eof, struct uri *uri,
return 1;
}
if (strlcasecmp(name, namelen, "MAP", 3)) return 1;
if (c_strlcasecmp(name, namelen, "MAP", 3)) return 1;
if (uri && uri->fragment) {
/* FIXME (bug 784): options->cp is the terminal charset;
@ -559,7 +559,7 @@ look_for_map(unsigned char **pos, unsigned char *eof, struct uri *uri,
al = get_attr_val(attr, "name", options->cp);
if (!al) return 1;
if (strlcasecmp(al, -1, uri->fragment, uri->fragmentlen)) {
if (c_strlcasecmp(al, -1, uri->fragment, uri->fragmentlen)) {
mem_free(al);
return 1;
}
@ -606,12 +606,12 @@ look_for_tag(unsigned char **pos, unsigned char *eof,
if (parse_element(*pos, eof, NULL, NULL, NULL, &pos2)) return 1;
if (strlcasecmp(name, namelen, "A", 1)
&& strlcasecmp(name, namelen, "/A", 2)
&& strlcasecmp(name, namelen, "MAP", 3)
&& strlcasecmp(name, namelen, "/MAP", 4)
&& strlcasecmp(name, namelen, "AREA", 4)
&& strlcasecmp(name, namelen, "/AREA", 5)) {
if (c_strlcasecmp(name, namelen, "A", 1)
&& c_strlcasecmp(name, namelen, "/A", 2)
&& c_strlcasecmp(name, namelen, "MAP", 3)
&& c_strlcasecmp(name, namelen, "/MAP", 4)
&& c_strlcasecmp(name, namelen, "AREA", 4)
&& c_strlcasecmp(name, namelen, "/AREA", 5)) {
*pos = pos2;
return 1;
}
@ -648,12 +648,12 @@ look_for_link(unsigned char **pos, unsigned char *eof, struct menu_item **menu,
return 1;
}
if (!strlcasecmp(name, namelen, "A", 1)) {
if (!c_strlcasecmp(name, namelen, "A", 1)) {
while (look_for_tag(pos, eof, name, namelen, &label));
if (*pos >= eof) return 0;
} else if (!strlcasecmp(name, namelen, "AREA", 4)) {
} else if (!c_strlcasecmp(name, namelen, "AREA", 4)) {
/* FIXME (bug 784): options->cp is the terminal charset;
* should use the document charset instead. */
unsigned char *alt = get_attr_val(attr, "alt", options->cp);
@ -667,7 +667,7 @@ look_for_link(unsigned char **pos, unsigned char *eof, struct menu_item **menu,
label = NULL;
}
} else if (!strlcasecmp(name, namelen, "/MAP", 4)) {
} else if (!c_strlcasecmp(name, namelen, "/MAP", 4)) {
/* This is the only successful return from here! */
add_to_ml(ml, (void *) *menu, (void *) NULL);
return 0;

View File

@ -52,7 +52,7 @@ html_form(struct html_context *html_context, unsigned char *a,
al = get_attr_val(a, "method", html_context->doc_cp);
if (al) {
if (!strcasecmp(al, "post")) {
if (!c_strcasecmp(al, "post")) {
unsigned char *enctype;
enctype = get_attr_val(a, "enctype",
@ -60,9 +60,9 @@ html_form(struct html_context *html_context, unsigned char *a,
form->method = FORM_METHOD_POST;
if (enctype) {
if (!strcasecmp(enctype, "multipart/form-data"))
if (!c_strcasecmp(enctype, "multipart/form-data"))
form->method = FORM_METHOD_POST_MP;
else if (!strcasecmp(enctype, "text/plain"))
else if (!c_strcasecmp(enctype, "text/plain"))
form->method = FORM_METHOD_POST_TEXT_PLAIN;
mem_free(enctype);
}
@ -153,11 +153,11 @@ html_button(struct html_context *html_context, unsigned char *a,
al = get_attr_val(a, "type", cp);
if (!al) goto no_type_attr;
if (!strcasecmp(al, "button")) {
if (!c_strcasecmp(al, "button")) {
type = FC_BUTTON;
} else if (!strcasecmp(al, "reset")) {
} else if (!c_strcasecmp(al, "reset")) {
type = FC_RESET;
} else if (strcasecmp(al, "submit")) {
} else if (c_strcasecmp(al, "submit")) {
/* unknown type */
mem_free(al);
return;
@ -273,16 +273,16 @@ html_input(struct html_context *html_context, unsigned char *a,
al = get_attr_val(a, "type", cp);
if (al) {
if (!strcasecmp(al, "text")) fc->type = FC_TEXT;
else if (!strcasecmp(al, "hidden")) fc->type = FC_HIDDEN;
else if (!strcasecmp(al, "button")) fc->type = FC_BUTTON;
else if (!strcasecmp(al, "checkbox")) fc->type = FC_CHECKBOX;
else if (!strcasecmp(al, "radio")) fc->type = FC_RADIO;
else if (!strcasecmp(al, "password")) fc->type = FC_PASSWORD;
else if (!strcasecmp(al, "submit")) fc->type = FC_SUBMIT;
else if (!strcasecmp(al, "reset")) fc->type = FC_RESET;
else if (!strcasecmp(al, "file")) fc->type = FC_FILE;
else if (!strcasecmp(al, "image")) fc->type = FC_IMAGE;
if (!c_strcasecmp(al, "text")) fc->type = FC_TEXT;
else if (!c_strcasecmp(al, "hidden")) fc->type = FC_HIDDEN;
else if (!c_strcasecmp(al, "button")) fc->type = FC_BUTTON;
else if (!c_strcasecmp(al, "checkbox")) fc->type = FC_CHECKBOX;
else if (!c_strcasecmp(al, "radio")) fc->type = FC_RADIO;
else if (!c_strcasecmp(al, "password")) fc->type = FC_PASSWORD;
else if (!c_strcasecmp(al, "submit")) fc->type = FC_SUBMIT;
else if (!c_strcasecmp(al, "reset")) fc->type = FC_RESET;
else if (!c_strcasecmp(al, "file")) fc->type = FC_FILE;
else if (!c_strcasecmp(al, "image")) fc->type = FC_IMAGE;
/* else unknown type, let it default to FC_TEXT. */
mem_free(al);
}
@ -408,12 +408,12 @@ abort:
closing_tag = 0;
}
if (closing_tag && !strlcasecmp(name, namelen, "SELECT", 6)) {
if (closing_tag && !c_strlcasecmp(name, namelen, "SELECT", 6)) {
add_select_item(&lnk_menu, &lbl, &orig_lbl, values, order, nnmi);
goto end_parse;
}
if (!strlcasecmp(name, namelen, "OPTION", 6)) {
if (!c_strlcasecmp(name, namelen, "OPTION", 6)) {
add_select_item(&lnk_menu, &lbl, &orig_lbl, values, order, nnmi);
if (!closing_tag) {
@ -442,7 +442,7 @@ abort:
goto see;
}
if (!strlcasecmp(name, namelen, "OPTGROUP", 8)) {
if (!c_strlcasecmp(name, namelen, "OPTGROUP", 8)) {
add_select_item(&lnk_menu, &lbl, &orig_lbl, values, order, nnmi);
if (group) new_menu_item(&lnk_menu, NULL, -1, 0), group = 0;
@ -586,10 +586,10 @@ sp:
if (namelen < 6) goto se;
if (name[0] == '/') name++, namelen--;
if (strlcasecmp(name, namelen, "OPTION", 6)
&& strlcasecmp(name, namelen, "SELECT", 6)
&& strlcasecmp(name, namelen, "OPTGROUP", 8))
if (c_strlcasecmp(name, namelen, "OPTION", 6)
&& c_strlcasecmp(name, namelen, "SELECT", 6)
&& c_strlcasecmp(name, namelen, "OPTGROUP", 8))
goto se;
}
@ -641,7 +641,7 @@ pp:
return;
}
if (parse_element(p, eof, &t_name, &t_namelen, NULL, end)) goto pp;
if (strlcasecmp(t_name, t_namelen, "/TEXTAREA", 9)) goto pp;
if (c_strlcasecmp(t_name, t_namelen, "/TEXTAREA", 9)) goto pp;
fc = init_form_control(FC_TEXTAREA, attr, html_context);
if (!fc) return;
@ -684,14 +684,14 @@ pp:
wrap_attr = get_attr_val(attr, "wrap", html_context->doc_cp);
if (wrap_attr) {
if (!strcasecmp(wrap_attr, "hard")
|| !strcasecmp(wrap_attr, "physical")) {
if (!c_strcasecmp(wrap_attr, "hard")
|| !c_strcasecmp(wrap_attr, "physical")) {
fc->wrap = FORM_WRAP_HARD;
} else if (!strcasecmp(wrap_attr, "soft")
|| !strcasecmp(wrap_attr, "virtual")) {
} else if (!c_strcasecmp(wrap_attr, "soft")
|| !c_strcasecmp(wrap_attr, "virtual")) {
fc->wrap = FORM_WRAP_SOFT;
} else if (!strcasecmp(wrap_attr, "none")
|| !strcasecmp(wrap_attr, "off")) {
} else if (!c_strcasecmp(wrap_attr, "none")
|| !c_strcasecmp(wrap_attr, "off")) {
fc->wrap = FORM_WRAP_NONE;
}
mem_free(wrap_attr);

View File

@ -227,10 +227,10 @@ html_script(struct html_context *html_context, unsigned char *a,
if (type) {
unsigned char *pos = type;
if (!strncasecmp(type, "text/", 5)) {
if (!c_strncasecmp(type, "text/", 5)) {
pos += 5;
} else if (!strncasecmp(type, "application/", 12)) {
} else if (!c_strncasecmp(type, "application/", 12)) {
pos += 12;
} else {
@ -241,7 +241,7 @@ not_processed:
return;
}
if (!strncasecmp(pos, "javascript", 10)) {
if (!c_strncasecmp(pos, "javascript", 10)) {
int len = strlen(pos);
if (len > 10 && !isdigit(pos[10])) {
@ -249,11 +249,11 @@ not_processed:
goto not_processed;
}
} else if (strcasecmp(pos, "ecmascript")
&& strcasecmp(pos, "jscript")
&& strcasecmp(pos, "livescript")
&& strcasecmp(pos, "x-javascript")
&& strcasecmp(pos, "x-ecmascript")) {
} else if (c_strcasecmp(pos, "ecmascript")
&& c_strcasecmp(pos, "jscript")
&& c_strcasecmp(pos, "livescript")
&& c_strcasecmp(pos, "x-javascript")
&& c_strcasecmp(pos, "x-ecmascript")) {
mem_free(type);
goto not_processed;
}
@ -271,7 +271,7 @@ not_processed:
if (languagelen < 10
|| (languagelen > 10 && !isdigit(language[10]))
|| strncasecmp(language, "javascript", 10)) {
|| c_strncasecmp(language, "javascript", 10)) {
mem_free(language);
goto not_processed;
}
@ -372,7 +372,7 @@ imported:
* argument. */
if (parse_element(*end, eof, &name, &namelen, NULL, NULL))
continue;
if (strlcasecmp(name, namelen, "/script", 7))
if (c_strlcasecmp(name, namelen, "/script", 7))
continue;
/* We have won! */
break;
@ -482,13 +482,13 @@ html_linebrk(struct html_context *html_context, unsigned char *a,
unsigned char *al = get_attr_val(a, "align", html_context->doc_cp);
if (al) {
if (!strcasecmp(al, "left")) par_format.align = ALIGN_LEFT;
else if (!strcasecmp(al, "right")) par_format.align = ALIGN_RIGHT;
else if (!strcasecmp(al, "center")) {
if (!c_strcasecmp(al, "left")) par_format.align = ALIGN_LEFT;
else if (!c_strcasecmp(al, "right")) par_format.align = ALIGN_RIGHT;
else if (!c_strcasecmp(al, "center")) {
par_format.align = ALIGN_CENTER;
if (!html_context->table_level)
par_format.leftmargin = par_format.rightmargin = 0;
} else if (!strcasecmp(al, "justify")) par_format.align = ALIGN_JUSTIFY;
} else if (!c_strcasecmp(al, "justify")) par_format.align = ALIGN_JUSTIFY;
mem_free(al);
}
}
@ -745,9 +745,9 @@ html_ul(struct html_context *html_context, unsigned char *a,
al = get_attr_val(a, "type", html_context->doc_cp);
if (al) {
if (!strcasecmp(al, "disc") || !strcasecmp(al, "circle"))
if (!c_strcasecmp(al, "disc") || !c_strcasecmp(al, "circle"))
par_format.flags = P_O;
else if (!strcasecmp(al, "square"))
else if (!c_strcasecmp(al, "square"))
par_format.flags = P_PLUS;
mem_free(al);
}
@ -893,7 +893,7 @@ html_li(struct html_context *html_context, unsigned char *a,
if (t == P_ROMAN) {
unsigned char *x;
for (x = n; *x; x++) *x = toupper(*x);
for (x = n; *x; x++) *x = c_toupper(*x);
}
} else {

View File

@ -463,12 +463,12 @@ html_object(struct html_context *html_context, unsigned char *a,
type = get_attr_val(a, "type", html_context->doc_cp);
if (!type) { mem_free(url); return; }
if (!strncasecmp(type, "text/", 5)) {
if (!c_strncasecmp(type, "text/", 5)) {
/* We will just emulate <iframe>. */
html_iframe_do(a, url, html_context);
html_skip(html_context, a);
} else if (!strncasecmp(type, "image/", 6)) {
} else if (!c_strncasecmp(type, "image/", 6)) {
/* <img> emulation. */
/* TODO: Use the enclosed text as 'alt' attribute. */
html_img_do(a, url, html_context);
@ -519,7 +519,7 @@ html_embed(struct html_context *html_context, unsigned char *a,
if (!extension) extension = object_src;
type = get_extension_content_type(extension);
if (type && !strncasecmp(type, "image/", 6)) {
if (type && !c_strncasecmp(type, "image/", 6)) {
html_img_do(a, object_src, html_context);
} else {
/* We will just emulate <iframe>. */
@ -757,26 +757,26 @@ html_link_parse(struct html_context *html_context, unsigned char *a,
/* TODO: fastfind */
for (i = 0; lt_names[i].str; i++)
if (!strcasecmp(link->name, lt_names[i].str)) {
if (!c_strcasecmp(link->name, lt_names[i].str)) {
link->type = lt_names[i].type;
return 1;
}
if (strcasestr(link->name, "icon") ||
(link->content_type && strcasestr(link->content_type, "icon"))) {
if (c_strcasestr(link->name, "icon") ||
(link->content_type && c_strcasestr(link->content_type, "icon"))) {
link->type = LT_ICON;
} else if (strcasestr(link->name, "alternate")) {
} else if (c_strcasestr(link->name, "alternate")) {
link->type = LT_ALTERNATE;
if (link->lang)
link->type = LT_ALTERNATE_LANG;
else if (strcasestr(link->name, "stylesheet") ||
(link->content_type && strcasestr(link->content_type, "css")))
else if (c_strcasestr(link->name, "stylesheet") ||
(link->content_type && c_strcasestr(link->content_type, "css")))
link->type = LT_ALTERNATE_STYLESHEET;
else if (link->media)
link->type = LT_ALTERNATE_MEDIA;
} else if (link->content_type && strcasestr(link->content_type, "css")) {
} else if (link->content_type && c_strcasestr(link->content_type, "css")) {
link->type = LT_STYLESHEET;
}
@ -858,7 +858,7 @@ html_link(struct html_context *html_context, unsigned char *a,
if (link.lang && link.type == LT_ALTERNATE_LANG &&
(link_display < 3 || (link.hreflang &&
strcasecmp(link.hreflang, link.lang)))) {
c_strcasecmp(link.hreflang, link.lang)))) {
APPEND(link.lang);
}

View File

@ -153,7 +153,7 @@ next_attr:
n = name;
name_start = e;
while (atchr(*n) && atchr(*e) && toupper(*e) == toupper(*n)) e++, n++;
while (atchr(*n) && atchr(*e) && c_toupper(*e) == c_toupper(*n)) e++, n++;
found = !*n && !atchr(*e);
if (found && (flags & HTML_ATTR_TEST)) return name_start;
@ -506,8 +506,8 @@ static struct element_info elements[] = {
static int
compar(const void *a, const void *b)
{
return strcasecmp(((struct element_info *) a)->name,
((struct element_info *) b)->name);
return c_strcasecmp(((struct element_info *) a)->name,
((struct element_info *) b)->name);
}
#else
@ -550,7 +550,7 @@ void
init_tags_lookup(void)
{
#ifdef USE_FASTFIND
fastfind_index(&ff_tags_index, FF_COMPRESS);
fastfind_index(&ff_tags_index, FF_COMPRESS | FF_LOCALE_INDEP);
#endif
}
@ -907,11 +907,11 @@ start_element(struct element_info *ei,
foreach (e, html_context->stack) {
if (is_block_element(e) && is_inline_element(ei)) break;
if (e->type < ELEMENT_KILLABLE) break;
if (!strlcasecmp(e->name, e->namelen, name, namelen)) break;
if (!c_strlcasecmp(e->name, e->namelen, name, namelen)) break;
}
}
if (!strlcasecmp(e->name, e->namelen, name, namelen)) {
if (!c_strlcasecmp(e->name, e->namelen, name, namelen)) {
while (e->prev != (void *) &html_context->stack)
kill_html_stack_item(html_context, e->prev);
@ -1084,7 +1084,7 @@ end_element(struct element_info *ei,
* quotation). "she said." will be rendered normally. */
foreach (e, html_context->stack) {
if (is_block_element(e) && is_inline_element(ei)) kill = 1;
if (strlcasecmp(e->name, e->namelen, name, namelen)) {
if (c_strlcasecmp(e->name, e->namelen, name, namelen)) {
if (e->type < ELEMENT_KILLABLE)
break;
else
@ -1183,10 +1183,10 @@ sp:
if (parse_element(s, eof, &name, &namelen, &attr, &s)) goto sp;
ps:
if (!strlcasecmp(name, namelen, "HEAD", 4)) goto se;
if (!strlcasecmp(name, namelen, "/HEAD", 5)) return;
if (!strlcasecmp(name, namelen, "BODY", 4)) return;
if (title && !title->length && !strlcasecmp(name, namelen, "TITLE", 5)) {
if (!c_strlcasecmp(name, namelen, "HEAD", 4)) goto se;
if (!c_strlcasecmp(name, namelen, "/HEAD", 5)) return;
if (!c_strlcasecmp(name, namelen, "BODY", 4)) return;
if (title && !title->length && !c_strlcasecmp(name, namelen, "TITLE", 5)) {
unsigned char *s1;
xse:
@ -1209,7 +1209,7 @@ xsp:
clr_spaces(title->source);
goto ps;
}
if (strlcasecmp(name, namelen, "META", 4)) goto se;
if (c_strlcasecmp(name, namelen, "META", 4)) goto se;
/* FIXME (bug 784): options->cp is the terminal charset;
* should use the document charset instead. */

View File

@ -62,7 +62,7 @@ search_html_stack(struct html_context *html_context, unsigned char *name)
foreach (element, html_context->stack) {
if (element == html_top)
continue; /* skip the top element */
if (strlcasecmp(element->name, element->namelen, name, namelen))
if (c_strlcasecmp(element->name, element->namelen, name, namelen))
continue;
return element;
}
@ -218,7 +218,7 @@ kill_html_stack_until(struct html_context *html_context, int ls, ...)
continue;
}
if (strlcasecmp(e->name, e->namelen, s, slen))
if (c_strlcasecmp(e->name, e->namelen, s, slen))
continue;
if (!sk) {
@ -240,11 +240,11 @@ kill_html_stack_until(struct html_context *html_context, int ls, ...)
va_end(arg);
if (e->type < ELEMENT_KILLABLE
|| (!strlcasecmp(e->name, e->namelen, "TABLE", 5)))
|| (!c_strlcasecmp(e->name, e->namelen, "TABLE", 5)))
break;
if (e->namelen == 2 && toupper(e->name[0]) == 'T') {
unsigned char c = toupper(e->name[1]);
if (e->namelen == 2 && c_toupper(e->name[0]) == 'T') {
unsigned char c = c_toupper(e->name[1]);
if (c == 'D' || c == 'H' || c == 'R')
break;

View File

@ -89,11 +89,11 @@ get_align(struct html_context *html_context, unsigned char *attr, int *a)
if (!al) return;
if (!strcasecmp(al, "left")) *a = ALIGN_LEFT;
else if (!strcasecmp(al, "right")) *a = ALIGN_RIGHT;
else if (!strcasecmp(al, "center")) *a = ALIGN_CENTER;
else if (!strcasecmp(al, "justify")) *a = ALIGN_JUSTIFY;
else if (!strcasecmp(al, "char")) *a = ALIGN_RIGHT; /* NOT IMPLEMENTED */
if (!c_strcasecmp(al, "left")) *a = ALIGN_LEFT;
else if (!c_strcasecmp(al, "right")) *a = ALIGN_RIGHT;
else if (!c_strcasecmp(al, "center")) *a = ALIGN_CENTER;
else if (!c_strcasecmp(al, "justify")) *a = ALIGN_JUSTIFY;
else if (!c_strcasecmp(al, "char")) *a = ALIGN_RIGHT; /* NOT IMPLEMENTED */
mem_free(al);
}
@ -104,10 +104,10 @@ get_valign(struct html_context *html_context, unsigned char *attr, int *a)
if (!al) return;
if (!strcasecmp(al, "top")) *a = VALIGN_TOP;
else if (!strcasecmp(al, "middle")) *a = VALIGN_MIDDLE;
else if (!strcasecmp(al, "bottom")) *a = VALIGN_BOTTOM;
else if (!strcasecmp(al, "baseline")) *a = VALIGN_BASELINE; /* NOT IMPLEMENTED */
if (!c_strcasecmp(al, "top")) *a = VALIGN_TOP;
else if (!c_strcasecmp(al, "middle")) *a = VALIGN_MIDDLE;
else if (!c_strcasecmp(al, "bottom")) *a = VALIGN_BOTTOM;
else if (!c_strcasecmp(al, "baseline")) *a = VALIGN_BASELINE; /* NOT IMPLEMENTED */
mem_free(al);
}
@ -154,16 +154,16 @@ set_table_frame(struct html_context *html_context, struct table *table,
al = get_attr_val(attr, "frame", html_context->doc_cp);
if (!al) return;
if (!strcasecmp(al, "void")) table->frame = TABLE_FRAME_VOID;
else if (!strcasecmp(al, "above")) table->frame = TABLE_FRAME_ABOVE;
else if (!strcasecmp(al, "below")) table->frame = TABLE_FRAME_BELOW;
else if (!strcasecmp(al, "hsides")) table->frame = TABLE_FRAME_HSIDES;
else if (!strcasecmp(al, "vsides")) table->frame = TABLE_FRAME_VSIDES;
else if (!strcasecmp(al, "lhs")) table->frame = TABLE_FRAME_LHS;
else if (!strcasecmp(al, "rhs")) table->frame = TABLE_FRAME_RHS;
if (!c_strcasecmp(al, "void")) table->frame = TABLE_FRAME_VOID;
else if (!c_strcasecmp(al, "above")) table->frame = TABLE_FRAME_ABOVE;
else if (!c_strcasecmp(al, "below")) table->frame = TABLE_FRAME_BELOW;
else if (!c_strcasecmp(al, "hsides")) table->frame = TABLE_FRAME_HSIDES;
else if (!c_strcasecmp(al, "vsides")) table->frame = TABLE_FRAME_VSIDES;
else if (!c_strcasecmp(al, "lhs")) table->frame = TABLE_FRAME_LHS;
else if (!c_strcasecmp(al, "rhs")) table->frame = TABLE_FRAME_RHS;
/* Following tests are useless since TABLE_FRAME_BOX is the default.
* else if (!strcasecmp(al, "box")) table->frame = TABLE_FRAME_BOX;
* else if (!strcasecmp(al, "border")) table->frame = TABLE_FRAME_BOX;
* else if (!c_strcasecmp(al, "box")) table->frame = TABLE_FRAME_BOX;
* else if (!c_strcasecmp(al, "border")) table->frame = TABLE_FRAME_BOX;
*/
mem_free(al);
}
@ -179,11 +179,11 @@ set_table_rules(struct html_context *html_context, struct table *table,
al = get_attr_val(attr, "rules", html_context->doc_cp);
if (!al) return;
if (!strcasecmp(al, "none")) table->rules = TABLE_RULE_NONE;
else if (!strcasecmp(al, "groups")) table->rules = TABLE_RULE_GROUPS;
else if (!strcasecmp(al, "rows")) table->rules = TABLE_RULE_ROWS;
else if (!strcasecmp(al, "cols")) table->rules = TABLE_RULE_COLS;
else if (!strcasecmp(al, "all")) table->rules = TABLE_RULE_ALL;
if (!c_strcasecmp(al, "none")) table->rules = TABLE_RULE_NONE;
else if (!c_strcasecmp(al, "groups")) table->rules = TABLE_RULE_GROUPS;
else if (!c_strcasecmp(al, "rows")) table->rules = TABLE_RULE_ROWS;
else if (!c_strcasecmp(al, "cols")) table->rules = TABLE_RULE_COLS;
else if (!c_strcasecmp(al, "all")) table->rules = TABLE_RULE_ALL;
mem_free(al);
}
@ -527,7 +527,7 @@ skip_table(unsigned char *html, unsigned char *eof)
}
if (!strlcasecmp(name, namelen, "TABLE", 5)) {
if (!c_strlcasecmp(name, namelen, "TABLE", 5)) {
if (!closing_tag) {
level++;
} else {
@ -608,7 +608,7 @@ see:
closing_tag = 0;
}
if (!strlcasecmp(name, namelen, "TABLE", 5)) {
if (!c_strlcasecmp(name, namelen, "TABLE", 5)) {
if (!closing_tag) {
en = skip_table(en, eof);
goto see;
@ -623,7 +623,7 @@ see:
}
}
if (!strlcasecmp(name, namelen, "CAPTION", 7)) {
if (!c_strlcasecmp(name, namelen, "CAPTION", 7)) {
if (!closing_tag) {
add_table_bad_html_end(table, html);
if (!table->caption.start)
@ -637,7 +637,7 @@ see:
goto see;
}
if (!strlcasecmp(name, namelen, "COLGROUP", 8)) {
if (!c_strlcasecmp(name, namelen, "COLGROUP", 8)) {
if (c_span) new_columns(table, c_span, c_width, c_al, c_val, 1);
add_table_bad_html_end(table, html);
@ -663,7 +663,7 @@ see:
goto see;
}
if (!closing_tag && !strlcasecmp(name, namelen, "COL", 3)) {
if (!closing_tag && !c_strlcasecmp(name, namelen, "COL", 3)) {
int sp, width, al, val;
add_table_bad_html_end(table, html);
@ -684,12 +684,12 @@ see:
}
/* All following tags have T as first letter. */
if (toupper(name[0]) != 'T') goto see;
if (c_toupper(name[0]) != 'T') goto see;
name++; namelen--;
if (namelen == 0) goto see;
c = toupper(name[0]);
c = c_toupper(name[0]);
/* /TR /TD /TH */
if (closing_tag && namelen == 1) {
@ -712,9 +712,9 @@ see:
/* THEAD TBODY TFOOT */
if (namelen == 4
&& ((!strlcasecmp(name, namelen, "HEAD", 4)) ||
(!strlcasecmp(name, namelen, "BODY", 4)) ||
(!strlcasecmp(name, namelen, "FOOT", 4)))) {
&& ((!c_strlcasecmp(name, namelen, "HEAD", 4)) ||
(!c_strlcasecmp(name, namelen, "BODY", 4)) ||
(!c_strlcasecmp(name, namelen, "FOOT", 4)))) {
if (c_span) new_columns(table, c_span, c_width, c_al, c_val, 1);
add_table_bad_html_end(table, html);

View File

@ -1389,7 +1389,7 @@ new_link(struct html_context *html_context, unsigned char *name, int namelen)
if (!format.form) {
link->target = null_or_stracpy(format.target);
link->data.name = memacpy(name, namelen);
/* if (strlen(url) > 4 && !strncasecmp(url, "MAP@", 4)) { */
/* if (strlen(url) > 4 && !c_strncasecmp(url, "MAP@", 4)) { */
if (format.link
&& ((format.link[0]|32) == 'm')
&& ((format.link[1]|32) == 'a')

View File

@ -96,7 +96,7 @@ int
compare_opt(struct document_options *o1, struct document_options *o2)
{
return memcmp(o1, o2, offsetof(struct document_options, framename))
|| strcasecmp(o1->framename, o2->framename)
|| c_strcasecmp(o1->framename, o2->framename)
|| (o1->box.x != o2->box.x)
|| (o1->box.y != o2->box.y)
|| ((o1->needs_height || o2->needs_height)

View File

@ -244,13 +244,13 @@ render_encoded_document(struct cache_entry *cached, struct document *document)
if (document->options.plain) {
#ifdef CONFIG_DOM
if (cached->content_type
&& (!strcasecmp("text/html", cached->content_type)
|| !strcasecmp("application/xhtml+xml", cached->content_type)
|| !strcasecmp("application/docbook+xml", cached->content_type)
|| !strcasecmp("application/rss+xml", cached->content_type)
|| !strcasecmp("application/xbel+xml", cached->content_type)
|| !strcasecmp("application/x-xbel", cached->content_type)
|| !strcasecmp("application/xbel", cached->content_type)))
&& (!c_strcasecmp("text/html", cached->content_type)
|| !c_strcasecmp("application/xhtml+xml", cached->content_type)
|| !c_strcasecmp("application/docbook+xml", cached->content_type)
|| !c_strcasecmp("application/rss+xml", cached->content_type)
|| !c_strcasecmp("application/xbel+xml", cached->content_type)
|| !c_strcasecmp("application/x-xbel", cached->content_type)
|| !c_strcasecmp("application/xbel", cached->content_type)))
render_dom_document(cached, document, &buffer);
else
#endif
@ -259,7 +259,7 @@ render_encoded_document(struct cache_entry *cached, struct document *document)
} else {
#ifdef CONFIG_DOM
if (cached->content_type
&& (!strlcasecmp("application/rss+xml", 19, cached->content_type, -1)))
&& (!c_strlcasecmp("application/rss+xml", 19, cached->content_type, -1)))
render_dom_document(cached, document, &buffer);
else
#endif

View File

@ -290,7 +290,7 @@ scan_css_token(struct dom_scanner *scanner, struct dom_scanner_token *token)
} else if (first_char == '!') {
scan_css(scanner, string, CSS_CHAR_WHITESPACE);
if (!strncasecmp(string, "important", 9)) {
if (!c_strncasecmp(string, "important", 9)) {
type = CSS_TOKEN_IMPORTANT;
string += 9;
}

View File

@ -35,7 +35,7 @@ struct dom_scanner_token {
/** Compare the token string to a "static" string */
#define dom_scanner_token_contains(token, str) \
((token)->string.length == (sizeof(str) - 1) \
&& !strncasecmp((token)->string.string, str, sizeof(str) - 1))
&& !c_strncasecmp((token)->string.string, str, sizeof(str) - 1))
struct dom_scan_table_info {

View File

@ -1,6 +1,7 @@
#ifndef EL_DOM_STRING_H
#define EL_DOM_STRING_H
#include "util/conv.h"
#include "util/memory.h"
/* For now DOM has it's own little string library. Mostly because there are
@ -31,9 +32,9 @@ static inline int
dom_string_casecmp(const struct dom_string *string1, const struct dom_string *string2)
{
size_t length = int_min(string1->length, string2->length);
size_t string_diff = strncasecmp(string1->string, string2->string, length);
size_t string_diff = c_strncasecmp(string1->string, string2->string, length);
/* If the lengths or strings don't match strncasecmp() does the
/* If the lengths or strings don't match c_strncasecmp() does the
* job else return which ever is bigger. */
return string_diff ? string_diff : string1->length - string2->length;
}
@ -41,7 +42,7 @@ dom_string_casecmp(const struct dom_string *string1, const struct dom_string *st
static inline int
dom_string_ncasecmp(struct dom_string *string1, struct dom_string *string2, size_t length)
{
return strncasecmp(string1->string, string2->string, length);
return c_strncasecmp(string1->string, string2->string, length);
}
#define copy_dom_string(string1, string2) \

View File

@ -153,7 +153,7 @@ document_get(struct SEE_interpreter *interp, struct SEE_object *o,
if (!string) return;
foreach (form, document->forms) {
if (!form->name || strcasecmp(string, form->name))
if (!form->name || c_strcasecmp(string, form->name))
continue;
form_view = find_form_view(doc_view, form);
form_object = js_get_form_object(interp, doc, form_view);

View File

@ -689,7 +689,7 @@ js_form_elems_namedItem(struct SEE_interpreter *interp, struct SEE_object *self,
return;
foreach (fc, form->items) {
if ((fc->id && !strcasecmp(string, fc->id)) || (fc->name && !strcasecmp(string, fc->name))) {
if ((fc->id && !c_strcasecmp(string, fc->id)) || (fc->name && !c_strcasecmp(string, fc->name))) {
struct form_state *fs = find_form_state(doc_view, fc);
if (fs) {
@ -815,7 +815,7 @@ js_forms_namedItem(struct SEE_interpreter *interp, struct SEE_object *self,
if (!string)
return;
foreach (form, document->forms) {
if (form->name && !strcasecmp(string, form->name)) {
if (form->name && !c_strcasecmp(string, form->name)) {
struct form_view *fv = find_form_view(doc_view, form);
struct js_form *obj = js_get_form_object(interp,
doc, fv);
@ -952,7 +952,7 @@ form_get(struct SEE_interpreter *interp, struct SEE_object *o,
struct js_input *fcobj = NULL;
struct form_state *fs;
if ((!fc->id || strcasecmp(string, fc->id)) && (!fc->name || strcasecmp(string, fc->name)))
if ((!fc->id || c_strcasecmp(string, fc->id)) && (!fc->name || c_strcasecmp(string, fc->name)))
continue;
fs = find_form_state(doc_view, fc);
if (fs) {
@ -989,19 +989,19 @@ form_put(struct SEE_interpreter *interp, struct SEE_object *o,
mem_free_set(&form->action, string);
}
} else if (p == s_encoding) {
if (!strcasecmp(string, "application/x-www-form-urlencoded")) {
if (!c_strcasecmp(string, "application/x-www-form-urlencoded")) {
form->method = form->method == FORM_METHOD_GET ? FORM_METHOD_GET
: FORM_METHOD_POST;
} else if (!strcasecmp(string, "multipart/form-data")) {
} else if (!c_strcasecmp(string, "multipart/form-data")) {
form->method = FORM_METHOD_POST_MP;
} else if (!strcasecmp(string, "text/plain")) {
} else if (!c_strcasecmp(string, "text/plain")) {
form->method = FORM_METHOD_POST_TEXT_PLAIN;
}
mem_free(string);
} else if (p == s_method) {
if (!strcasecmp(string, "GET")) {
if (!c_strcasecmp(string, "GET")) {
form->method = FORM_METHOD_GET;
} else if (!strcasecmp(string, "POST")) {
} else if (!c_strcasecmp(string, "POST")) {
form->method = FORM_METHOD_POST;
}
mem_free(string);

View File

@ -304,7 +304,7 @@ js_window_open(struct SEE_interpreter *interp, struct SEE_object *self,
return;
}
if (frame && *frame && strcasecmp(frame, "_blank")) {
if (frame && *frame && c_strcasecmp(frame, "_blank")) {
struct delayed_open *deo = mem_calloc(1, sizeof(*deo));
if (deo) {

View File

@ -126,7 +126,7 @@ document_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
}
#endif
foreach (form, document->forms) {
if (!form->name || strcasecmp(string, form->name))
if (!form->name || c_strcasecmp(string, form->name))
continue;
object_to_jsval(ctx, vp, get_form_object(ctx, obj, find_form_view(doc_view, form)));

View File

@ -857,7 +857,8 @@ form_elements_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
undef_to_jsval(ctx, rval);
foreach (fc, form->items) {
if ((fc->id && !strcasecmp(string, fc->id)) || (fc->name && !strcasecmp(string, fc->name))) {
if ((fc->id && !c_strcasecmp(string, fc->id))
|| (fc->name && !c_strcasecmp(string, fc->name))) {
struct form_state *fs = find_form_state(doc_view, fc);
if (fs) {
@ -979,7 +980,8 @@ form_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
JSObject *fcobj = NULL;
struct form_state *fs;
if ((!fc->id || strcasecmp(string, fc->id)) && (!fc->name || strcasecmp(string, fc->name)))
if ((!fc->id || c_strcasecmp(string, fc->id))
&& (!fc->name || c_strcasecmp(string, fc->name)))
continue;
undef_to_jsval(ctx, vp);
@ -1120,21 +1122,21 @@ form_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
case JSP_FORM_ENCODING:
string = jsval_to_string(ctx, vp);
if (!strcasecmp(string, "application/x-www-form-urlencoded")) {
if (!c_strcasecmp(string, "application/x-www-form-urlencoded")) {
form->method = form->method == FORM_METHOD_GET ? FORM_METHOD_GET
: FORM_METHOD_POST;
} else if (!strcasecmp(string, "multipart/form-data")) {
} else if (!c_strcasecmp(string, "multipart/form-data")) {
form->method = FORM_METHOD_POST_MP;
} else if (!strcasecmp(string, "text/plain")) {
} else if (!c_strcasecmp(string, "text/plain")) {
form->method = FORM_METHOD_POST_TEXT_PLAIN;
}
break;
case JSP_FORM_METHOD:
string = jsval_to_string(ctx, vp);
if (!strcasecmp(string, "GET")) {
if (!c_strcasecmp(string, "GET")) {
form->method = FORM_METHOD_GET;
} else if (!strcasecmp(string, "POST")) {
} else if (!c_strcasecmp(string, "POST")) {
form->method = FORM_METHOD_POST;
}
break;
@ -1353,7 +1355,7 @@ find_form_by_name(JSContext *ctx, JSObject *jsdoc,
return;
foreach (form, doc_view->document->forms) {
if (form->name && !strcasecmp(string, form->name)) {
if (form->name && !c_strcasecmp(string, form->name)) {
object_to_jsval(ctx, rval, get_form_object(ctx, jsdoc,
find_form_view(doc_view, form)));
break;

View File

@ -399,7 +399,7 @@ window_open(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return JS_TRUE;
}
if (frame && *frame && strcasecmp(frame, "_blank")) {
if (frame && *frame && c_strcasecmp(frame, "_blank")) {
struct delayed_open *deo = mem_calloc(1, sizeof(*deo));
if (deo) {

View File

@ -318,7 +318,7 @@ globhist_simple_search(unsigned char *search_url, unsigned char *search_title)
if ((*search_title
&& strcasestr(history_item->title, search_title))
|| (*search_url
&& strcasestr(history_item->url, search_url))) {
&& c_strcasestr(history_item->url, search_url))) {
history_item->box_item->visible = 1;
} else {
history_item->box_item->visible = 0;

View File

@ -1376,7 +1376,7 @@ get_cp_index(const unsigned char *name)
int i, a;
int syscp = 0;
if (!strcasecmp(name, "System")) {
if (!c_strcasecmp(name, "System")) {
#if HAVE_LANGINFO_CODESET
name = nl_langinfo(CODESET);
syscp = SYSTEM_CHARSET_FLAG;
@ -1399,7 +1399,7 @@ get_cp_index(const unsigned char *name)
* once. So we will do a simple strcasecmp() here.
*/
if (!strcasecmp(name, codepages[i].aliases[a]))
if (!c_strcasecmp(name, codepages[i].aliases[a]))
return i | syscp;
}
}
@ -1457,7 +1457,7 @@ get_cp_index(const unsigned char *name)
const struct codepage_desc *codepage;
int syscp = 0;
if (!strcasecmp(name, "System")) {
if (!c_strcasecmp(name, "System")) {
#if HAVE_LANGINFO_CODESET
name = nl_langinfo(CODESET);
syscp = SYSTEM_CHARSET_FLAG;

View File

@ -35,6 +35,7 @@
#include "elinks.h"
#include "intl/gettext/loadinfo.h"
#include "util/conv.h"
#include "util/string.h"
/* Awful hack to permit compilation under cygwin and its broken configure.
@ -349,7 +350,7 @@ _nl_normalize_codeset(const unsigned char *codeset, size_t name_len)
for (cnt = 0; cnt < name_len; ++cnt)
if (isalpha(codeset[cnt]))
*wp++ = tolower(codeset[cnt]);
*wp++ = c_tolower(codeset[cnt]);
else if (isdigit(codeset[cnt]))
*wp++ = codeset[cnt];

View File

@ -152,7 +152,7 @@ name_to_language(const unsigned char *name)
int i;
for (i = 0; languages[i].name; i++) {
if (strcasecmp(languages[i].name, name))
if (c_strcasecmp(languages[i].name, name))
continue;
return i;
}

View File

@ -285,5 +285,5 @@ extend_alias_table(void)
static int
alias_compare(const struct alias_map *map1, const struct alias_map *map2)
{
return strcasecmp(map1->alias, map2->alias);
return c_strcasecmp(map1->alias, map2->alias);
}

View File

@ -280,13 +280,13 @@ parse_optional_fields(struct mailcap_entry *entry, unsigned char *line)
if (!field) break;
if (!strncasecmp(field, "needsterminal", 13)) {
if (!c_strncasecmp(field, "needsterminal", 13)) {
entry->needsterminal = 1;
} else if (!strncasecmp(field, "copiousoutput", 13)) {
} else if (!c_strncasecmp(field, "copiousoutput", 13)) {
entry->copiousoutput = 1;
} else if (!strncasecmp(field, "test", 4)) {
} else if (!c_strncasecmp(field, "test", 4)) {
entry->testcommand = get_mailcap_field_text(field + 4);
if (!entry->testcommand)
return 0;
@ -298,7 +298,7 @@ parse_optional_fields(struct mailcap_entry *entry, unsigned char *line)
return 0;
}
} else if (!strncasecmp(field, "description", 11)) {
} else if (!c_strncasecmp(field, "description", 11)) {
entry->description = get_mailcap_field_text(field + 11);
if (!entry->description)
return 0;

View File

@ -249,7 +249,7 @@ get_fragment_content_type(struct cache_entry *cached)
if (!sample)
return NULL;
if (strcasestr(sample, "<html>"))
if (c_strcasestr(sample, "<html>"))
ctype = stracpy("text/html");
mem_free(sample);
@ -291,7 +291,7 @@ get_content_type(struct cache_entry *cached)
* is with default (via option system) and mimetypes resolving
* doing that option and hash lookup will not be easy to
* convert. --jonas */
convert_to_lowercase(extension, strlen(extension));
convert_to_lowercase_locale_indep(extension, strlen(extension));
ctype = get_extension_content_type(extension);
mem_free(extension);

View File

@ -89,7 +89,7 @@ find_in_dns_cache(unsigned char *name)
struct dnsentry *dnsentry;
foreach (dnsentry, dns_cache)
if (!strcasecmp(dnsentry->name, name)) {
if (!c_strcasecmp(dnsentry->name, name)) {
move_to_top_of_list(dns_cache, dnsentry);
return dnsentry;
}

View File

@ -41,7 +41,7 @@ get_system_env(void)
int env = get_common_env();
unsigned char *term = getenv("TERM");
if (!term || (toupper(term[0]) == 'B' && toupper(term[1]) == 'E'))
if (!term || (c_toupper(term[0]) == 'B' && c_toupper(term[1]) == 'E'))
env |= ENV_BE;
return env;

View File

@ -297,7 +297,7 @@ auth_user_matching_uri(struct auth_entry *auth, struct uri *uri)
{
if (!uri->userlen) /* Noone said it doesn't. */
return 1;
return !strlcasecmp(auth->user, -1, uri->user, uri->userlen);
return !c_strlcasecmp(auth->user, -1, uri->user, uri->userlen);
}
@ -907,7 +907,7 @@ next:
if (pos + 4 > data_len)
return -1;
if (strncasecmp(&data[pos], "byte", 4))
if (c_strncasecmp(&data[pos], "byte", 4))
return -1;
errno = 0;

View File

@ -224,7 +224,7 @@ add_gopher_command(struct connection *conn, struct string *command,
querylen = selector + selectorlen - query;
/* Exclude '?' */
selectorlen -= querylen + 1;
if (querylen >= 7 && !strncasecmp(query, "search=", 7)) {
if (querylen >= 7 && !c_strncasecmp(query, "search=", 7)) {
query += 7;
querylen -= 7;
}

View File

@ -133,7 +133,7 @@ parse_header(unsigned char *head, unsigned char *item, unsigned char **ptr)
/* Does item match header line ? */
for (itempos = item; *itempos && *pos; itempos++, pos++)
if (toupper(*itempos) != toupper(*pos))
if (c_toupper(*itempos) != c_toupper(*pos))
break;
if (!*pos) break; /* Nothing left to parse. */
@ -226,7 +226,7 @@ parse_header_param(unsigned char *str, unsigned char *name, unsigned char **ret)
while (*p && (*p == ';' || *p <= ' ')) p++;
if (strlen(p) < namelen) return HEADER_PARAM_NOT_FOUND;
} while (strncasecmp(p, name, namelen));
} while (c_strncasecmp(p, name, namelen));
p += namelen;
@ -275,11 +275,11 @@ get_header_param(unsigned char *e, unsigned char *name)
unsigned char *n, *start;
again:
while (*e && toupper(*e++) != toupper(*name));
while (*e && c_toupper(*e++) != c_toupper(*name));
if (!*e) return NULL;
n = name + 1;
while (*n && toupper(*e) == toupper(*n)) e++, n++;
while (*n && c_toupper(*e) == c_toupper(*n)) e++, n++;
if (*n) goto again;
skip_space(e);

View File

@ -34,7 +34,7 @@ get_blacklist_entry(struct uri *uri)
if_assert_failed return NULL;
foreach (entry, blacklist)
if (!strlcasecmp(entry->host, -1, uri->host, uri->hostlen))
if (!c_strlcasecmp(entry->host, -1, uri->host, uri->hostlen))
return entry;
return NULL;

View File

@ -385,8 +385,8 @@ get_http_code(struct read_buffer *rb, int *code, struct http_version *version)
while (*head == ' ') head++;
/* HTTP/ */
if (toupper(*head) != 'H' || toupper(*++head) != 'T' ||
toupper(*++head) != 'T' || toupper(*++head) != 'P'
if (c_toupper(*head) != 'H' || c_toupper(*++head) != 'T' ||
c_toupper(*++head) != 'T' || c_toupper(*++head) != 'P'
|| *++head != '/')
return -1;
@ -1409,7 +1409,7 @@ get_header(struct read_buffer *rb)
/* XXX: We will have to do some guess about whether an HTTP header is
* coming or not, in order to support HTTP/0.9 reply correctly. This
* means a little code duplication with get_http_code(). --pasky */
if (rb->length > 4 && strncasecmp(rb->data, "HTTP/", 5))
if (rb->length > 4 && c_strncasecmp(rb->data, "HTTP/", 5))
return -2;
for (i = 0; i < rb->length; i++) {
@ -1446,7 +1446,7 @@ check_http_authentication(struct connection *conn, struct uri *uri,
d = parse_header(header, header_field, &str);
while (d) {
if (!strncasecmp(d, "Basic", 5)) {
if (!c_strncasecmp(d, "Basic", 5)) {
unsigned char *realm = get_header_param(d, "realm");
if (realm) {
@ -1455,7 +1455,7 @@ check_http_authentication(struct connection *conn, struct uri *uri,
mem_free(d);
break;
}
} else if (!strncasecmp(d, "Digest", 6)) {
} else if (!c_strncasecmp(d, "Digest", 6)) {
unsigned char *realm = get_header_param(d, "realm");
unsigned char *nonce = get_header_param(d, "nonce");
unsigned char *opaque = get_header_param(d, "opaque");
@ -1469,13 +1469,13 @@ check_http_authentication(struct connection *conn, struct uri *uri,
break;
}
#ifdef CONFIG_GSSAPI
else if (!strncasecmp(d, HTTPNEG_GSS_STR, HTTPNEG_GSS_STRLEN)) {
else if (!c_strncasecmp(d, HTTPNEG_GSS_STR, HTTPNEG_GSS_STRLEN)) {
if (http_negotiate_input(conn, uri, HTTPNEG_GSS, str)==0)
ret = 1;
mem_free(d);
break;
}
else if (!strncasecmp(d, HTTPNEG_NEG_STR, HTTPNEG_NEG_STRLEN)) {
else if (!c_strncasecmp(d, HTTPNEG_NEG_STR, HTTPNEG_NEG_STRLEN)) {
if (http_negotiate_input(conn, uri, HTTPNEG_NEG, str)==0)
ret = 1;
mem_free(d);
@ -1730,7 +1730,7 @@ again:
d = parse_header(conn->cached->head, "Proxy-Authenticate", &str);
while (d) {
if (!strncasecmp(d, "Basic", 5)) {
if (!c_strncasecmp(d, "Basic", 5)) {
unsigned char *realm = get_header_param(d, "realm");
if (realm) {
@ -1740,7 +1740,7 @@ again:
break;
}
} else if (!strncasecmp(d, "Digest", 6)) {
} else if (!c_strncasecmp(d, "Digest", 6)) {
unsigned char *realm = get_header_param(d, "realm");
unsigned char *nonce = get_header_param(d, "nonce");
unsigned char *opaque = get_header_param(d, "opaque");
@ -1766,7 +1766,7 @@ again:
if ((d = parse_header(conn->cached->head, "Connection", NULL))
|| (d = parse_header(conn->cached->head, "Proxy-Connection", NULL))) {
if (!strcasecmp(d, "close")) http->close = 1;
if (!c_strcasecmp(d, "close")) http->close = 1;
mem_free(d);
} else if (PRE_HTTP_1_1(version)) {
http->close = 1;
@ -1778,7 +1778,7 @@ again:
if (d) {
if (strlen(d) > 6) {
d[5] = 0;
if (isdigit(d[6]) && !strcasecmp(d, "bytes")) {
if (isdigit(d[6]) && !c_strcasecmp(d, "bytes")) {
int f;
errno = 0;
@ -1834,7 +1834,7 @@ again:
d = parse_header(conn->cached->head, "Accept-Ranges", NULL);
if (d) {
if (!strcasecmp(d, "none"))
if (!c_strcasecmp(d, "none"))
conn->unrestartable = 1;
mem_free(d);
} else {
@ -1845,7 +1845,7 @@ again:
d = parse_header(conn->cached->head, "Transfer-Encoding", NULL);
if (d) {
if (!strcasecmp(d, "chunked")) {
if (!c_strcasecmp(d, "chunked")) {
http->length = LEN_CHUNKED;
http->chunk_remaining = CHUNK_SIZE;
}
@ -1855,7 +1855,7 @@ again:
d = parse_header(conn->cached->head, "Last-Modified", NULL);
if (d) {
if (conn->cached->last_modified && strcasecmp(conn->cached->last_modified, d)) {
if (conn->cached->last_modified && c_strcasecmp(conn->cached->last_modified, d)) {
delete_entry_content(conn->cached);
if (conn->from) {
conn->from = 0;
@ -1917,21 +1917,21 @@ again:
* will leave the saved file with the correct encoding. */
#ifdef CONFIG_GZIP
if (file_encoding != ENCODING_GZIP
&& (!strcasecmp(d, "gzip") || !strcasecmp(d, "x-gzip")))
&& (!c_strcasecmp(d, "gzip") || !c_strcasecmp(d, "x-gzip")))
conn->content_encoding = ENCODING_GZIP;
if (!strcasecmp(d, "deflate") || !strcasecmp(d, "x-deflate"))
if (!c_strcasecmp(d, "deflate") || !c_strcasecmp(d, "x-deflate"))
conn->content_encoding = ENCODING_DEFLATE;
#endif
#ifdef CONFIG_BZIP2
if (file_encoding != ENCODING_BZIP2
&& (!strcasecmp(d, "bzip2") || !strcasecmp(d, "x-bzip2")))
&& (!c_strcasecmp(d, "bzip2") || !c_strcasecmp(d, "x-bzip2")))
conn->content_encoding = ENCODING_BZIP2;
#endif
#ifdef CONFIG_LZMA
if (file_encoding != ENCODING_LZMA
&& (!strcasecmp(d, "lzma") || !strcasecmp(d, "x-lzma")))
&& (!c_strcasecmp(d, "lzma") || !c_strcasecmp(d, "x-lzma")))
conn->content_encoding = ENCODING_LZMA;
#endif
mem_free(d);

View File

@ -297,9 +297,9 @@ add_header_to_string(struct string *str, unsigned char *header)
break;
for (sp = end; sp < cp; sp++)
charset_q[sp - end] = tolower(*sp);
charset_q[sp - end] = c_tolower(*sp);
charset_q[cp - end] = 0;
encoding = tolower(cp[1]);
encoding = c_tolower(cp[1]);
if (!encoding || cp[2] != '?')
break;

View File

@ -114,7 +114,7 @@ get_protocol(unsigned char *name, int namelen)
unsigned char *pname = protocol_backends[protocol].name;
int pnamelen = strlen(pname);
int minlen = int_min(pnamelen, namelen);
int compare = strncasecmp(pname, name, minlen);
int compare = c_strncasecmp(pname, name, minlen);
if (compare == 0) {
if (pnamelen == namelen)

View File

@ -37,7 +37,7 @@ proxy_probe_no_proxy(unsigned char *url, unsigned char *no_proxy)
skip_space(no_proxy);
if (jumper) *jumper = '\0';
if (strcasestr(url, no_proxy)) {
if (c_strcasestr(url, no_proxy)) {
if (jumper) *jumper = ',';
if (slash) *slash = '/';
return 1;
@ -86,9 +86,9 @@ strip_proxy_protocol(unsigned char *proxy,
{
assert(proxy && *proxy);
if (!strncasecmp(proxy, strip1, strlen(strip1)))
if (!c_strncasecmp(proxy, strip1, strlen(strip1)))
proxy += strlen(strip1);
else if (strip2 && !strncasecmp(proxy, strip2, strlen(strip2)))
else if (strip2 && !c_strncasecmp(proxy, strip2, strlen(strip2)))
proxy += strlen(strip2);
return proxy;

View File

@ -67,13 +67,13 @@ is_in_domain(unsigned char *domain, unsigned char *server, int server_len)
return 0;
if (domain_len == server_len)
return !strncasecmp(domain, server, server_len);
return !c_strncasecmp(domain, server, server_len);
len = server_len - domain_len;
if (server[len - 1] != '.')
return 0;
return !strncasecmp(domain, server + len, domain_len);
return !c_strncasecmp(domain, server + len, domain_len);
}
int
@ -131,7 +131,7 @@ end_with_known_tld(const unsigned char *s, int slen)
int tldlen = strlen(tld[i]);
int pos = slen - tldlen;
if (pos >= 0 && !strncasecmp(&s[pos], tld[i], tldlen))
if (pos >= 0 && !c_strncasecmp(&s[pos], tld[i], tldlen))
return pos;
}
@ -274,7 +274,7 @@ parse_uri(struct uri *uri, unsigned char *uristring)
/* A bit of a special case, but using the "normal" host
* parsing seems a bit scary at this point. (see bug 107). */
if (datalen > 9 && !strncasecmp(prefix_end, "localhost/", 10)) {
if (datalen > 9 && !c_strncasecmp(prefix_end, "localhost/", 10)) {
prefix_end += 9;
datalen -= 9;
}
@ -711,8 +711,8 @@ normalize_uri(struct uri *uri, unsigned char *uristring)
* get_translated_uri() through translate_url() calls this
* function and then it already works on and modifies an
* allocated copy. */
convert_to_lowercase(uri->string, uri->protocollen);
if (uri->hostlen) convert_to_lowercase(uri->host, uri->hostlen);
convert_to_lowercase_locale_indep(uri->string, uri->protocollen);
if (uri->hostlen) convert_to_lowercase_locale_indep(uri->host, uri->hostlen);
parse = 1;
parse_string = uri->data;
@ -1023,7 +1023,7 @@ find_uri_protocol(unsigned char *newurl)
ch = newurl + strcspn(newurl, ".:/@");
if (*ch == '@'
|| (*ch == ':' && *newurl != '[' && strchr(newurl, '@'))
|| !strncasecmp(newurl, "ftp.", 4)) {
|| !c_strncasecmp(newurl, "ftp.", 4)) {
/* Contains user/password/ftp-hostname */
return PROTOCOL_FTP;
@ -1521,11 +1521,11 @@ check_uri_sanity(struct uri *uri)
int pos;
for (pos = 0; pos < uri->protocollen; pos++)
if (isupper(uri->string[pos])) goto error;
if (c_isupper(uri->string[pos])) goto error;
if (uri->hostlen)
for (pos = 0; pos < uri->hostlen; pos++)
if (isupper(uri->host[pos])) goto error;
if (c_isupper(uri->host[pos])) goto error;
return;
error:
INTERNAL("Uppercase letters detected in protocol or host part (%s).", struri(uri));

View File

@ -104,7 +104,7 @@ get_user_program(struct terminal *term, unsigned char *progid, int progidlen)
/* Now add lowercased progid part. Delicious. */
add_bytes_to_string(&name, progid, progidlen);
convert_to_lowercase(&name.source[sizeof("protocol.user.") - 1], progidlen);
convert_to_lowercase_locale_indep(&name.source[sizeof("protocol.user.") - 1], progidlen);
add_char_to_string(&name, '.');
add_to_string(&name, get_system_str(xwin));

View File

@ -1316,7 +1316,7 @@ setup_download_handler(struct session *ses, struct download *loading,
goto plaintext_follow;
for (i = 0; known_types[i].type; i++) {
if (strcasecmp(ctype, known_types[i].type))
if (c_strcasecmp(ctype, known_types[i].type))
continue;
plaintext = known_types[i].plain;
@ -1326,7 +1326,7 @@ setup_download_handler(struct session *ses, struct download *loading,
xwin = ses->tab->term->environment & ENV_XWIN;
handler = get_mime_type_handler(ctype, xwin);
if (!handler && strlen(ctype) >= 4 && !strncasecmp(ctype, "text", 4))
if (!handler && strlen(ctype) >= 4 && !c_strncasecmp(ctype, "text", 4))
goto plaintext_follow;
type_query = find_type_query(ses);
@ -1339,8 +1339,8 @@ setup_download_handler(struct session *ses, struct download *loading,
#ifdef CONFIG_BITTORRENT
/* A terrible waste of a good MIME handler here, but we want
* to use the type_query this is easier. */
if ((!strcasecmp(ctype, "application/x-bittorrent")
|| !strcasecmp(ctype, "application/x-torrent"))
if ((!c_strcasecmp(ctype, "application/x-bittorrent")
|| !c_strcasecmp(ctype, "application/x-torrent"))
&& !get_cmd_opt_bool("anonymous"))
query_bittorrent_dialog(type_query);
else

View File

@ -341,7 +341,7 @@ request_frame(struct session *ses, unsigned char *name,
foreach (frame, loc->frames) {
struct document_view *doc_view;
if (strcasecmp(frame->name, name))
if (c_strcasecmp(frame->name, name))
continue;
foreach (doc_view, ses->scrn_frames) {
@ -1255,7 +1255,7 @@ ses_find_frame(struct session *ses, unsigned char *name)
if_assert_failed return NULL;
foreachback (frame, loc->frames)
if (!strcasecmp(frame->name, name))
if (!c_strcasecmp(frame->name, name))
return frame;
return NULL;

View File

@ -69,7 +69,7 @@ void
init_colors_lookup(void)
{
#ifdef USE_FASTFIND
fastfind_index(&ff_colors_index, FF_COMPRESS);
fastfind_index(&ff_colors_index, FF_COMPRESS | FF_LOCALE_INDEP);
#endif
}
@ -112,7 +112,7 @@ decode_hex_color:
#ifndef USE_FASTFIND
for (cs = color_specs; cs->name; cs++)
if (!strlcasecmp(cs->name, -1, str, slen))
if (!c_strlcasecmp(cs->name, -1, str, slen))
break;
#else
cs = fastfind_search(&ff_colors_index, str, slen);

View File

@ -411,7 +411,7 @@ strtolx(unsigned char *str, unsigned char **end)
if (errno) return 0;
if (!*end) return num;
postfix = toupper(**end);
postfix = c_toupper(**end);
if (postfix == 'K') {
(*end)++;
if (num < -INT_MAX / 1024) return -INT_MAX;
@ -534,3 +534,99 @@ sanitize_url(unsigned char *url)
return 1;
}
int c_tolower(int c) {
switch (c)
{
case 'A': return 'a';
case 'B': return 'b';
case 'C': return 'c';
case 'D': return 'd';
case 'E': return 'e';
case 'F': return 'f';
case 'G': return 'g';
case 'H': return 'h';
case 'I': return 'i';
case 'J': return 'j';
case 'K': return 'k';
case 'L': return 'l';
case 'M': return 'm';
case 'N': return 'n';
case 'O': return 'o';
case 'P': return 'p';
case 'Q': return 'q';
case 'R': return 'r';
case 'S': return 's';
case 'T': return 't';
case 'U': return 'u';
case 'V': return 'v';
case 'W': return 'w';
case 'X': return 'x';
case 'Y': return 'y';
case 'Z': return 'z';
default: return c;
}
}
int c_toupper(int c) {
switch (c) {
case 'a': return 'A';
case 'b': return 'B';
case 'c': return 'C';
case 'd': return 'D';
case 'e': return 'E';
case 'f': return 'F';
case 'g': return 'G';
case 'h': return 'H';
case 'i': return 'I';
case 'j': return 'J';
case 'k': return 'K';
case 'l': return 'L';
case 'm': return 'M';
case 'n': return 'N';
case 'o': return 'O';
case 'p': return 'P';
case 'q': return 'Q';
case 'r': return 'R';
case 's': return 'S';
case 't': return 'T';
case 'u': return 'U';
case 'v': return 'V';
case 'w': return 'W';
case 'x': return 'X';
case 'y': return 'Y';
case 'z': return 'Z';
default: return c;
}
}
int c_isupper (int c)
{
switch (c)
{
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
return 1;
default:
return 0;
}
}
int c_islower (int c)
{
switch (c)
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
return 1;
default:
return 0;
}
}

View File

@ -182,6 +182,16 @@ trim_chars(unsigned char *s, unsigned char c, int *len)
return s;
}
/* Convert a character to {lower|upper}case using the
* ASCII character set (as if in the C locale) */
int c_tolower(int c);
int c_toupper(int c);
/* Check whether a character is {lower|upper}case using the
* the ASCII character set (as if in the C locale) */
int c_islower(int c);
int c_isupper(int c);
/** Convert uppercase letters in @a string with the given @a length to
* lowercase. */
static inline void
@ -192,6 +202,16 @@ convert_to_lowercase(unsigned char *string, int length)
string[length] = tolower(string[length]);
}
/* Convert uppercase letters in @string with the given @length to lowercase
* using the ASCII character set (as if in the C locale) */
static inline void
convert_to_lowercase_locale_indep(unsigned char *string, int length)
{
for (length--; length >= 0; length--)
if (c_isupper(string[length]))
string[length] = c_tolower(string[length]);
}
/** This function drops control chars, nbsp char and limit the number
* of consecutive space chars to one. It modifies its argument. */
void clr_spaces(unsigned char *str);

View File

@ -169,6 +169,7 @@ struct fastfind_info {
int leafsets_count;
unsigned int case_aware:1;
unsigned int locale_indep:1;
unsigned int compress:1;
int idxtab[FF_MAX_CHARS];
@ -233,6 +234,7 @@ FF_DBG_dump_stats(struct fastfind_info *info)
fprintf(stderr, "------ FastFind Statistics ------\n");
fprintf(stderr, "Comment : %s\n", info->debug.comment);
fprintf(stderr, "Case-aware : %s\n", info->case_aware ? "yes" : "no");
fprintf(stderr, "Locale-indep: %s\n", info->locale_indep ? "yes" : "no");
fprintf(stderr, "Compress : %s\n", info->compress ? "yes" : "no");
fprintf(stderr, "Uniq_chars : %s\n", info->uniq_chars);
fprintf(stderr, "Uniq_chars #: %d/%d max.\n", info->uniq_chars_count, FF_MAX_CHARS);
@ -292,6 +294,7 @@ init_fastfind(struct fastfind_index *index, enum fastfind_flags flags)
info->min_key_len = FF_MAX_KEYLEN;
info->case_aware = !!(flags & FF_CASE_AWARE);
info->locale_indep = !!(flags & FF_LOCALE_INDEP);
info->compress = !!(flags & FF_COMPRESS);
FF_DBG_mem(info, sizeof(*info) - sizeof(info->debug));
@ -434,7 +437,7 @@ compress_tree(struct ff_node *leafset, struct fastfind_info *info)
}
}
#define ifcase(c) (info->case_aware ? (c) : toupper(c))
#define ifcase(c) ( info->case_aware ? (c) : (info->locale_indep ? c_toupper(c) : toupper(c)) )
struct fastfind_index *
fastfind_index(struct fastfind_index *index, enum fastfind_flags flags)
@ -622,7 +625,10 @@ fastfind_search(struct fastfind_index *index,
if (info->case_aware)
FF_SEARCH(key[i]);
else
FF_SEARCH(toupper(key[i]));
if (info->locale_indep)
FF_SEARCH(c_toupper(key[i]));
else
FF_SEARCH(toupper(key[i]));
return NULL;
}

View File

@ -19,6 +19,8 @@ enum fastfind_flags {
FF_NONE = 0,
FF_CASE_AWARE = 1, /**< honour case when comparing */
FF_COMPRESS = 2, /**< compress nodes if possible */
FF_LOCALE_INDEP = 4 /**< whether the case conversion is
* locale independent or not */
};
struct fastfind_index {

View File

@ -25,7 +25,7 @@ map_scanner_string(struct scanner *scanner,
for (; mappings->name; mappings++) {
if (mappings->base_type == base_type
&& !strlcasecmp(mappings->name, -1, ident, length))
&& !c_strlcasecmp(mappings->name, -1, ident, length))
return mappings->type;
}

View File

@ -2,6 +2,7 @@
#define EL__UTIL_SCANNER_H
#include "util/error.h"
#include "util/string.h"
/* Define if you want a talking scanner */
/* #define DEBUG_SCANNER */
@ -29,7 +30,7 @@ struct scanner_token {
/** Compare the string of @a token with @a str */
#define scanner_token_strlcasecmp(token, str, len) \
((token) && !strlcasecmp((token)->string, (token)->length, str, len))
((token) && !c_strlcasecmp((token)->string, (token)->length, str, len))
/** Also compares the token string but using a "static" string */
#define scanner_token_contains(token, str) \

View File

@ -14,6 +14,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "elinks.h"
@ -233,11 +234,110 @@ elinks_strlcmp(const unsigned char *s1, size_t n1,
int
elinks_strlcasecmp(const unsigned char *s1, size_t n1,
const unsigned char *s2, size_t n2)
const unsigned char *s2, size_t n2,
const int locale_indep)
{
strlcmp_device("strlcasecmp", s1, n1, s2, n2, toupper(s1[p]), toupper(s2[p]));
if (locale_indep) {
strlcmp_device("strlcasecmp", s1, n1, s2, n2, c_toupper(s1[p]), c_toupper(s2[p]));
}
else {
strlcmp_device("strlcasecmp", s1, n1, s2, n2, toupper(s1[p]), toupper(s2[p]));
}
}
/* c_strcasecmp
* Taken from GNU coreutils (version 6.9)
* File name: lib/c-strcasecmp.c
* Copyright (C) 1998-1999, 2005-2006 Free Software Foundation, Inc.
* Licensed under the GPL version 2 or any later version.
*/
int c_strcasecmp (const char *s1, const char *s2)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2)
return 0;
do
{
c1 = c_tolower (*p1);
c2 = c_tolower (*p2);
if (c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
}
/* c_strncasecmp
* Taken from GNU coreutils (version 6.9)
* File name: lib/c-strncasecmp.c
* ^ (note the "n")
* Copyright (C) 1998-1999, 2005-2006 Free Software Foundation, Inc.
* Licensed under the GPL version 2 or any later version.
*/
int c_strncasecmp (const char *s1, const char *s2, size_t n)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2 || n == 0)
return 0;
do
{
c1 = c_tolower (*p1);
c2 = c_tolower (*p2);
if (--n == 0 || c1 == '\0')
break;
++p1;
++p2;
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
}
/* c_strcasestr - adapted from src/osdep/stub.c */
char * c_strcasestr(const char *haystack, const char *needle)
{
size_t haystack_length = strlen(haystack);
size_t needle_length = strlen(needle);
int i;
if (haystack_length < needle_length)
return NULL;
for (i = haystack_length - needle_length + 1; i; i--) {
if (!c_strncasecmp(haystack, needle, needle_length))
return (char *) haystack;
haystack++;
}
return NULL;
}
/* The new string utilities: */

View File

@ -100,9 +100,19 @@ int elinks_strlcmp(const unsigned char *s1, size_t n1,
const unsigned char *s2, size_t n2);
/** Acts identically to strlcmp(), except for being case insensitive. */
#define strlcasecmp(a,b,c,d) (errfile = __FILE__, errline = __LINE__, elinks_strlcasecmp(a,b,c,d))
#define strlcasecmp(a,b,c,d) (errfile = __FILE__, errline = __LINE__, elinks_strlcasecmp(a,b,c,d,0))
#define c_strlcasecmp(a,b,c,d) (errfile = __FILE__, errline = __LINE__, elinks_strlcasecmp(a,b,c,d,1))
int elinks_strlcasecmp(const unsigned char *s1, size_t n1,
const unsigned char *s2, size_t n2);
const unsigned char *s2, size_t n2,
const int locale_indep);
/* strcasecmp and strncasecmp which work as if they are
* in the C locale - both taken from GNU coreutils */
int c_strcasecmp(const char *s1, const char *s2);
int c_strncasecmp(const char *s1, const char *s2, size_t n);
/* strcasestr function which works as if it is in the C locale. */
char * c_strcasestr(const char *haystack, const char *needle);
/** @} */