aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-04 20:08:49 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-07 15:33:33 +0000
commit607ee63b77138acd3c366e1a746b6b97e03e0da4 (patch)
treecce6112512492771e68d897e1318189e1ec7f83a
parenturl-mode: auto-detect: don’t store the lower-cased URL; use original casing (diff)
url-mode: auto-detect: use wcsncasecmp() instead of towlower()
When matching the URI scheme, use wcsncasecmp() when comparing the strings, instead of calling towlower() on each cell.
-rw-r--r--url-mode.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/url-mode.c b/url-mode.c
index 8d31908c..1b6dc9d8 100644
--- a/url-mode.c
+++ b/url-mode.c
@@ -170,7 +170,7 @@ auto_detected(struct terminal *term, enum url_action action)
for (int c = 0; c < term->cols; c++) {
const struct cell *cell = &row->cells[c];
- wchar_t wc = towlower(cell->wc);
+ wchar_t wc = cell->wc;
switch (state) {
case STATE_PROTOCOL:
@@ -194,7 +194,7 @@ auto_detected(struct terminal *term, enum url_action action)
const wchar_t *proto = &proto_chars[max_prot_len - prot_len];
- if (wcsncmp(prots[i], proto, prot_len) == 0) {
+ if (wcsncasecmp(prots[i], proto, prot_len) == 0) {
state = STATE_URL;
start = proto_start[max_prot_len - prot_len];
@@ -216,36 +216,37 @@ auto_detected(struct terminal *term, enum url_action action)
bool emit_url = false;
switch (wc) {
case L'a'...L'z':
+ case L'A'...L'Z':
case L'0'...L'9':
case L'-': case L'.': case L'_': case L'~': case L':':
case L'/': case L'?': case L'#': case L'@': case L'!':
case L'$': case L'&': case L'\'': case L'*': case L'+':
case L',': case L';': case L'=': case L'"':
- url[len++] = cell->wc;
+ url[len++] = wc;
break;
case L'(':
parenthesis++;
- url[len++] = cell->wc;
+ url[len++] = wc;
break;
case L'[':
brackets++;
- url[len++] = cell->wc;
+ url[len++] = wc;
break;
case L')':
if (--parenthesis < 0)
emit_url = true;
else
- url[len++] = cell->wc;
+ url[len++] = wc;
break;
case L']':
if (--brackets < 0)
emit_url = true;
else
- url[len++] = cell->wc;
+ url[len++] = wc;
break;
default: