aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2011-11-11 04:26:41 +0000
committercorvid <corvid@lavabit.com>2011-11-11 04:26:41 +0000
commit980fe05f47b9d6dd8626b5ea021e2c16807ff5ca (patch)
tree2e5670d74d8fcfb8e7f6b84ffaf5f77b74855746 /src
parent119aa95ed6bc612dd4ef7a3121d9bf220148aaa4 (diff)
locale-independent ASCII character case handling
Basically, I and i are different letters in Turkic languages, and this causes problems for str(n)casecmp and toupper/tolower in these locales when dillo is dealing with ASCII.
Diffstat (limited to 'src')
-rw-r--r--src/IO/http.c4
-rw-r--r--src/IO/mime.c4
-rw-r--r--src/auth.c16
-rw-r--r--src/cache.c19
-rw-r--r--src/capi.c19
-rw-r--r--src/colors.c2
-rw-r--r--src/cookies.c12
-rw-r--r--src/css.cc6
-rw-r--r--src/cssparser.cc58
-rw-r--r--src/decode.c29
-rw-r--r--src/form.cc46
-rw-r--r--src/html.cc79
-rw-r--r--src/keys.cc6
-rw-r--r--src/misc.c41
-rw-r--r--src/prefsparser.cc12
-rw-r--r--src/table.cc6
-rw-r--r--src/uicmd.cc2
-rw-r--r--src/url.c9
-rw-r--r--src/web.cc2
19 files changed, 189 insertions, 183 deletions
diff --git a/src/IO/http.c b/src/IO/http.c
index 0c34a6b6..3e87f912 100644
--- a/src/IO/http.c
+++ b/src/IO/http.c
@@ -480,7 +480,7 @@ static int Http_must_use_proxy(const DilloUrl *url)
for (p = np; (tok = dStrsep(&p, " ")); ) {
int start = host_len - strlen(tok);
- if (start >= 0 && dStrcasecmp(host + start, tok) == 0) {
+ if (start >= 0 && dStrAsciiCasecmp(host + start, tok) == 0) {
/* no_proxy token is suffix of host string */
ret = 0;
break;
@@ -719,7 +719,7 @@ static HostConnection_t *Http_host_connection_get(const char *host)
for (i = 0; i < dList_length(host_connections); i++) {
hc = (HostConnection_t*) dList_nth_data(host_connections, i);
- if (dStrcasecmp(host, hc->host) == 0)
+ if (dStrAsciiCasecmp(host, hc->host) == 0)
return hc;
}
diff --git a/src/IO/mime.c b/src/IO/mime.c
index 19dc601a..3606d23c 100644
--- a/src/IO/mime.c
+++ b/src/IO/mime.c
@@ -67,7 +67,7 @@ static Viewer_t Mime_minor_type_fetch(const char *Key, uint_t Size)
if (Size) {
for ( i = 0; i < MimeMinItemsSize; ++i )
- if (dStrncasecmp(Key, MimeMinItems[i].Name, Size) == 0)
+ if (dStrnAsciiCasecmp(Key, MimeMinItems[i].Name, Size) == 0)
return MimeMinItems[i].Data;
}
return NULL;
@@ -83,7 +83,7 @@ static Viewer_t Mime_major_type_fetch(const char *Key, uint_t Size)
if (Size) {
for ( i = 0; i < MimeMajItemsSize; ++i )
- if (dStrncasecmp(Key, MimeMajItems[i].Name, Size) == 0)
+ if (dStrnAsciiCasecmp(Key, MimeMajItems[i].Name, Size) == 0)
return MimeMajItems[i].Data;
}
return NULL;
diff --git a/src/auth.c b/src/auth.c
index 0148521b..d6ca8504 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -228,7 +228,7 @@ static int Auth_parse_token_value(AuthParse_t *auth_parse, char **auth,
static int Auth_parse_basic_challenge_cb(AuthParse_t *auth_parse, char *token,
const char *value)
{
- if (dStrcasecmp("realm", token) == 0) {
+ if (dStrAsciiCasecmp("realm", token) == 0) {
if (!auth_parse->realm)
auth_parse->realm = strdup(value);
return 0; /* end parsing */
@@ -243,7 +243,7 @@ static int Auth_parse_digest_challenge_cb(AuthParse_t *auth_parse, char *token,
{
const char *const fn = "Auth_parse_digest_challenge_cb";
- if (!dStrcasecmp("realm", token) && !auth_parse->realm)
+ if (!dStrAsciiCasecmp("realm", token) && !auth_parse->realm)
auth_parse->realm = strdup(value);
else if (!strcmp("domain", token) && !auth_parse->domain)
auth_parse->domain = strdup(value);
@@ -252,9 +252,9 @@ static int Auth_parse_digest_challenge_cb(AuthParse_t *auth_parse, char *token,
else if (!strcmp("opaque", token) && !auth_parse->opaque)
auth_parse->opaque = strdup(value);
else if (strcmp("stale", token) == 0) {
- if (dStrcasecmp("true", value) == 0)
+ if (dStrAsciiCasecmp("true", value) == 0)
auth_parse->stale = 1;
- else if (dStrcasecmp("false", value) == 0)
+ else if (dStrAsciiCasecmp("false", value) == 0)
auth_parse->stale = 0;
else {
MSG("%s: Invalid stale value: %s\n", fn, value);
@@ -359,8 +359,8 @@ static AuthHost_t *Auth_host_by_url(const DilloUrl *url)
int i;
for (i = 0; (host = dList_nth_data(auth_hosts, i)); i++)
- if (((dStrcasecmp(URL_SCHEME(url), host->scheme) == 0) &&
- (dStrcasecmp(URL_AUTHORITY(url), host->authority) == 0)))
+ if (((dStrAsciiCasecmp(URL_SCHEME(url), host->scheme) == 0) &&
+ (dStrAsciiCasecmp(URL_AUTHORITY(url), host->authority) == 0)))
return host;
return NULL;
@@ -672,11 +672,11 @@ int a_Auth_do_auth(Dlist *challenges, const DilloUrl *url)
char *chal;
for (i = 0; (chal = dList_nth_data(challenges, i)); ++i)
- if (!dStrncasecmp(chal, "Digest ", 7))
+ if (!dStrnAsciiCasecmp(chal, "Digest ", 7))
if (Auth_do_auth(chal, DIGEST, url))
return 1;
for (i = 0; (chal = dList_nth_data(challenges, i)); ++i)
- if (!dStrncasecmp(chal, "Basic ", 6))
+ if (!dStrnAsciiCasecmp(chal, "Basic ", 6))
if (Auth_do_auth(chal, BASIC, url))
return 1;
diff --git a/src/cache.c b/src/cache.c
index 15869ac6..11c7faf3 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -13,7 +13,6 @@
* Dillo's cache module
*/
-#include <ctype.h> /* for tolower */
#include <sys/types.h>
#include <stdlib.h>
@@ -521,7 +520,7 @@ const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
/* META only gives charset; use detected MIME type too */
entry->TypeNorm = dStrconcat(entry->TypeDet, ctype, NULL);
} else if (*from == 'm' &&
- !dStrncasecmp(ctype, "text/xhtml", 10)) {
+ !dStrnAsciiCasecmp(ctype, "text/xhtml", 10)) {
/* WORKAROUND: doxygen uses "text/xhtml" in META */
entry->TypeNorm = dStrdup(entry->TypeDet);
}
@@ -584,7 +583,7 @@ static char *Cache_parse_field(const char *header, const char *fieldname)
for (i = 0; header[i]; i++) {
/* Search fieldname */
for (j = 0; fieldname[j]; j++)
- if (tolower(fieldname[j]) != tolower(header[i + j]))
+ if (D_ASCII_TOLOWER(fieldname[j]) != D_ASCII_TOLOWER(header[i + j]))
break;
if (fieldname[j]) {
/* skip to next line */
@@ -620,7 +619,7 @@ static Dlist *Cache_parse_multiple_fields(const char *header,
for (i = 0; header[i]; i++) {
/* Search fieldname */
for (j = 0; fieldname[j]; j++)
- if (tolower(fieldname[j]) != tolower(header[i + j]))
+ if (D_ASCII_TOLOWER(fieldname[j]) != D_ASCII_TOLOWER(header[i + j]))
break;
if (fieldname[j]) {
/* skip to next line */
@@ -694,8 +693,8 @@ static void Cache_parse_header(CacheEntry_t *entry)
entry->Flags |= CA_TempRedirect; /* 302 Temporary Redirect */
if (URL_FLAGS(location_url) & (URL_Post + URL_Get) &&
- dStrcasecmp(URL_SCHEME(location_url), "dpi") == 0 &&
- dStrcasecmp(URL_SCHEME(entry->Url), "dpi") != 0) {
+ dStrAsciiCasecmp(URL_SCHEME(location_url), "dpi") == 0 &&
+ dStrAsciiCasecmp(URL_SCHEME(entry->Url), "dpi") != 0) {
/* Forbid dpi GET and POST from non dpi-generated urls */
MSG("Redirection Denied! '%s' -> '%s'\n",
URL_STR(entry->Url), URL_STR(location_url));
@@ -734,7 +733,7 @@ static void Cache_parse_header(CacheEntry_t *entry)
* If Transfer-Encoding is present, Content-Length must be ignored.
* If the Transfer-Encoding is non-identity, it is an error.
*/
- if (dStrcasecmp(encoding, "identity"))
+ if (dStrAsciiCasecmp(encoding, "identity"))
MSG_HTTP("Content-Length and non-identity Transfer-Encoding "
"headers both present.\n");
} else {
@@ -1045,9 +1044,9 @@ static void Cache_auth_entry(CacheEntry_t *entry, BrowserWindow *bw)
*/
int a_Cache_download_enabled(const DilloUrl *url)
{
- if (!dStrcasecmp(URL_SCHEME(url), "http") ||
- !dStrcasecmp(URL_SCHEME(url), "https") ||
- !dStrcasecmp(URL_SCHEME(url), "ftp"))
+ if (!dStrAsciiCasecmp(URL_SCHEME(url), "http") ||
+ !dStrAsciiCasecmp(URL_SCHEME(url), "https") ||
+ !dStrAsciiCasecmp(URL_SCHEME(url), "ftp"))
return 1;
return 0;
}
diff --git a/src/capi.c b/src/capi.c
index c3812acc..281eb6f3 100644
--- a/src/capi.c
+++ b/src/capi.c
@@ -229,7 +229,7 @@ int a_Capi_dpi_verify_request(BrowserWindow *bw, DilloUrl *url)
const DilloUrl *referer;
int allow = FALSE;
- if (dStrcasecmp(URL_SCHEME(url), "dpi") == 0) {
+ if (dStrAsciiCasecmp(URL_SCHEME(url), "dpi") == 0) {
if (!(URL_FLAGS(url) & (URL_Post + URL_Get))) {
allow = TRUE;
} else if (!(URL_FLAGS(url) & URL_Post) &&
@@ -239,7 +239,7 @@ int a_Capi_dpi_verify_request(BrowserWindow *bw, DilloUrl *url)
/* only allow GET&POST dpi-requests from dpi-generated urls */
if (a_Nav_stack_size(bw)) {
referer = a_History_get_url(NAV_TOP_UIDX(bw));
- if (dStrcasecmp(URL_SCHEME(referer), "dpi") == 0) {
+ if (dStrAsciiCasecmp(URL_SCHEME(referer), "dpi") == 0) {
allow = TRUE;
}
}
@@ -266,10 +266,10 @@ static int Capi_url_uses_dpi(DilloUrl *url, char **server_ptr)
char *p, *server = NULL, *url_str = URL_STR(url);
Dstr *tmp;
- if ((dStrncasecmp(url_str, "http:", 5) == 0) ||
- (dStrncasecmp(url_str, "about:", 6) == 0)) {
+ if ((dStrnAsciiCasecmp(url_str, "http:", 5) == 0) ||
+ (dStrnAsciiCasecmp(url_str, "about:", 6) == 0)) {
/* URL doesn't use dpi (server = NULL) */
- } else if (dStrncasecmp(url_str, "dpi:/", 5) == 0) {
+ } else if (dStrnAsciiCasecmp(url_str, "dpi:/", 5) == 0) {
/* dpi prefix, get this server's name */
if ((p = strchr(url_str + 5, '/')) != NULL) {
server = dStrndup(url_str + 5, (uint_t)(p - url_str - 5));
@@ -388,7 +388,8 @@ static bool_t Capi_filters_test(const DilloUrl *wanted,
*want_host = URL_HOST(wanted);
if (want_host[0] == '\0') {
ret = (req_host[0] == '\0' ||
- !dStrcasecmp(URL_SCHEME(wanted), "data")) ? TRUE : FALSE;
+ !dStrAsciiCasecmp(URL_SCHEME(wanted), "data"))
+ ? TRUE : FALSE;
} else {
/* This will regard "www.dillo.org" and "www.dillo.org." as
* different, but it doesn't seem worth caring about.
@@ -454,7 +455,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
} else if (Capi_url_uses_dpi(web->url, &server)) {
/* dpi request */
if ((safe = a_Capi_dpi_verify_request(web->bw, web->url))) {
- if (dStrcasecmp(scheme, "dpi") == 0) {
+ if (dStrAsciiCasecmp(scheme, "dpi") == 0) {
if (strcmp(server, "vsource") == 0) {
/* allow "view source" reload upon user request */
} else {
@@ -478,7 +479,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
}
dFree(server);
- } else if (!dStrcasecmp(scheme, "http")) {
+ } else if (!dStrAsciiCasecmp(scheme, "http")) {
/* http request */
if (reload) {
a_Capi_conn_abort_by_url(web->url);
@@ -491,7 +492,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
}
use_cache = 1;
- } else if (!dStrcasecmp(scheme, "about")) {
+ } else if (!dStrAsciiCasecmp(scheme, "about")) {
/* internal request */
use_cache = 1;
}
diff --git a/src/colors.c b/src/colors.c
index 5b647bb2..5d929a88 100644
--- a/src/colors.c
+++ b/src/colors.c
@@ -262,7 +262,7 @@ int32_t a_Color_parse (const char *subtag, int32_t default_color, int *err)
high = NCOLORS - 1;
while (low <= high) {
mid = (low + high) / 2;
- if ((ret = dStrcasecmp(cp, color_keyword[mid].key)) < 0)
+ if ((ret = dStrAsciiCasecmp(cp, color_keyword[mid].key)) < 0)
high = mid - 1;
else if (ret > 0)
low = mid + 1;
diff --git a/src/cookies.c b/src/cookies.c
index eadd0322..0a1e94ff 100644
--- a/src/cookies.c
+++ b/src/cookies.c
@@ -284,11 +284,11 @@ static int Cookie_control_init(void)
rule[j++] = line[i++];
rule[j] = '\0';
- if (dStrcasecmp(rule, "ACCEPT") == 0)
+ if (dStrAsciiCasecmp(rule, "ACCEPT") == 0)
cc.action = COOKIE_ACCEPT;
- else if (dStrcasecmp(rule, "ACCEPT_SESSION") == 0)
+ else if (dStrAsciiCasecmp(rule, "ACCEPT_SESSION") == 0)
cc.action = COOKIE_ACCEPT_SESSION;
- else if (dStrcasecmp(rule, "DENY") == 0)
+ else if (dStrAsciiCasecmp(rule, "DENY") == 0)
cc.action = COOKIE_DENY;
else {
MSG("Cookies: rule '%s' for domain '%s' is not recognised.\n",
@@ -297,7 +297,7 @@ static int Cookie_control_init(void)
}
cc.domain = dStrdup(domain);
- if (dStrcasecmp(cc.domain, "DEFAULT") == 0) {
+ if (dStrAsciiCasecmp(cc.domain, "DEFAULT") == 0) {
/* Set the default action */
default_action = cc.action;
dFree(cc.domain);
@@ -338,13 +338,13 @@ static CookieControlAction Cookies_control_check_domain(const char *domain)
if (ccontrol[i].domain[0] == '.') {
diff = strlen(domain) - strlen(ccontrol[i].domain);
if (diff >= 0) {
- if (dStrcasecmp(domain + diff, ccontrol[i].domain) != 0)
+ if (dStrAsciiCasecmp(domain + diff, ccontrol[i].domain) != 0)
continue;
} else {
continue;
}
} else {
- if (dStrcasecmp(domain, ccontrol[i].domain) != 0)
+ if (dStrAsciiCasecmp(domain, ccontrol[i].domain) != 0)
continue;
}
diff --git a/src/css.cc b/src/css.cc
index d0bd8d95..1e703f2e 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -265,16 +265,16 @@ bool CssSimpleSelector::match (const DoctreeNode *n) {
if (element != ELEMENT_ANY && element != n->element)
return false;
if (pseudo != NULL &&
- (n->pseudo == NULL || dStrcasecmp (pseudo, n->pseudo) != 0))
+ (n->pseudo == NULL || dStrAsciiCasecmp (pseudo, n->pseudo) != 0))
return false;
- if (id != NULL && (n->id == NULL || dStrcasecmp (id, n->id) != 0))
+ if (id != NULL && (n->id == NULL || dStrAsciiCasecmp (id, n->id) != 0))
return false;
if (klass != NULL) {
for (int i = 0; i < klass->size (); i++) {
bool found = false;
if (n->klass != NULL) {
for (int j = 0; j < n->klass->size (); j++) {
- if (dStrcasecmp (klass->get(i), n->klass->get(j)) == 0) {
+ if (dStrAsciiCasecmp (klass->get(i), n->klass->get(j)) == 0) {
found = true;
break;
}
diff --git a/src/cssparser.cc b/src/cssparser.cc
index e58a52e1..6d5b3768 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -674,7 +674,7 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType *type)
case CSS_TYPE_ENUM:
if (ttype == CSS_TK_SYMBOL) {
for (i = 0; Css_property_info[prop].enum_symbols[i]; i++)
- if (dStrcasecmp(tval,
+ if (dStrAsciiCasecmp(tval,
Css_property_info[prop].enum_symbols[i]) == 0)
return true;
}
@@ -682,11 +682,11 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType *type)
case CSS_TYPE_MULTI_ENUM:
if (ttype == CSS_TK_SYMBOL) {
- if (dStrcasecmp(tval, "none") == 0) {
+ if (dStrAsciiCasecmp(tval, "none") == 0) {
return true;
} else {
for (i = 0; Css_property_info[prop].enum_symbols[i]; i++) {
- if (dStrcasecmp(tval,
+ if (dStrAsciiCasecmp(tval,
Css_property_info[prop].enum_symbols[i]) == 0)
return true;
}
@@ -703,14 +703,14 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType *type)
case CSS_TYPE_SIGNED_LENGTH:
if (ttype == CSS_TK_DECINT ||
ttype == CSS_TK_FLOAT ||
- (ttype == CSS_TK_SYMBOL && dStrcasecmp(tval, "auto") == 0))
+ (ttype == CSS_TK_SYMBOL && dStrAsciiCasecmp(tval, "auto") == 0))
return true;
break;
case CSS_TYPE_COLOR:
if ((ttype == CSS_TK_COLOR ||
ttype == CSS_TK_SYMBOL) &&
- (dStrcasecmp(tval, "rgb") == 0 ||
+ (dStrAsciiCasecmp(tval, "rgb") == 0 ||
a_Color_parse(tval, -1, &err) != -1))
return true;
break;
@@ -838,7 +838,7 @@ bool CssParser::parseValue(CssPropertyName prop,
case CSS_TYPE_ENUM:
if (ttype == CSS_TK_SYMBOL) {
for (i = 0; Css_property_info[prop].enum_symbols[i]; i++)
- if (dStrcasecmp(tval,
+ if (dStrAsciiCasecmp(tval,
Css_property_info[prop].enum_symbols[i]) == 0) {
val->intVal = i;
ret = true;
@@ -853,10 +853,10 @@ bool CssParser::parseValue(CssPropertyName prop,
ret = true;
while (ttype == CSS_TK_SYMBOL) {
- if (dStrcasecmp(tval, "none") != 0) {
+ if (dStrAsciiCasecmp(tval, "none") != 0) {
for (i = 0, found = false;
!found && Css_property_info[prop].enum_symbols[i]; i++) {
- if (dStrcasecmp(tval,
+ if (dStrAsciiCasecmp(tval,
Css_property_info[prop].enum_symbols[i]) == 0)
val->intVal |= (1 << i);
}
@@ -877,32 +877,32 @@ bool CssParser::parseValue(CssPropertyName prop,
if (!spaceSeparated && ttype == CSS_TK_SYMBOL) {
ret = true;
- if (dStrcasecmp(tval, "px") == 0) {
+ if (dStrAsciiCasecmp(tval, "px") == 0) {
lentype = CSS_LENGTH_TYPE_PX;
nextToken();
- } else if (dStrcasecmp(tval, "mm") == 0) {
+ } else if (dStrAsciiCasecmp(tval, "mm") == 0) {
lentype = CSS_LENGTH_TYPE_MM;
nextToken();
- } else if (dStrcasecmp(tval, "cm") == 0) {
+ } else if (dStrAsciiCasecmp(tval, "cm") == 0) {
lentype = CSS_LENGTH_TYPE_MM;
fval *= 10;
nextToken();
- } else if (dStrcasecmp(tval, "in") == 0) {
+ } else if (dStrAsciiCasecmp(tval, "in") == 0) {
lentype = CSS_LENGTH_TYPE_MM;
fval *= 25.4;
nextToken();
- } else if (dStrcasecmp(tval, "pt") == 0) {
+ } else if (dStrAsciiCasecmp(tval, "pt") == 0) {
lentype = CSS_LENGTH_TYPE_MM;
fval *= (25.4 / 72);
nextToken();
- } else if (dStrcasecmp(tval, "pc") == 0) {
+ } else if (dStrAsciiCasecmp(tval, "pc") == 0) {
lentype = CSS_LENGTH_TYPE_MM;
fval *= (25.4 / 6);
nextToken();
- } else if (dStrcasecmp(tval, "em") == 0) {
+ } else if (dStrAsciiCasecmp(tval, "em") == 0) {
lentype = CSS_LENGTH_TYPE_EM;
nextToken();
- } else if (dStrcasecmp(tval, "ex") == 0) {
+ } else if (dStrAsciiCasecmp(tval, "ex") == 0) {
lentype = CSS_LENGTH_TYPE_EX;
nextToken();
} else {
@@ -927,7 +927,7 @@ bool CssParser::parseValue(CssPropertyName prop,
ret = true;
val->intVal = CSS_CREATE_LENGTH(fval, lentype);
- } else if (ttype == CSS_TK_SYMBOL && dStrcasecmp(tval, "auto") == 0) {
+ } else if (ttype == CSS_TK_SYMBOL && !dStrAsciiCasecmp(tval, "auto")) {
ret = true;
val->intVal = CSS_LENGTH_TYPE_AUTO;
nextToken();
@@ -943,7 +943,7 @@ bool CssParser::parseValue(CssPropertyName prop,
ret = true;
nextToken();
} else if (ttype == CSS_TK_SYMBOL) {
- if (dStrcasecmp(tval, "rgb") == 0) {
+ if (dStrAsciiCasecmp(tval, "rgb") == 0) {
nextToken();
if (parseRgbColor(&val->intVal))
ret = true;
@@ -1022,7 +1022,7 @@ bool CssParser::parseWeight()
if (ttype == CSS_TK_CHAR && tval[0] == '!') {
nextToken();
if (ttype == CSS_TK_SYMBOL &&
- dStrcasecmp(tval, "important") == 0) {
+ dStrAsciiCasecmp(tval, "important") == 0) {
nextToken();
return true;
}
@@ -1036,7 +1036,7 @@ bool CssParser::parseWeight()
*/
static int Css_property_info_cmp(const void *a, const void *b)
{
- return dStrcasecmp(((CssPropertyInfo *) a)->symbol,
+ return dStrAsciiCasecmp(((CssPropertyInfo *) a)->symbol,
((CssPropertyInfo *) b)->symbol);
}
@@ -1046,7 +1046,7 @@ static int Css_property_info_cmp(const void *a, const void *b)
*/
static int Css_shorthand_info_cmp(const void *a, const void *b)
{
- return dStrcasecmp(((CssShorthandInfo *) a)->symbol,
+ return dStrAsciiCasecmp(((CssShorthandInfo *) a)->symbol,
((CssShorthandInfo *) b)->symbol);
}
@@ -1391,7 +1391,7 @@ char * CssParser::parseUrl()
Dstr *urlStr = NULL;
if (ttype != CSS_TK_SYMBOL ||
- dStrcasecmp(tval, "url") != 0)
+ dStrAsciiCasecmp(tval, "url") != 0)
return NULL;
nextToken();
@@ -1437,7 +1437,7 @@ void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl)
nextToken();
if (ttype == CSS_TK_SYMBOL &&
- dStrcasecmp(tval, "url") == 0)
+ dStrAsciiCasecmp(tval, "url") == 0)
urlStr = parseUrl();
else if (ttype == CSS_TK_STRING)
urlStr = dStrdup (tval);
@@ -1449,8 +1449,8 @@ void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl)
mediaSyntaxIsOK = false;
mediaIsSelected = false;
while (ttype == CSS_TK_SYMBOL) {
- if (dStrcasecmp(tval, "all") == 0 ||
- dStrcasecmp(tval, "screen") == 0)
+ if (dStrAsciiCasecmp(tval, "all") == 0 ||
+ dStrAsciiCasecmp(tval, "screen") == 0)
mediaIsSelected = true;
nextToken();
if (ttype == CSS_TK_CHAR && tval[0] == ',') {
@@ -1491,8 +1491,8 @@ void CssParser::parseMedia()
/* parse a comma-separated list of media */
while (ttype == CSS_TK_SYMBOL) {
- if (dStrcasecmp(tval, "all") == 0 ||
- dStrcasecmp(tval, "screen") == 0)
+ if (dStrAsciiCasecmp(tval, "all") == 0 ||
+ dStrAsciiCasecmp(tval, "screen") == 0)
mediaIsSelected = true;
nextToken();
if (ttype == CSS_TK_CHAR && tval[0] == ',') {
@@ -1578,11 +1578,11 @@ void CssParser::parse(DilloHtml *html, DilloUrl *url, CssContext * context,
parser.tval[0] == '@') {
parser.nextToken();
if (parser.ttype == CSS_TK_SYMBOL) {
- if (dStrcasecmp(parser.tval, "import") == 0 &&
+ if (dStrAsciiCasecmp(parser.tval, "import") == 0 &&
html != NULL &&
importsAreAllowed) {
parser.parseImport(html, url);
- } else if (dStrcasecmp(parser.tval, "media") == 0) {
+ } else if (dStrAsciiCasecmp(parser.tval, "media") == 0) {
parser.parseMedia();
} else {
parser.ignoreStatement();
diff --git a/src/decode.c b/src/decode.c
index 24067318..7ea3dc25 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -190,7 +190,7 @@ Decode *a_Decode_transfer_init(const char *format)
{
Decode *dc = NULL;
- if (format && !dStrcasecmp(format, "chunked")) {
+ if (format && !dStrAsciiCasecmp(format, "chunked")) {
int *chunk_remaining = dNew(int, 1);
*chunk_remaining = 0;
dc = dNew(Decode, 1);
@@ -215,7 +215,8 @@ Decode *a_Decode_content_init(const char *format)
Decode *dc = NULL;
if (format && *format) {
- if (!dStrcasecmp(format, "gzip") || !dStrcasecmp(format, "x-gzip")) {
+ if (!dStrAsciiCasecmp(format, "gzip") ||
+ !dStrAsciiCasecmp(format, "x-gzip")) {
z_stream *zs;
_MSG("gzipped data!\n");
@@ -245,17 +246,17 @@ Decode *a_Decode_content_init(const char *format)
*/
static int Decode_is_ascii(const char *str)
{
- return (!(dStrcasecmp(str, "ASCII") &&
- dStrcasecmp(str, "US-ASCII") &&
- dStrcasecmp(str, "us") &&
- dStrcasecmp(str, "IBM367") &&
- dStrcasecmp(str, "cp367") &&
- dStrcasecmp(str, "csASCII") &&
- dStrcasecmp(str, "ANSI_X3.4-1968") &&
- dStrcasecmp(str, "iso-ir-6") &&
- dStrcasecmp(str, "ANSI_X3.4-1986") &&
- dStrcasecmp(str, "ISO_646.irv:1991") &&
- dStrcasecmp(str, "ISO646-US")));
+ return (!(dStrAsciiCasecmp(str, "ASCII") &&
+ dStrAsciiCasecmp(str, "US-ASCII") &&
+ dStrAsciiCasecmp(str, "us") &&
+ dStrAsciiCasecmp(str, "IBM367") &&
+ dStrAsciiCasecmp(str, "cp367") &&
+ dStrAsciiCasecmp(str, "csASCII") &&
+ dStrAsciiCasecmp(str, "ANSI_X3.4-1968") &&
+ dStrAsciiCasecmp(str, "iso-ir-6") &&
+ dStrAsciiCasecmp(str, "ANSI_X3.4-1986") &&
+ dStrAsciiCasecmp(str, "ISO_646.irv:1991") &&
+ dStrAsciiCasecmp(str, "ISO646-US")));
}
/*
@@ -271,7 +272,7 @@ Decode *a_Decode_charset_init(const char *format)
if (format &&
strlen(format) &&
- dStrcasecmp(format,"UTF-8") &&
+ dStrAsciiCasecmp(format,"UTF-8") &&
!Decode_is_ascii(format)) {
iconv_t ic = iconv_open("UTF-8", format);
diff --git a/src/form.cc b/src/form.cc
index a69129b1..8781d815 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -271,7 +271,7 @@ static DilloHtmlInput *Html_get_radio_input(DilloHtml *html, const char *name)
for (int idx = 0; idx < inputs->size(); idx++) {
DilloHtmlInput *input = inputs->get(idx);
if (input->type == DILLO_HTML_INPUT_RADIO &&
- input->name && !dStrcasecmp(input->name, name))
+ input->name && !dStrAsciiCasecmp(input->name, name))
return input;
}
}
@@ -318,9 +318,9 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize)
method = DILLO_HTML_METHOD_GET;
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "method"))) {
- if (!dStrcasecmp(attrbuf, "post")) {
+ if (!dStrAsciiCasecmp(attrbuf, "post")) {
method = DILLO_HTML_METHOD_POST;
- } else if (dStrcasecmp(attrbuf, "get")) {
+ } else if (dStrAsciiCasecmp(attrbuf, "get")) {
BUG_MSG("Unknown form submission method \"%s\"\n", attrbuf);
}
}
@@ -333,7 +333,7 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize)
content_type = DILLO_HTML_ENC_URLENCODED;
if ((method == DILLO_HTML_METHOD_POST) &&
((attrbuf = a_Html_get_attr(html, tag, tagsize, "enctype")))) {
- if (!dStrcasecmp(attrbuf, "multipart/form-data"))
+ if (!dStrAsciiCasecmp(attrbuf, "multipart/form-data"))
content_type = DILLO_HTML_ENC_MULTIPART;
}
charset = NULL;
@@ -343,9 +343,9 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize)
char *ptr = first = dStrdup(attrbuf);
while (ptr && !charset) {
char *curr = dStrsep(&ptr, " ,");
- if (!dStrcasecmp(curr, "utf-8")) {
+ if (!dStrAsciiCasecmp(curr, "utf-8")) {
charset = curr;
- } else if (!dStrcasecmp(curr, "UNKNOWN")) {
+ } else if (!dStrAsciiCasecmp(curr, "UNKNOWN")) {
/* defined to be whatever encoding the document is in */
charset = html->charset;
}
@@ -441,18 +441,18 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize)
init_str = NULL;
inp_type = DILLO_HTML_INPUT_UNKNOWN;
- if (!dStrcasecmp(type, "password")) {
+ if (!dStrAsciiCasecmp(type, "password")) {
inp_type = DILLO_HTML_INPUT_PASSWORD;
attrbuf = a_Html_get_attr(html, tag, tagsize, "size");
int size = Html_input_get_size(html, attrbuf);
resource = factory->createEntryResource (size, true, NULL);
init_str = value;
- } else if (!dStrcasecmp(type, "checkbox")) {
+ } else if (!dStrAsciiCasecmp(type, "checkbox")) {
inp_type = DILLO_HTML_INPUT_CHECKBOX;
resource = factory->createCheckButtonResource(false);
init_val = (a_Html_get_attr(html, tag, tagsize, "checked") != NULL);
init_str = (value) ? value : dStrdup("on");
- } else if (!dStrcasecmp(type, "radio")) {
+ } else if (!dStrAsciiCasecmp(type, "radio")) {
inp_type = DILLO_HTML_INPUT_RADIO;
RadioButtonResource *rb_r = NULL;
DilloHtmlInput *input = Html_get_radio_input(html, name);
@@ -461,22 +461,22 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize)
resource = factory->createRadioButtonResource(rb_r, false);
init_val = (a_Html_get_attr(html, tag, tagsize, "checked") != NULL);
init_str = value;
- } else if (!dStrcasecmp(type, "hidden")) {
+ } else if (!dStrAsciiCasecmp(type, "hidden")) {
inp_type = DILLO_HTML_INPUT_HIDDEN;
init_str = value;
int size = Html_input_get_size(html, NULL);
resource = factory->createEntryResource(size, false, name);
- } else if (!dStrcasecmp(type, "submit")) {
+ } else if (!dStrAsciiCasecmp(type, "submit")) {
inp_type = DILLO_HTML_INPUT_SUBMIT;
init_str = (value) ? value : dStrdup("submit");
resource = factory->createLabelButtonResource(init_str);
// gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */
- } else if (!dStrcasecmp(type, "reset")) {
+ } else if (!dStrAsciiCasecmp(type, "reset")) {
inp_type = DILLO_HTML_INPUT_RESET;
init_str = (value) ? value : dStrdup("Reset");
resource = factory->createLabelButtonResource(init_str);
// gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */
- } else if (!dStrcasecmp(type, "image")) {
+ } else if (!dStrAsciiCasecmp(type, "image")) {
if (URL_FLAGS(html->base_url) & URL_SpamSafe) {
/* Don't request the image; make a text submit button instead */
inp_type = DILLO_HTML_INPUT_SUBMIT;
@@ -491,7 +491,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize)
embed = Html_input_image(html, tag, tagsize);
init_str = value;
}
- } else if (!dStrcasecmp(type, "file")) {
+ } else if (!dStrAsciiCasecmp(type, "file")) {
bool valid = true;
if (html->InFlags & IN_FORM) {
DilloHtmlForm *form = html->getCurrentForm();
@@ -512,7 +512,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize)
init_str = dStrdup("File selector");
resource = factory->createLabelButtonResource(init_str);
}
- } else if (!dStrcasecmp(type, "button")) {
+ } else if (!dStrAsciiCasecmp(type, "button")) {
inp_type = DILLO_HTML_INPUT_BUTTON;
if (value) {
init_str = value;
@@ -521,7 +521,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize)
} else {
/* Text input, which also is the default */
inp_type = DILLO_HTML_INPUT_TEXT;
- if (*type && dStrcasecmp(type, "text"))
+ if (*type && dStrAsciiCasecmp(type, "text"))
BUG_MSG("Unknown input type: \"%s\"\n", type);
attrbuf = a_Html_get_attr(html, tag, tagsize, "size");
int size = Html_input_get_size(html, attrbuf);
@@ -831,11 +831,11 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize)
type = a_Html_get_attr_wdef(html, tag, tagsize, "type", "");
- if (!dStrcasecmp(type, "button")) {
+ if (!dStrAsciiCasecmp(type, "button")) {
inp_type = DILLO_HTML_INPUT_BUTTON;
- } else if (!dStrcasecmp(type, "reset")) {
+ } else if (!dStrAsciiCasecmp(type, "reset")) {
inp_type = DILLO_HTML_INPUT_BUTTON_RESET;
- } else if (!dStrcasecmp(type, "submit") || !*type) {
+ } else if (!dStrAsciiCasecmp(type, "submit") || !*type) {
/* submit button is the default */
inp_type = DILLO_HTML_INPUT_BUTTON_SUBMIT;
} else {
@@ -1034,7 +1034,7 @@ Dstr *DilloHtmlForm::buildQueryData(DilloHtmlInput *active_submit)
char *boundary = NULL;
iconv_t char_encoder = (iconv_t) -1;
- if (submit_charset && dStrcasecmp(submit_charset, "UTF-8")) {
+ if (submit_charset && dStrAsciiCasecmp(submit_charset, "UTF-8")) {
char_encoder = iconv_open(submit_charset, "UTF-8");
if (char_encoder == (iconv_t) -1) {
MSG_WARN("Cannot convert to character encoding '%s'\n",
@@ -1308,8 +1308,8 @@ void DilloHtmlForm::filesInputMultipartAppend(Dstr* data,
(void)a_Misc_get_content_type_from_data(file->str, file->len, &ctype);
/* Heuristic: text/plain with ".htm[l]" extension -> text/html */
if ((ext = strrchr(filename, '.')) &&
- !dStrcasecmp(ctype, "text/plain") &&
- (!dStrcasecmp(ext, ".html") || !dStrcasecmp(ext, ".htm"))) {
+ !dStrAsciiCasecmp(ctype, "text/plain") &&
+ (!dStrAsciiCasecmp(ext, ".html") || !dStrAsciiCasecmp(ext, ".htm"))){
ctype = "text/html";
}
@@ -1474,7 +1474,7 @@ DilloHtmlInput *DilloHtmlForm::getRadioInput (const char *name)
for (int idx = 0; idx < inputs->size(); idx++) {
DilloHtmlInput *input = inputs->get(idx);
if (input->type == DILLO_HTML_INPUT_RADIO &&
- input->name && !dStrcasecmp(input->name, name))
+ input->name && !dStrAsciiCasecmp(input->name, name))
return input;
}
return NULL;
diff --git a/src/html.cc b/src/html.cc
index 9f3f048b..896aaab6 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -16,7 +16,7 @@
/*-----------------------------------------------------------------------------
* Includes
*---------------------------------------------------------------------------*/
-#include <ctype.h> /* for isspace and tolower */
+#include <ctype.h> /* for isspace */
#include <string.h> /* for memcpy and memmove */
#include <stdlib.h>
#include <stdio.h> /* for sprintf */
@@ -311,16 +311,16 @@ void a_Html_tag_set_align_attr(DilloHtml *html, const char *tag, int tagsize)
if ((align = a_Html_get_attr(html, tag, tagsize, "align"))) {
TextAlignType textAlignType = TEXT_ALIGN_LEFT;
- if (dStrcasecmp (align, "left") == 0)
+ if (dStrAsciiCasecmp (align, "left") == 0)
textAlignType = TEXT_ALIGN_LEFT;
- else if (dStrcasecmp (align, "right") == 0)
+ else if (dStrAsciiCasecmp (align, "right") == 0)
textAlignType = TEXT_ALIGN_RIGHT;
- else if (dStrcasecmp (align, "center") == 0)
+ else if (dStrAsciiCasecmp (align, "center") == 0)
textAlignType = TEXT_ALIGN_CENTER;
- else if (dStrcasecmp (align, "justify") == 0)
+ else if (dStrAsciiCasecmp (align, "justify") == 0)
textAlignType = TEXT_ALIGN_JUSTIFY;
#if 0
- else if (dStrcasecmp (align, "char") == 0) {
+ else if (dStrAsciiCasecmp (align, "char") == 0) {
/* TODO: Actually not supported for <p> etc. */
v.textAlign = TEXT_ALIGN_STRING;
if ((charattr = a_Html_get_attr(html, tag, tagsize, "char"))) {
@@ -352,11 +352,11 @@ bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, int tagsize)
VAlignType valign;
if ((attr = a_Html_get_attr(html, tag, tagsize, "valign"))) {
- if (dStrcasecmp (attr, "top") == 0)
+ if (dStrAsciiCasecmp (attr, "top") == 0)
valign = VALIGN_TOP;
- else if (dStrcasecmp (attr, "bottom") == 0)
+ else if (dStrAsciiCasecmp (attr, "bottom") == 0)
valign = VALIGN_BOTTOM;
- else if (dStrcasecmp (attr, "baseline") == 0)
+ else if (dStrAsciiCasecmp (attr, "baseline") == 0)
valign = VALIGN_BASELINE;
else
valign = VALIGN_MIDDLE;
@@ -1240,7 +1240,7 @@ static bool Html_match_tag(const char *tagstr, char *tag, int tagsize)
int i;
for (i = 0; i < tagsize && tagstr[i] != '\0'; i++) {
- if (tolower(tagstr[i]) != tolower(tag[i]))
+ if (D_ASCII_TOLOWER(tagstr[i]) != D_ASCII_TOLOWER(tag[i]))
return false;
}
/* The test for '/' is for xml compatibility: "empty/>" will be matched. */
@@ -1530,18 +1530,18 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize)
_MSG("New: {%s}\n", ntag);
/* The default DT_NONE type is TagSoup */
- if (!dStrncasecmp(ntag, HTML_SGML_sig, strlen(HTML_SGML_sig))) {
+ if (!dStrnAsciiCasecmp(ntag, HTML_SGML_sig, strlen(HTML_SGML_sig))) {
p = ntag + strlen(HTML_SGML_sig) + 1;
if (!strncmp(p, HTML401, strlen(HTML401)) &&
- dStristr(p + strlen(HTML401), HTML401_url)) {
+ dStriAsciiStr(p + strlen(HTML401), HTML401_url)) {
html->DocType = DT_HTML;
html->DocTypeVersion = 4.01f;
} else if (!strncmp(p, XHTML1, strlen(XHTML1)) &&
- dStristr(p + strlen(XHTML1), XHTML1_url)) {
+ dStriAsciiStr(p + strlen(XHTML1), XHTML1_url)) {
html->DocType = DT_XHTML;
html->DocTypeVersion = 1.0f;
} else if (!strncmp(p, XHTML11, strlen(XHTML11)) &&
- dStristr(p + strlen(XHTML11), XHTML11_url)) {
+ dStriAsciiStr(p + strlen(XHTML11), XHTML11_url)) {
html->DocType = DT_XHTML;
html->DocTypeVersion = 1.1f;
} else if (!strncmp(p, HTML40, strlen(HTML40))) {
@@ -1554,7 +1554,7 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize)
html->DocType = DT_HTML;
html->DocTypeVersion = 2.0f;
}
- } else if (!dStrcasecmp(ntag, HTML5_sig)) {
+ } else if (!dStrAsciiCasecmp(ntag, HTML5_sig)) {
BUG_MSG("Document follows HTML5 working draft; treating as HTML4.\n");
html->DocType = DT_HTML;
html->DocTypeVersion = 5.0f;
@@ -1687,11 +1687,11 @@ static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize)
if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "type"))) {
BUG_MSG("type attribute is required for <style>\n");
- } else if (dStrcasecmp(attrbuf, "text/css")) {
+ } else if (dStrAsciiCasecmp(attrbuf, "text/css")) {
html->loadCssFromStash = false;
}
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "media")) &&
- dStrcasecmp(attrbuf, "all") && !dStristr(attrbuf, "screen")) {
+ dStrAsciiCasecmp(attrbuf, "all") && !dStriAsciiStr(attrbuf, "screen")) {
/* HTML 4.01 sec. 6.13 says that media descriptors are case-sensitive,
* but sec. 14.2.3 says that the attribute is case-insensitive.
* TODO can be a comma-separated list.
@@ -1860,7 +1860,7 @@ static void Html_tag_open_frame (DilloHtml *html, const char *tag, int tagsize)
textblock->addWidget(bullet, html->styleEngine->wordStyle ());
textblock->addSpace(html->styleEngine->wordStyle ());
- if (tolower(tag[1]) == 'i') {
+ if (D_ASCII_TOLOWER(tag[1]) == 'i') {
/* IFRAME usually comes with very long advertising/spying URLS,
* to not break rendering we will force name="IFRAME" */
textblock->addText ("IFRAME", html->styleEngine->wordStyle ());
@@ -2120,7 +2120,7 @@ DilloImage *a_Html_image_new(DilloHtml *html, const char *tag,
Image->bg_color = HT2TB(html)->getBgColor()->getColor();
load_now = prefs.load_images ||
- !dStrcasecmp(URL_SCHEME(url), "data") ||
+ !dStrAsciiCasecmp(URL_SCHEME(url), "data") ||
(a_Capi_get_flags_with_redirection(url) & CAPI_IsCached);
bool loading = false;
if (load_now)
@@ -2292,15 +2292,15 @@ static void Html_tag_open_area(DilloHtml *html, const char *tag, int tagsize)
}
attrbuf = a_Html_get_attr(html, tag, tagsize, "shape");
- if (!attrbuf || !*attrbuf || !dStrcasecmp(attrbuf, "rect")) {
+ if (!attrbuf || !*attrbuf || !dStrAsciiCasecmp(attrbuf, "rect")) {
/* the default shape is a rectangle */
type = RECTANGLE;
- } else if (dStrcasecmp(attrbuf, "default") == 0) {
+ } else if (dStrAsciiCasecmp(attrbuf, "default") == 0) {
/* "default" is the background */
type = BACKGROUND;
- } else if (dStrcasecmp(attrbuf, "circle") == 0) {
+ } else if (dStrAsciiCasecmp(attrbuf, "circle") == 0) {
type = CIRCLE;
- } else if (dStrncasecmp(attrbuf, "poly", 4) == 0) {
+ } else if (dStrnAsciiCasecmp(attrbuf, "poly", 4) == 0) {
type = POLYGON;
} else {
BUG_MSG("<area> unknown shape: \"%s\"\n", attrbuf);
@@ -2394,7 +2394,7 @@ static const char* Html_get_javascript_link(DilloHtml *html)
char ch, *p1, *p2;
Dstr *Buf = html->attr_data;
- if (dStrncasecmp("javascript", Buf->str, 10) == 0) {
+ if (dStrnAsciiCasecmp("javascript", Buf->str, 10) == 0) {
i = strcspn(Buf->str, "'\"");
ch = Buf->str[i];
if ((ch == '"' || ch == '\'') &&
@@ -2440,7 +2440,7 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize)
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "href"))) {
/* if it's a javascript link, extract the reference. */
- if (tolower(attrbuf[0]) == 'j')
+ if (D_ASCII_TOLOWER(attrbuf[0]) == 'j')
attrbuf = Html_get_javascript_link(html);
url = a_Html_url_new(html, attrbuf, NULL, 0);
@@ -2548,11 +2548,11 @@ static void Html_tag_open_ul(DilloHtml *html, const char *tag, int tagsize)
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "type"))) {
/* list_style_type explicitly defined */
- if (dStrcasecmp(attrbuf, "disc") == 0)
+ if (dStrAsciiCasecmp(attrbuf, "disc") == 0)
list_style_type = LIST_STYLE_TYPE_DISC;
- else if (dStrcasecmp(attrbuf, "circle") == 0)
+ else if (dStrAsciiCasecmp(attrbuf, "circle") == 0)
list_style_type = LIST_STYLE_TYPE_CIRCLE;
- else if (dStrcasecmp(attrbuf, "square") == 0)
+ else if (dStrAsciiCasecmp(attrbuf, "square") == 0)
list_style_type = LIST_STYLE_TYPE_SQUARE;
else
/* invalid value */
@@ -2853,7 +2853,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
}
if ((equiv = a_Html_get_attr(html, tag, tagsize, "http-equiv"))) {
- if (!dStrcasecmp(equiv, "refresh") &&
+ if (!dStrAsciiCasecmp(equiv, "refresh") &&
(content = a_Html_get_attr(html, tag, tagsize, "content"))) {
/* Get delay, if present, and make a message with it */
@@ -2905,7 +2905,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
a_Url_free(new_url);
dFree(mr_url);
- } else if (!dStrcasecmp(equiv, "content-type") &&
+ } else if (!dStrAsciiCasecmp(equiv, "content-type") &&
(content = a_Html_get_attr(html, tag, tagsize, "content"))) {
_MSG("Html_tag_open_meta: content={%s}\n", content);
/* Cannot ask cache whether the content type was changed, as
@@ -3010,14 +3010,14 @@ static void Html_tag_open_link(DilloHtml *html, const char *tag, int tagsize)
dReturn_if_fail (prefs.load_stylesheets);
/* CSS stylesheet link */
if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "rel")) ||
- dStrcasecmp(attrbuf, "stylesheet"))
+ dStrAsciiCasecmp(attrbuf, "stylesheet"))
return;
/* IMPLIED attributes? */
if (((attrbuf = a_Html_get_attr(html, tag, tagsize, "type")) &&
- dStrcasecmp(attrbuf, "text/css")) ||
+ dStrAsciiCasecmp(attrbuf, "text/css")) ||
((attrbuf = a_Html_get_attr(html, tag, tagsize, "media")) &&
- !dStristr(attrbuf, "screen") && dStrcasecmp(attrbuf, "all")))
+ !dStriAsciiStr(attrbuf, "screen") && dStrAsciiCasecmp(attrbuf, "all")))
return;
if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "href")) ||
@@ -3231,8 +3231,8 @@ const TagInfo Tags[] = {
static int Html_tag_compare(const char *p1, const char *p2)
{
while ( *p2 ) {
- if (tolower(*p1) != *p2)
- return(tolower(*p1) - *p2);
+ if (D_ASCII_TOLOWER(*p1) != *p2)
+ return(D_ASCII_TOLOWER(*p1) - *p2);
++p1;
++p2;
}
@@ -3474,7 +3474,7 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
if (ni == -1) {
/* TODO: doctype parsing is a bit fuzzy, but enough for the time being */
if (!(html->InFlags & IN_HTML)) {
- if (tagsize > 9 && !dStrncasecmp(tag, "<!doctype", 9))
+ if (tagsize > 9 && !dStrnAsciiCasecmp(tag, "<!doctype", 9))
Html_parse_doctype(html, tag, tagsize);
}
/* Ignore unknown tags */
@@ -3591,8 +3591,11 @@ static const char *Html_get_attr2(DilloHtml *html,
(tag[i] == '=' || isspace(tag[i]) || tag[i] == '>')))) {
state = SEEK_TOKEN_START;
--i;
- } else if (tolower(tag[i]) != tolower(attrname[attr_pos++]))
- state = SEEK_ATTR_START;
+ } else {
+ if (D_ASCII_TOLOWER(tag[i]) != D_ASCII_TOLOWER(attrname[attr_pos]))
+ state = SEEK_ATTR_START;
+ attr_pos++;
+ }
break;
case SEEK_TOKEN_START:
diff --git a/src/keys.cc b/src/keys.cc
index 68438b9b..687d09fc 100644
--- a/src/keys.cc
+++ b/src/keys.cc
@@ -245,7 +245,7 @@ int Keys::getKeyCode(char *keyName)
{
uint_t i;
for (i = 0; i < sizeof(keyNames) / sizeof(Mapping_t); i++) {
- if (!dStrcasecmp(keyNames[i].name, keyName)) {
+ if (!dStrAsciiCasecmp(keyNames[i].name, keyName)) {
return keyNames[i].value;
}
}
@@ -262,7 +262,7 @@ KeysCommand_t Keys::getCmdCode(const char *commandName)
uint_t i;
for (i = 0; i < sizeof(default_keys) / sizeof(KeyBinding_t); i++) {
- if (!dStrcasecmp(default_keys[i].name, commandName))
+ if (!dStrAsciiCasecmp(default_keys[i].name, commandName))
return default_keys[i].cmd;
}
return KEYS_INVALID;
@@ -276,7 +276,7 @@ int Keys::getModifier(char *modifierName)
{
uint_t i;
for (i = 0; i < sizeof(modifierNames) / sizeof(Mapping_t); i++) {
- if (!dStrcasecmp(modifierNames[i].name, modifierName)) {
+ if (!dStrAsciiCasecmp(modifierNames[i].name, modifierName)) {
return modifierNames[i].value;
}
}
diff --git a/src/misc.c b/src/misc.c
index 72b4e03d..5efcf1de 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -141,12 +141,12 @@ int a_Misc_get_content_type_from_data(void *Data, size_t Size, const char **PT)
/* HTML try */
for (i = 0; i < Size && dIsspace(p[i]); ++i);
- if ((Size - i >= 5 && !dStrncasecmp(p+i, "<html", 5)) ||
- (Size - i >= 5 && !dStrncasecmp(p+i, "<head", 5)) ||
- (Size - i >= 6 && !dStrncasecmp(p+i, "<title", 6)) ||
- (Size - i >= 14 && !dStrncasecmp(p+i, "<!doctype html", 14)) ||
+ if ((Size - i >= 5 && !dStrnAsciiCasecmp(p+i, "<html", 5)) ||
+ (Size - i >= 5 && !dStrnAsciiCasecmp(p+i, "<head", 5)) ||
+ (Size - i >= 6 && !dStrnAsciiCasecmp(p+i, "<title", 6)) ||
+ (Size - i >= 14 && !dStrnAsciiCasecmp(p+i, "<!doctype html", 14)) ||
/* this line is workaround for FTP through the Squid proxy */
- (Size - i >= 17 && !dStrncasecmp(p+i, "<!-- HTML listing", 17))) {
+ (Size - i >= 17 && !dStrnAsciiCasecmp(p+i, "<!-- HTML listing", 17))) {
Type = DT_TEXT_HTML;
st = 0;
@@ -233,8 +233,8 @@ void a_Misc_parse_content_type(const char *type, char **major, char **minor,
*minor = dStrndup(str, s - str);
}
if (charset && *s &&
- (dStrncasecmp(type, "text/", 5) == 0 ||
- dStrncasecmp(type, "application/xhtml+xml", 21) == 0)) {
+ (dStrnAsciiCasecmp(type, "text/", 5) == 0 ||
+ dStrnAsciiCasecmp(type, "application/xhtml+xml", 21) == 0)) {
/* "charset" parameter defined for text media type in RFC 2046,
* application/xhtml+xml in RFC 3236.
*
@@ -246,7 +246,7 @@ void a_Misc_parse_content_type(const char *type, char **major, char **minor,
const char terminators[] = " ;\t";
const char key[] = "charset";
- if ((s = dStristr(str, key)) &&
+ if ((s = dStriAsciiStr(str, key)) &&
(s == str || strchr(terminators, s[-1]))) {
s += sizeof(key) - 1;
for ( ; *s == ' ' || *s == '\t'; ++s);
@@ -283,12 +283,12 @@ int a_Misc_content_type_cmp(const char *ct1, const char *ct2)
a_Misc_parse_content_type(ct1, &major1, &minor1, &charset1);
a_Misc_parse_content_type(ct2, &major2, &minor2, &charset2);
- if (major1 && major2 && !dStrcasecmp(major1, major2) &&
- minor1 && minor2 && !dStrcasecmp(minor1, minor2) &&
+ if (major1 && major2 && !dStrAsciiCasecmp(major1, major2) &&
+ minor1 && minor2 && !dStrAsciiCasecmp(minor1, minor2) &&
((!charset1 && !charset2) ||
- (charset1 && charset2 && !dStrcasecmp(charset1, charset2)) ||
- (!charset1 && charset2 && !dStrcasecmp(charset2, "UTF-8")) ||
- (charset1 && !charset2 && !dStrcasecmp(charset1, "UTF-8")))) {
+ (charset1 && charset2 && !dStrAsciiCasecmp(charset1, charset2)) ||
+ (!charset1 && charset2 && !dStrAsciiCasecmp(charset2, "UTF-8")) ||
+ (charset1 && !charset2 && !dStrAsciiCasecmp(charset1, "UTF-8")))) {
ret = 0;
} else {
ret = 1;
@@ -328,22 +328,23 @@ int a_Misc_content_type_check(const char *EntryType, const char *DetectedType)
return 0; /* there's no mismatch without server type */
for (i = 1; MimeTypes[i].str; ++i)
- if (dStrncasecmp(EntryType, MimeTypes[i].str, MimeTypes[i].len) == 0)
+ if (dStrnAsciiCasecmp(EntryType, MimeTypes[i].str, MimeTypes[i].len) ==0)
break;
if (!MimeTypes[i].str) {
/* type not found, no mismatch */
st = 0;
- } else if (dStrncasecmp(EntryType, "image/", 6) == 0 &&
- !dStrncasecmp(DetectedType,MimeTypes[i].str,MimeTypes[i].len)){
+ } else if (dStrnAsciiCasecmp(EntryType, "image/", 6) == 0 &&
+ !dStrnAsciiCasecmp(DetectedType, MimeTypes[i].str,
+ MimeTypes[i].len)){
/* An image, and there's an exact match */
st = 0;
- } else if (dStrncasecmp(EntryType, "text/", 5) ||
- dStrncasecmp(DetectedType, "application/", 12)) {
+ } else if (dStrnAsciiCasecmp(EntryType, "text/", 5) ||
+ dStrnAsciiCasecmp(DetectedType, "application/", 12)) {
/* Not an application sent as text */
st = 0;
- } else if (dStrncasecmp(EntryType, "application/xhtml+xml", 21) &&
- dStrncasecmp(DetectedType, "text/html", 9)) {
+ } else if (dStrnAsciiCasecmp(EntryType, "application/xhtml+xml", 21) &&
+ dStrnAsciiCasecmp(DetectedType, "text/html", 9)) {
/* XML version of HTML */
st = 0;
}
diff --git a/src/prefsparser.cc b/src/prefsparser.cc
index efe64a0e..7fd6cf4a 100644
--- a/src/prefsparser.cc
+++ b/src/prefsparser.cc
@@ -127,8 +127,8 @@ int PrefsParser::parseOption(char *name, char *value)
switch (node->type) {
case PREFS_BOOL:
- *(bool_t *)node->pref = (!dStrcasecmp(value, "yes") ||
- !dStrcasecmp(value, "true"));
+ *(bool_t *)node->pref = (!dStrAsciiCasecmp(value, "yes") ||
+ !dStrAsciiCasecmp(value, "true"));
break;
case PREFS_COLOR:
*(int32_t *)node->pref = a_Color_parse(value, *(int32_t*)node->pref,&st);
@@ -167,18 +167,18 @@ int PrefsParser::parseOption(char *name, char *value)
&prefs.width, &prefs.height);
break;
case PREFS_FILTER:
- if (!dStrcasecmp(value, "same_domain"))
+ if (!dStrAsciiCasecmp(value, "same_domain"))
prefs.filter_auto_requests = PREFS_FILTER_SAME_DOMAIN;
else {
- if (dStrcasecmp(value, "allow_all"))
+ if (dStrAsciiCasecmp(value, "allow_all"))
MSG_WARN("prefs: unrecognized value for filter_auto_requests\n");
prefs.filter_auto_requests = PREFS_FILTER_ALLOW_ALL;
}
break;
case PREFS_PANEL_SIZE:
- if (!dStrcasecmp(value, "tiny"))
+ if (!dStrAsciiCasecmp(value, "tiny"))
prefs.panel_size = P_tiny;
- else if (!dStrcasecmp(value, "small"))
+ else if (!dStrAsciiCasecmp(value, "small"))
prefs.panel_size = P_small;
else /* default to "medium" */
prefs.panel_size = P_medium;
diff --git a/src/table.cc b/src/table.cc
index f89e781b..622868ca 100644
--- a/src/table.cc
+++ b/src/table.cc
@@ -81,13 +81,13 @@ void Html_tag_open_table(DilloHtml *html, const char *tag, int tagsize)
a_Html_parse_length (html, attrbuf));
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "align"))) {
- if (dStrcasecmp (attrbuf, "left") == 0)
+ if (dStrAsciiCasecmp (attrbuf, "left") == 0)
html->styleEngine->setNonCssHint (CSS_PROPERTY_TEXT_ALIGN,
CSS_TYPE_ENUM, TEXT_ALIGN_LEFT);
- else if (dStrcasecmp (attrbuf, "right") == 0)
+ else if (dStrAsciiCasecmp (attrbuf, "right") == 0)
html->styleEngine->setNonCssHint (CSS_PROPERTY_TEXT_ALIGN,
CSS_TYPE_ENUM, TEXT_ALIGN_RIGHT);
- else if (dStrcasecmp (attrbuf, "center") == 0)
+ else if (dStrAsciiCasecmp (attrbuf, "center") == 0)
html->styleEngine->setNonCssHint (CSS_PROPERTY_TEXT_ALIGN,
CSS_TYPE_ENUM, TEXT_ALIGN_CENTER);
}
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 38225047..b02a5746 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -597,7 +597,7 @@ void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
/* Filter URL string */
new_urlstr = a_Url_string_strip_delimiters(urlstr);
- if (!dStrncasecmp(new_urlstr, "file:", 5)) {
+ if (!dStrnAsciiCasecmp(new_urlstr, "file:", 5)) {
/* file URI */
ch = new_urlstr[5];
if (!ch || ch == '.') {
diff --git a/src/url.c b/src/url.c
index 78f717cf..27c97d1c 100644
--- a/src/url.c
+++ b/src/url.c
@@ -54,7 +54,7 @@ static const char *HEX = "0123456789ABCDEF";
#define URL_STR_FIELD_CMP(s1,s2) \
(s1) && (s2) ? strcmp(s1,s2) : !(s1) && !(s2) ? 0 : (s1) ? 1 : -1
#define URL_STR_FIELD_I_CMP(s1,s2) \
- (s1) && (s2) ? dStrcasecmp(s1,s2) : !(s1) && !(s2) ? 0 : (s1) ? 1 : -1
+ (s1) && (s2) ? dStrAsciiCasecmp(s1,s2) : !(s1) && !(s2) ? 0 : (s1) ? 1 : -1
/*
* Return the url as a string.
@@ -702,7 +702,7 @@ static uint_t Url_host_public_internal_dots(const char *host)
for (i = 0; i < tld_num; i++) {
if (strlen(tlds[i]) == (uint_t) tld_len &&
- !dStrncasecmp(tlds[i], host + start, tld_len)) {
+ !dStrnAsciiCasecmp(tlds[i], host + start, tld_len)) {
_MSG("TLD code matched %s\n", tlds[i]);
ret++;
break;
@@ -759,6 +759,7 @@ bool_t a_Url_same_organization(const DilloUrl *u1, const DilloUrl *u2)
if (!u1 || !u2)
return FALSE;
- return dStrcasecmp(Url_host_find_public_suffix(URL_HOST(u1)),
- Url_host_find_public_suffix(URL_HOST(u2))) ? FALSE :TRUE;
+ return dStrAsciiCasecmp(Url_host_find_public_suffix(URL_HOST(u1)),
+ Url_host_find_public_suffix(URL_HOST(u2)))
+ ? FALSE : TRUE;
}
diff --git a/src/web.cc b/src/web.cc
index 74851f2b..48c368be 100644
--- a/src/web.cc
+++ b/src/web.cc
@@ -95,7 +95,7 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
} else {
/* A non-RootUrl. At this moment we only handle image-children */
- if (!dStrncasecmp(Type, "image/", 6)) {
+ if (!dStrnAsciiCasecmp(Type, "image/", 6)) {
dw = (Widget*) a_Mime_set_viewer(Type, Web, Call, Data);
} else {
MSG_HTTP("'%s' cannot be displayed as image; has media type '%s'\n",