From 607ee63b77138acd3c366e1a746b6b97e03e0da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 4 Feb 2021 21:08:49 +0100 Subject: [PATCH] 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. --- url-mode.c | 15 ++++++++------- 1 file 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: