summaryrefslogtreecommitdiff
path: root/src/selection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/selection.c')
-rw-r--r--src/selection.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/selection.c b/src/selection.c
index 6f7336f..0eda34f 100644
--- a/src/selection.c
+++ b/src/selection.c
@@ -38,7 +38,15 @@ static char *link_at_text(const struct term *t, struct term_vector2i cell)
char *out = NULL;
if (url && col >= start + (int)(url - text)) {
size_t n = strlen(url);
- while (n && strchr(".,;:!?)]}>\"'", url[n - 1])) url[--n] = 0;
+ /* Bitmask matching trailing punctuation characters: .,;:!?)]}>"' */
+ static const uint64_t mask[4] = {
+ 0xCC00528600000000ULL,
+ 0x2000000020000000ULL,
+ 0ULL,
+ 0ULL
+ };
+ while (n && (mask[(unsigned char)url[n - 1] >> 6] & (1ULL << ((unsigned char)url[n - 1] & 63))))
+ url[--n] = 0;
if (col < start + (int)(url - text) + (int)n && n > scheme)
out = term_strdup(url);
}