vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit a5d6806459fe051f4bc57b3c8d43dc704801f8be
parent 2d49922181aee518d1b3d8d5489ca012a3277111
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun, 19 Oct 2014 12:33:57 +0200

Only cast once in op_case_change

Diffstat:
Mvis.c | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/vis.c b/vis.c @@ -615,15 +615,14 @@ static void op_case_change(OperatorContext *c) { len = text_bytes_get(vis->win->text, c->range.start, len, buf); size_t rem = len; for (char *cur = buf; rem > 0; cur++, rem--) { - if (isascii((unsigned char)*cur)) { - if (c->arg->i == 0) { - *cur = islower((unsigned char)*cur) ? - toupper((unsigned char)*cur) : - tolower((unsigned char)*cur) ; - } else if (c->arg->i > 0) - *cur = toupper((unsigned char)*cur); + int ch = (unsigned char)*cur; + if (isascii(ch)) { + if (c->arg->i == 0) + *cur = islower(ch) ? toupper(ch) : tolower(ch); + else if (c->arg->i > 0) + *cur = toupper(ch); else - *cur = tolower((unsigned char)*cur); + *cur = tolower(ch); } }