summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dlib/dlib.c32
-rw-r--r--dlib/dlib.h10
-rw-r--r--dpi/bookmarks.c2
-rw-r--r--dpi/cookies.c38
-rw-r--r--dpi/datauri.c8
-rw-r--r--dpi/downloads.cc2
-rw-r--r--dpi/dpiutil.c11
-rw-r--r--dpi/file.c33
-rw-r--r--dpi/ftp.c10
-rw-r--r--dpi/https.c4
-rw-r--r--dpid/dpid.c2
-rw-r--r--dw/fltkplatform.cc2
-rw-r--r--dw/style.cc6
-rw-r--r--lout/misc.hh21
-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
-rw-r--r--test/dw_anchors_test.cc6
34 files changed, 309 insertions, 250 deletions
diff --git a/dlib/dlib.c b/dlib/dlib.c
index a3c59060..002adcdf 100644
--- a/dlib/dlib.c
+++ b/dlib/dlib.c
@@ -173,16 +173,21 @@ char *dStrsep(char **orig, const char *delim)
}
/*
+ * ASCII functions to avoid the case difficulties introduced by I/i in
+ * Turkic locales.
+ */
+
+/*
* Case insensitive strstr
*/
-char *dStristr(const char *haystack, const char *needle)
+char *dStriAsciiStr(const char *haystack, const char *needle)
{
int i, j;
char *ret = NULL;
if (haystack && needle) {
for (i = 0, j = 0; haystack[i] && needle[j]; ++i)
- if (tolower(haystack[i]) == tolower(needle[j])) {
+ if (D_ASCII_TOLOWER(haystack[i]) == D_ASCII_TOLOWER(needle[j])) {
++j;
} else if (j) {
i -= j;
@@ -194,6 +199,29 @@ char *dStristr(const char *haystack, const char *needle)
return ret;
}
+int dStrAsciiCasecmp(const char *s1, const char *s2)
+{
+ int ret = 0;
+
+ while ((*s1 || *s2) &&
+ !(ret = D_ASCII_TOLOWER(*s1) - D_ASCII_TOLOWER(*s2))) {
+ s1++;
+ s2++;
+ }
+ return ret;
+}
+
+int dStrnAsciiCasecmp(const char *s1, const char *s2, size_t n)
+{
+ int ret = 0;
+
+ while (n-- && (*s1 || *s2) &&
+ !(ret = D_ASCII_TOLOWER(*s1) - D_ASCII_TOLOWER(*s2))) {
+ s1++;
+ s2++;
+ }
+ return ret;
+}
/*
*- dStr ----------------------------------------------------------------------
diff --git a/dlib/dlib.h b/dlib/dlib.h
index cd612d28..8dc324a7 100644
--- a/dlib/dlib.h
+++ b/dlib/dlib.h
@@ -5,7 +5,6 @@
#include <stddef.h> /* for size_t */
#include <stdarg.h> /* for va_list */
#include <string.h> /* for strerror */
-#include <strings.h> /* for strcasecmp, strncasecmp (POSIX 2001) */
#include "d_size.h"
@@ -34,6 +33,8 @@ extern "C" {
#define dIsspace(c) isspace((uchar_t)(c))
#define dIsalnum(c) isalnum((uchar_t)(c))
+#define D_ASCII_TOUPPER(c) (((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))
+#define D_ASCII_TOLOWER(c) (((c) >= 'A' && (c) <= 'Z') ? (c) + 0x20 : (c))
/*
*-- Casts -------------------------------------------------------------------
*/
@@ -86,12 +87,11 @@ char *dStrconcat(const char *s1, ...);
char *dStrstrip(char *s);
char *dStrnfill(size_t len, char c);
char *dStrsep(char **orig, const char *delim);
-char *dStristr(const char *haystack, const char *needle);
void dStrshred(char *s);
+char *dStriAsciiStr(const char *haystack, const char *needle);
+int dStrAsciiCasecmp(const char *s1, const char *s2);
+int dStrnAsciiCasecmp(const char *s1, const char *s2, size_t n);
-/* these are in POSIX 2001. Could be implemented if a port requires it */
-#define dStrcasecmp strcasecmp
-#define dStrncasecmp strncasecmp
#define dStrerror strerror
/*
diff --git a/dpi/bookmarks.c b/dpi/bookmarks.c
index 6e9cb3df..6932d2f0 100644
--- a/dpi/bookmarks.c
+++ b/dpi/bookmarks.c
@@ -442,7 +442,7 @@ static void Unencode_str(char *e_str)
if (*e == '+') {
*p = ' ';
} else if (*e == '%') {
- if (dStrncasecmp(e, "%0D%0A", 6) == 0) {
+ if (dStrnAsciiCasecmp(e, "%0D%0A", 6) == 0) {
*p = '\n';
e += 5;
} else {
diff --git a/dpi/cookies.c b/dpi/cookies.c
index 734dc016..93048a5c 100644
--- a/dpi/cookies.c
+++ b/dpi/cookies.c
@@ -158,7 +158,7 @@ static int Domain_node_cmp(const void *v1, const void *v2)
{
const DomainNode *n1 = v1, *n2 = v2;
- return dStrcasecmp(n1->domain, n2->domain);
+ return dStrAsciiCasecmp(n1->domain, n2->domain);
}
/*
@@ -169,7 +169,7 @@ static int Domain_node_by_domain_cmp(const void *v1, const void *v2)
const DomainNode *node = v1;
const char *domain = v2;
- return dStrcasecmp(node->domain, domain);
+ return dStrAsciiCasecmp(node->domain, domain);
}
/*
@@ -468,7 +468,7 @@ static int Cookies_get_month(const char *month_name)
int i;
for (i = 0; i < 12; i++) {
- if (!dStrncasecmp(months[i], month_name, 3))
+ if (!dStrnAsciiCasecmp(months[i], month_name, 3))
return i;
}
return -1;
@@ -821,15 +821,15 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date)
cookie->expires_at = mktime(tm);
if (cookie->expires_at == (time_t) -1)
cookie->expires_at = cookies_future_time;
- } else if (dStrcasecmp(attr, "Path") == 0) {
+ } else if (dStrAsciiCasecmp(attr, "Path") == 0) {
value = Cookies_parse_value(&str);
dFree(cookie->path);
cookie->path = value;
- } else if (dStrcasecmp(attr, "Domain") == 0) {
+ } else if (dStrAsciiCasecmp(attr, "Domain") == 0) {
value = Cookies_parse_value(&str);
dFree(cookie->domain);
cookie->domain = value;
- } else if (dStrcasecmp(attr, "Max-Age") == 0) {
+ } else if (dStrAsciiCasecmp(attr, "Max-Age") == 0) {
value = Cookies_parse_value(&str);
if (isdigit(*value) || *value == '-') {
time_t now = time(NULL);
@@ -845,7 +845,7 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date)
expires = max_age = TRUE;
}
dFree(value);
- } else if (dStrcasecmp(attr, "Expires") == 0) {
+ } else if (dStrAsciiCasecmp(attr, "Expires") == 0) {
if (!max_age) {
value = Cookies_parse_value(&str);
Cookies_unquote_string(value);
@@ -870,10 +870,10 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date)
} else {
Cookies_eat_value(&str);
}
- } else if (dStrcasecmp(attr, "Secure") == 0) {
+ } else if (dStrAsciiCasecmp(attr, "Secure") == 0) {
cookie->secure = TRUE;
Cookies_eat_value(&str);
- } else if (dStrcasecmp(attr, "HttpOnly") == 0) {
+ } else if (dStrAsciiCasecmp(attr, "HttpOnly") == 0) {
Cookies_eat_value(&str);
} else {
MSG("Cookie contains unknown attribute: '%s'\n", attr);
@@ -992,7 +992,7 @@ static bool_t Cookies_domain_matches(char *A, char *B)
* don't, so: No.
*/
- if (!dStrcasecmp(A, B))
+ if (!dStrAsciiCasecmp(A, B))
return TRUE;
if (Cookies_domain_is_ip(B))
@@ -1002,7 +1002,7 @@ static bool_t Cookies_domain_matches(char *A, char *B)
if (diff > 0) {
/* B is the tail of A, and the match is preceded by a '.' */
- return (dStrcasecmp(A + diff, B) == 0 && A[diff - 1] == '.');
+ return (dStrAsciiCasecmp(A + diff, B) == 0 && A[diff - 1] == '.');
} else {
return FALSE;
}
@@ -1050,7 +1050,7 @@ static uint_t Cookies_internal_dots_required(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;
@@ -1221,7 +1221,7 @@ static char *Cookies_get(char *url_host, char *url_path,
matching_cookies = dList_new(8);
/* Check if the protocol is secure or not */
- is_ssl = (!dStrcasecmp(url_scheme, "https"));
+ is_ssl = (!dStrAsciiCasecmp(url_scheme, "https"));
is_ip_addr = Cookies_domain_is_ip(url_host);
@@ -1350,11 +1350,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",
@@ -1363,7 +1363,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);
@@ -1404,13 +1404,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/dpi/datauri.c b/dpi/datauri.c
index 6d7acfa7..9088c6aa 100644
--- a/dpi/datauri.c
+++ b/dpi/datauri.c
@@ -226,14 +226,14 @@ static char *datauri_get_mime(char *url)
char *mime_type = NULL, *p;
size_t len = 0;
- if (dStrncasecmp(url, "data:", 5) == 0) {
+ if (dStrnAsciiCasecmp(url, "data:", 5) == 0) {
if ((p = strchr(url, ',')) && p - url < 256) {
url += 5;
len = p - url;
strncpy(buf, url, len);
buf[len] = 0;
/* strip ";base64" */
- if (len >= 7 && dStrcasecmp(buf + len - 7, ";base64") == 0) {
+ if (len >= 7 && dStrAsciiCasecmp(buf + len - 7, ";base64") == 0) {
len -= 7;
buf[len] = 0;
}
@@ -242,7 +242,7 @@ static char *datauri_get_mime(char *url)
/* that's it, now handle omitted types */
if (len == 0) {
mime_type = dStrdup("text/plain;charset=US-ASCII");
- } else if (!dStrncasecmp(buf, "charset", 7)) {
+ } else if (!dStrnAsciiCasecmp(buf, "charset", 7)) {
mime_type = dStrconcat("text/plain", buf, NULL);
} else {
mime_type = dStrdup(buf);
@@ -262,7 +262,7 @@ static unsigned char *datauri_get_data(char *url, size_t *p_sz)
unsigned char *data = NULL;
if ((p = strchr(url, ',')) && p - url >= 12 && /* "data:;base64" */
- dStrncasecmp(p - 7, ";base64", 7) == 0) {
+ dStrnAsciiCasecmp(p - 7, ";base64", 7) == 0) {
is_base64 = 1;
}
diff --git a/dpi/downloads.cc b/dpi/downloads.cc
index d9ccb380..418dbd1b 100644
--- a/dpi/downloads.cc
+++ b/dpi/downloads.cc
@@ -327,7 +327,7 @@ DLItem::DLItem(const char *full_filename, const char *url, DLAction action)
/* escape "'" character for the shell. Is it necessary? */
esc_url = Escape_uri_str(url, "'");
/* avoid malicious SMTP relaying with FTP urls */
- if (dStrncasecmp(esc_url, "ftp:/", 5) == 0)
+ if (dStrnAsciiCasecmp(esc_url, "ftp:/", 5) == 0)
Filter_smtp_hack(esc_url);
dl_argv = new char*[8];
int i = 0;
diff --git a/dpi/dpiutil.c b/dpi/dpiutil.c
index e29d529f..45100be2 100644
--- a/dpi/dpiutil.c
+++ b/dpi/dpiutil.c
@@ -68,8 +68,10 @@ char *Unescape_uri_str(const char *s)
if (strchr(s, '%')) {
for (p = buf; (*p = *s); ++s, ++p) {
if (*p == '%' && isxdigit(s[1]) && isxdigit(s[2])) {
- *p = (isdigit(s[1]) ? (s[1] - '0') : toupper(s[1]) - 'A' + 10)*16;
- *p += isdigit(s[2]) ? (s[2] - '0') : toupper(s[2]) - 'A' + 10;
+ *p = (isdigit(s[1]) ? (s[1] - '0')
+ : D_ASCII_TOUPPER(s[1]) - 'A' + 10) * 16;
+ *p += isdigit(s[2]) ? (s[2] - '0')
+ : D_ASCII_TOUPPER(s[2]) - 'A' + 10;
s += 2;
}
}
@@ -121,7 +123,7 @@ char *Unescape_html_str(const char *str)
for (i = 0, j = 0; str[i]; ++i) {
if (str[i] == '&') {
for (k = 0; k < 5; ++k) {
- if (!dStrncasecmp(str + i, unsafe_rep[k], unsafe_rep_len[k])) {
+ if (!dStrnAsciiCasecmp(str + i, unsafe_rep[k], unsafe_rep_len[k])) {
i += unsafe_rep_len[k] - 1;
break;
}
@@ -154,7 +156,8 @@ char *Filter_smtp_hack(char *url)
memmove(url + i, url + i + 1, strlen(url + i));
--i;
} else if (c == '%' && url[i+1] == '0' &&
- (tolower(url[i+2]) == 'a' || tolower(url[i+2]) == 'd')) {
+ (D_ASCII_TOLOWER(url[i+2]) == 'a' ||
+ D_ASCII_TOLOWER(url[i+2]) == 'd')) {
memmove(url + i, url + i + 3, strlen(url + i + 2));
--i;
}
diff --git a/dpi/file.c b/dpi/file.c
index 0e517298..9e33cae2 100644
--- a/dpi/file.c
+++ b/dpi/file.c
@@ -15,7 +15,7 @@
* With new HTML layout.
*/
-#include <ctype.h> /* for tolower */
+#include <ctype.h> /* for isspace */
#include <errno.h> /* for errno */
#include <stdio.h>
#include <stdlib.h>
@@ -142,12 +142,12 @@ static const char *File_get_content_type_from_data(void *Data, size_t Size)
/* 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 = 1;
@@ -502,18 +502,18 @@ static const char *File_ext(const char *filename)
e++;
- if (!dStrcasecmp(e, "gif")) {
+ if (!dStrAsciiCasecmp(e, "gif")) {
return "image/gif";
- } else if (!dStrcasecmp(e, "jpg") ||
- !dStrcasecmp(e, "jpeg")) {
+ } else if (!dStrAsciiCasecmp(e, "jpg") ||
+ !dStrAsciiCasecmp(e, "jpeg")) {
return "image/jpeg";
- } else if (!dStrcasecmp(e, "png")) {
+ } else if (!dStrAsciiCasecmp(e, "png")) {
return "image/png";
- } else if (!dStrcasecmp(e, "html") ||
- !dStrcasecmp(e, "htm") ||
- !dStrcasecmp(e, "shtml")) {
+ } else if (!dStrAsciiCasecmp(e, "html") ||
+ !dStrAsciiCasecmp(e, "htm") ||
+ !dStrAsciiCasecmp(e, "shtml")) {
return "text/html";
- } else if (!dStrcasecmp(e, "txt")) {
+ } else if (!dStrAsciiCasecmp(e, "txt")) {
return "text/plain";
} else {
return NULL;
@@ -712,7 +712,8 @@ static int File_send_file(ClientInfo *client)
/* Check for gzipped file */
namelen = strlen(client->filename);
- if (namelen > 3 && !dStrcasecmp(client->filename + namelen - 3, ".gz")) {
+ if (namelen > 3 &&
+ !dStrAsciiCasecmp(client->filename + namelen - 3, ".gz")) {
gzipped = TRUE;
namelen -= 3;
}
@@ -804,7 +805,7 @@ static char *File_normalize_path(const char *orig)
str += 5;
/* Skip "localhost" */
- if (dStrncasecmp(str, "//localhost/", 12) == 0)
+ if (dStrnAsciiCasecmp(str, "//localhost/", 12) == 0)
str += 11;
/* Skip packed slashes, and leave just one */
diff --git a/dpi/ftp.c b/dpi/ftp.c
index 3ddac10c..460c2f03 100644
--- a/dpi/ftp.c
+++ b/dpi/ftp.c
@@ -98,12 +98,12 @@ static int a_Misc_get_content_type_from_data2(void *Data, size_t Size,
/* 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 = 1;
st = 0;
diff --git a/dpi/https.c b/dpi/https.c
index bea9de10..c2becdae 100644
--- a/dpi/https.c
+++ b/dpi/https.c
@@ -360,9 +360,9 @@ static int get_network_connection(char * url)
char * url_look_up = NULL;
/*Determine how much of url we chop off as unneeded*/
- if (dStrncasecmp(url, "https://", 8) == 0){
+ if (dStrnAsciiCasecmp(url, "https://", 8) == 0){
url_offset = 8;
- } else if (dStrncasecmp(url, "http://", 7) == 0) {
+ } else if (dStrnAsciiCasecmp(url, "http://", 7) == 0) {
url_offset = 7;
portnum = 80;
}
diff --git a/dpid/dpid.c b/dpid/dpid.c
index d8bfeb96..ff95b702 100644
--- a/dpid/dpid.c
+++ b/dpid/dpid.c
@@ -845,7 +845,7 @@ int service_match(const struct service *A, const char *B)
if (A->name[A_len - 1] == '*')
len = A_len - 1;
- return(dStrncasecmp(A->name, B, len));
+ return(dStrnAsciiCasecmp(A->name, B, len));
}
/*!
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc
index 5c69a4ec..099c449c 100644
--- a/dw/fltkplatform.cc
+++ b/dw/fltkplatform.cc
@@ -141,7 +141,7 @@ FltkFont::~FltkFont ()
static void strstrip(char *big, const char *little)
{
if (strlen(big) >= strlen(little) &&
- strcasecmp(big + strlen(big) - strlen(little), little) == 0)
+ misc::AsciiStrcasecmp(big + strlen(big) - strlen(little), little) == 0)
*(big + strlen(big) - strlen(little)) = '\0';
}
diff --git a/dw/style.cc b/dw/style.cc
index 4a37801e..a2240a9e 100644
--- a/dw/style.cc
+++ b/dw/style.cc
@@ -889,10 +889,10 @@ static const char
*const roman_I2[] = { "","C","CC","CCC","CD","D","DC","DCC","DCCC","CM" },
*const roman_I3[] = { "","M","MM","MMM","MMMM" };
-static void strtolower (char *s)
+static void strAsciiTolower (char *s)
{
for ( ; *s; s++)
- *s = tolower (*s);
+ *s = misc::AsciiTolower (*s);
}
/**
@@ -947,7 +947,7 @@ void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType)
buf[buflen - 1] = '\0';
if (low)
- strtolower(buf);
+ strAsciiTolower(buf);
}
diff --git a/lout/misc.hh b/lout/misc.hh
index e78e7576..2a8584eb 100644
--- a/lout/misc.hh
+++ b/lout/misc.hh
@@ -43,6 +43,27 @@ inline int roundInt(double d)
return (int) ((d > 0) ? (d + 0.5) : (d - 0.5));
}
+inline int AsciiTolower(char c)
+{
+ return ((c >= 'A' && c <= 'Z') ? c + 0x20 : c);
+}
+
+inline int AsciiToupper(char c)
+{
+ return ((c >= 'a' && c <= 'z') ? c - 0x20 : c);
+}
+
+inline int AsciiStrcasecmp(const char *s1, const char *s2)
+{
+ int ret = 0;
+
+ while ((*s1 || *s2) && !(ret = AsciiTolower(*s1) - AsciiTolower(*s2))) {
+ s1++;
+ s2++;
+ }
+ return ret;
+}
+
/**
* \brief Instances of a sub class of this interface may be compared (less,
* greater).
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",
diff --git a/test/dw_anchors_test.cc b/test/dw_anchors_test.cc
index 10525f1a..cb839f40 100644
--- a/test/dw_anchors_test.cc
+++ b/test/dw_anchors_test.cc
@@ -69,14 +69,14 @@ static void textTimeout (void *data)
char buf[16];
strcpy (buf, numbers[textblockNo]);
- buf[0] = toupper (buf[0]);
+ buf[0] = lout::misc::AsciiToupper (buf[0]);
topTextblock->addText (buf, headingStyle);
topTextblock->addParbreak (5, headingStyle);
for (int i = 0; i < 30; i++) {
strcpy (buf, numbers[textblockNo]);
if (i == 0)
- buf[0] = toupper (buf[0]);
+ buf[0] = lout::misc::AsciiToupper (buf[0]);
strcat (buf, i == 29 ? "." : ",");
topTextblock->addText (buf, wordStyle);
@@ -109,7 +109,7 @@ int main(int argc, char **argv)
for (int i = 0; i < 10; i++) {
char buf[16];
strcpy (buf, numbers[i]);
- buf[0] = toupper (buf[0]);
+ buf[0] = lout::misc::AsciiToupper (buf[0]);
buttonLabel[i] = strdup(buf);
Fl_Button *button = new Fl_Button(0, 20 * i, 50, 20, buttonLabel[i]);
button->callback (anchorCallback, (void*)(long)i);