mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04:00
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.
This commit is contained in:
parent
6b7003bcc3
commit
607ee63b77
1 changed files with 8 additions and 7 deletions
15
url-mode.c
15
url-mode.c
|
|
@ -170,7 +170,7 @@ auto_detected(struct terminal *term, enum url_action action)
|
||||||
|
|
||||||
for (int c = 0; c < term->cols; c++) {
|
for (int c = 0; c < term->cols; c++) {
|
||||||
const struct cell *cell = &row->cells[c];
|
const struct cell *cell = &row->cells[c];
|
||||||
wchar_t wc = towlower(cell->wc);
|
wchar_t wc = cell->wc;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case STATE_PROTOCOL:
|
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];
|
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;
|
state = STATE_URL;
|
||||||
start = proto_start[max_prot_len - prot_len];
|
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;
|
bool emit_url = false;
|
||||||
switch (wc) {
|
switch (wc) {
|
||||||
case L'a'...L'z':
|
case L'a'...L'z':
|
||||||
|
case L'A'...L'Z':
|
||||||
case L'0'...L'9':
|
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'@': 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;
|
break;
|
||||||
|
|
||||||
case L'(':
|
case L'(':
|
||||||
parenthesis++;
|
parenthesis++;
|
||||||
url[len++] = cell->wc;
|
url[len++] = wc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L'[':
|
case L'[':
|
||||||
brackets++;
|
brackets++;
|
||||||
url[len++] = cell->wc;
|
url[len++] = wc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L')':
|
case L')':
|
||||||
if (--parenthesis < 0)
|
if (--parenthesis < 0)
|
||||||
emit_url = true;
|
emit_url = true;
|
||||||
else
|
else
|
||||||
url[len++] = cell->wc;
|
url[len++] = wc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L']':
|
case L']':
|
||||||
if (--brackets < 0)
|
if (--brackets < 0)
|
||||||
emit_url = true;
|
emit_url = true;
|
||||||
else
|
else
|
||||||
url[len++] = cell->wc;
|
url[len++] = wc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue