Introduce an unsigned char variable for the ctype function calls.
authormmcc <mmcc@openbsd.org>
Thu, 15 Oct 2015 19:36:50 +0000 (19:36 +0000)
committermmcc <mmcc@openbsd.org>
Thu, 15 Oct 2015 19:36:50 +0000 (19:36 +0000)
ok millert@

bin/ksh/vi.c

index 6888204..8c6c98e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vi.c,v 1.33 2015/09/18 07:28:24 nicm Exp $    */
+/*     $OpenBSD: vi.c,v 1.34 2015/10/15 19:36:50 mmcc Exp $    */
 
 /*
  *     vi command editing
@@ -1082,18 +1082,20 @@ vi_cmd(int argcnt, const char *cmd)
 
                case '~': {
                        char    *p;
+                       unsigned char c;
                        int     i;
 
                        if (es->linelen == 0)
                                return -1;
                        for (i = 0; i < argcnt; i++) {
                                p = &es->cbuf[es->cursor];
-                               if (islower((unsigned char)*p)) {
+                               c = (unsigned char)*p;
+                               if (islower(c)) {
                                        modified = 1; hnum = hlast;
-                                       *p = toupper(*p);
-                               } else if (isupper((unsigned char)*p)) {
+                                       *p = toupper(c);
+                               } else if (isupper(c)) {
                                        modified = 1; hnum = hlast;
-                                       *p = tolower(*p);
+                                       *p = tolower(c);
                                }
                                if (es->cursor < es->linelen - 1)
                                        es->cursor++;