ctype and other sign extension fixes.
authorokan <okan@openbsd.org>
Fri, 17 Jan 2014 18:42:30 +0000 (18:42 +0000)
committerokan <okan@openbsd.org>
Fri, 17 Jan 2014 18:42:30 +0000 (18:42 +0000)
with deraadt and millert, ok millert

usr.bin/mail/aux.c
usr.bin/mail/cmd2.c
usr.bin/mail/collect.c
usr.bin/mail/fio.c
usr.bin/mail/head.c
usr.bin/mail/lex.c
usr.bin/mail/list.c
usr.bin/mail/send.c
usr.bin/mail/tty.c

index c401def..3c6e961 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: aux.c,v 1.25 2009/10/27 23:59:40 deraadt Exp $        */
+/*     $OpenBSD: aux.c,v 1.26 2014/01/17 18:42:30 okan Exp $   */
 /*     $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $    */
 
 /*
@@ -160,8 +160,9 @@ gethfield(FILE *f, char *linebuf, int rem, char **colon)
                        return(-1);
                if ((c = readline(f, linebuf, LINESIZE, NULL)) <= 0)
                        return(-1);
-               for (cp = linebuf; isprint(*cp) && *cp != ' ' && *cp != ':';
-                    cp++)
+               for (cp = linebuf;
+                   isprint((unsigned char)*cp) && *cp != ' ' && *cp != ':';
+                   cp++)
                        ;
                if (*cp != ':' || cp == linebuf)
                        continue;
@@ -233,7 +234,7 @@ istrlcpy(char *dst, const char *src, size_t dsize)
        /* Copy as many bytes as will fit */
        if (n != 0 && --n != 0) {
                do {
-                       if ((*d++ = tolower(*s++)) == 0)
+                       if ((*d++ = tolower((unsigned char)*s++)) == 0)
                                break;
                } while (--n != 0);
        }
@@ -427,7 +428,7 @@ skin(char *name)
        gotlt = 0;
        lastsp = 0;
        bufend = nbuf;
-       for (cp = name, cp2 = bufend; (c = *cp++) != '\0'; ) {
+       for (cp = name, cp2 = bufend; (c = (unsigned char)*cp++) != '\0'; ) {
                switch (c) {
                case '(':
                        cp = skip_comment(cp);
@@ -439,13 +440,13 @@ skin(char *name)
                         * Start of a "quoted-string".
                         * Copy it in its entirety.
                         */
-                       while ((c = *cp) != '\0') {
+                       while ((c = (unsigned char)*cp) != '\0') {
                                cp++;
                                if (c == '"')
                                        break;
                                if (c != '\\')
                                        *cp2++ = c;
-                               else if ((c = *cp) != '\0') {
+                               else if ((c = (unsigned char)*cp) != '\0') {
                                        *cp2++ = c;
                                        cp++;
                                }
@@ -472,12 +473,12 @@ skin(char *name)
                case '>':
                        if (gotlt) {
                                gotlt = 0;
-                               while ((c = *cp) && c != ',') {
+                               while ((c = (unsigned char)*cp) && c != ',') {
                                        cp++;
                                        if (c == '(')
                                                cp = skip_comment(cp);
                                        else if (c == '"')
-                                               while ((c = *cp) != '\0') {
+                                               while ((c = (unsigned char)*cp) != '\0') {
                                                        cp++;
                                                        if (c == '"')
                                                                break;
index 3a47287..6a2eae2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cmd2.c,v 1.19 2012/11/14 13:22:37 gsoares Exp $       */
+/*     $OpenBSD: cmd2.c,v 1.20 2014/01/17 18:42:30 okan Exp $  */
 /*     $NetBSD: cmd2.c,v 1.7 1997/05/17 19:55:10 pk Exp $      */
 
 /*
@@ -224,20 +224,20 @@ snarf(char *linebuf, int *flag)
        /*
         * Strip away trailing blanks.
         */
-       while (cp > linebuf && isspace(*cp))
+       while (cp > linebuf && isspace((unsigned char)*cp))
                cp--;
        *++cp = 0;
 
        /*
         * Now search for the beginning of the file name.
         */
-       while (cp > linebuf && !isspace(*cp))
+       while (cp > linebuf && !isspace((unsigned char)*cp))
                cp--;
        if (*cp == '\0') {
                puts("No file specified.");
                return(NULL);
        }
-       if (isspace(*cp))
+       if (isspace((unsigned char)*cp))
                *cp++ = 0;
        else
                *flag = 0;
index 204dc36..930d9a1 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: collect.c,v 1.33 2011/04/06 11:36:26 miod Exp $       */
+/*     $OpenBSD: collect.c,v 1.34 2014/01/17 18:42:30 okan Exp $       */
 /*     $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $        */
 
 /*
@@ -155,7 +155,7 @@ cont:
                                goto err;
                        continue;
                }
-               c = linebuf[1];
+               c = (unsigned char)linebuf[1];
                switch (c) {
                default:
                        /*
@@ -221,7 +221,7 @@ cont:
                         * Set the Subject list.
                         */
                        cp = &linebuf[2];
-                       while (isspace(*cp))
+                       while (isspace((unsigned char)*cp))
                                cp++;
                        hp->h_subject = savestr(cp);
                        break;
@@ -249,7 +249,7 @@ cont:
                         * then open it and copy the contents to collf.
                         */
                        cp = &linebuf[2];
-                       while (isspace(*cp))
+                       while (isspace((unsigned char)*cp))
                                cp++;
                        if (*cp == '\0') {
                                puts("Interpolate what file?");
index 2de727c..205ce36 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: fio.c,v 1.32 2009/10/27 23:59:40 deraadt Exp $        */
+/*     $OpenBSD: fio.c,v 1.33 2014/01/17 18:42:30 okan Exp $   */
 /*     $NetBSD: fio.c,v 1.8 1997/07/07 22:57:55 phil Exp $     */
 
 /*
@@ -140,12 +140,12 @@ setptr(FILE *ibuf, off_t offset)
                        inhead = 0;
                } else if (inhead) {
                        for (cp = linebuf, cp2 = "status";; cp++) {
-                               if ((c = *cp2++) == 0) {
+                               if ((c = (unsigned char)*cp2++) == 0) {
                                        while (isspace(*cp++))
                                                ;
                                        if (cp[-1] != ':')
                                                break;
-                                       while ((c = *cp++) != '\0')
+                                       while ((c = (unsigned char)*cp++) != '\0')
                                                if (c == 'R')
                                                        this.m_flag |= MREAD;
                                                else if (c == 'O')
index 97fefc2..3043e5c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: head.c,v 1.11 2009/10/27 23:59:40 deraadt Exp $       */
+/*     $OpenBSD: head.c,v 1.12 2014/01/17 18:42:30 okan Exp $  */
 /*     $NetBSD: head.c,v 1.6 1996/12/28 07:11:03 tls Exp $     */
 
 /*
@@ -195,11 +195,11 @@ cmatch(char *cp, char *tp)
        while (*cp && *tp)
                switch (*tp++) {
                case 'a':
-                       if (!islower(*cp++))
+                       if (!islower((unsigned char)*cp++))
                                return(0);
                        break;
                case 'A':
-                       if (!isupper(*cp++))
+                       if (!isupper((unsigned char)*cp++))
                                return(0);
                        break;
                case ' ':
@@ -207,20 +207,20 @@ cmatch(char *cp, char *tp)
                                return(0);
                        break;
                case '0':
-                       if (!isdigit(*cp++))
+                       if (!isdigit((unsigned char)*cp++))
                                return(0);
                        break;
                case 'O':
-                       if (*cp != ' ' && !isdigit(*cp))
+                       if (*cp != ' ' && !isdigit((unsigned char)*cp))
                                return(0);
                        cp++;
                        break;
                case 'p':
-                       if (!ispunct(*cp++))
+                       if (!ispunct((unsigned char)*cp++))
                                return(0);
                        break;
                case 'P':
-                       if (*cp != ' ' && !ispunct(*cp))
+                       if (*cp != ' ' && !ispunct((unsigned char)*cp))
                                return(0);
                        cp++;
                        break;
@@ -252,10 +252,10 @@ nextword(char *wp, char *wbuf)
                *wbuf = 0;
                return(NULL);
        }
-       while ((c = *wp++) && c != ' ' && c != '\t') {
+       while ((c = (unsigned char)*wp++) && c != ' ' && c != '\t') {
                *wbuf++ = c;
                if (c == '"') {
-                       while ((c = *wp++) && c != '"')
+                       while ((c = (unsigned char)*wp++) && c != '"')
                                *wbuf++ = c;
                        if (c == '"')
                                *wbuf++ = c;
@@ -264,7 +264,7 @@ nextword(char *wp, char *wbuf)
                }
        }
        *wbuf = '\0';
-       for (; c == ' ' || c == '\t'; c = *wp++)
+       for (; c == ' ' || c == '\t'; c = (unsigned char)*wp++)
                ;
        if (c == 0)
                return(NULL);
index ba19d21..11789bd 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: lex.c,v 1.35 2013/04/29 00:28:23 okan Exp $   */
+/*     $OpenBSD: lex.c,v 1.36 2014/01/17 18:42:30 okan Exp $   */
 /*     $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $      */
 
 /*
@@ -302,7 +302,7 @@ execute(char *linebuf, int contxt)
         * Handle ! escapes differently to get the correct
         * lexical conventions.
         */
-       for (cp = linebuf; isspace(*cp); cp++)
+       for (cp = linebuf; isspace((unsigned char)*cp); cp++)
                ;
        if (*cp == '!') {
                if (sourcing) {
@@ -313,7 +313,8 @@ execute(char *linebuf, int contxt)
                return(0);
        }
        cp2 = word;
-       while (*cp && strchr(" \t0123456789$^.:/-+*'\"", *cp) == NULL)
+       while (*cp &&
+               strchr(" \t0123456789$^.:/-+*'\"", (unsigned char)*cp) == NULL)
                *cp2++ = *cp++;
        *cp2 = '\0';
 
@@ -378,17 +379,17 @@ execute(char *linebuf, int contxt)
                /*
                 * remove leading blanks.
                 */
-               while (isspace(*cp))
+               while (isspace((unsigned char)*cp))
                        cp++;
 
-               if (isdigit(*cp) || *cp == ':') {
+               if (isdigit((unsigned char)*cp) || *cp == ':') {
                        if ((c = getmsglist(cp, msgvec, com->c_msgflag)) < 0)
                                break;
                        /* position to next space - past the message list */
-                       while (!isspace(*cp))
+                       while (!isspace((unsigned char)*cp))
                                cp++;
                        /* position to next non-space */
-                       while (isspace(*cp))
+                       while (isspace((unsigned char)*cp))
                                cp++;
                } else {
                        c = 0; /* no message list */
@@ -407,7 +408,7 @@ execute(char *linebuf, int contxt)
                 * Just the straight string, with
                 * leading blanks removed.
                 */
-               while (isspace(*cp))
+               while (isspace((unsigned char)*cp))
                        cp++;
 
                e = (*com->c_func2)(msgvec, cp);
@@ -455,7 +456,7 @@ execute(char *linebuf, int contxt)
                 * Just the straight string, with
                 * leading blanks removed.
                 */
-               while (isspace(*cp))
+               while (isspace((unsigned char)*cp))
                        cp++;
                e = (*com->c_func)(cp);
                break;
index cfdb17e..6be696f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: list.c,v 1.18 2009/10/27 23:59:40 deraadt Exp $       */
+/*     $OpenBSD: list.c,v 1.19 2014/01/17 18:42:30 okan Exp $  */
 /*     $NetBSD: list.c,v 1.7 1997/07/09 05:23:36 mikel Exp $   */
 
 /*
@@ -509,13 +509,13 @@ scan(char **sp)
        }
        cp = *sp;
        cp2 = lexstring;
-       c = *cp++;
+       c = (unsigned char)*cp++;
 
        /*
         * strip away leading white space.
         */
        while (c == ' ' || c == '\t')
-               c = *cp++;
+               c = (unsigned char)*cp++;
 
        /*
         * If no characters remain, we are at end of line,
@@ -537,7 +537,7 @@ scan(char **sp)
                        lexnumber = lexnumber*10 + c - '0';
                        if (cp2 - lexstring < STRINGLEN - 1)
                                *cp2++ = c;
-                       c = *cp++;
+                       c = (unsigned char)*cp++;
                }
                *cp2 = '\0';
                *sp = --cp;
@@ -566,7 +566,7 @@ scan(char **sp)
        quotec = 0;
        if (c == '\'' || c == '"') {
                quotec = c;
-               c = *cp++;
+               c = (unsigned char)*cp++;
        }
        while (c != '\0') {
                if (c == quotec) {
@@ -577,7 +577,7 @@ scan(char **sp)
                        break;
                if (cp2 - lexstring < STRINGLEN-1)
                        *cp2++ = c;
-               c = *cp++;
+               c = (unsigned char)*cp++;
        }
        if (quotec && c == 0) {
                fprintf(stderr, "Missing %c\n", quotec);
index 6f0dc51..f8fdac9 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: send.c,v 1.22 2009/10/27 23:59:40 deraadt Exp $       */
+/*     $OpenBSD: send.c,v 1.23 2014/01/17 18:42:30 okan Exp $  */
 /*     $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $        */
 
 /*
@@ -130,10 +130,11 @@ sendmessage(struct message *mp, FILE *obuf, struct ignoretab *doign,
                        /*
                         * Pick up the header field if we have one.
                         */
-                       for (cp = line; (c = *cp++) && c != ':' && !isspace(c);)
+                       for (cp = line;
+                           (c = (unsigned char)*cp++) && c != ':' && !isspace(c); )
                                ;
                        cp2 = --cp;
-                       while (isspace(*cp++))
+                       while (isspace((unsigned char)*cp++))
                                ;
                        if (cp[-1] != ':') {
                                /*
index 8adc37a..1942814 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: tty.c,v 1.19 2009/10/27 23:59:40 deraadt Exp $        */
+/*     $OpenBSD: tty.c,v 1.20 2014/01/17 18:42:30 okan Exp $   */
 /*     $NetBSD: tty.c,v 1.7 1997/07/09 05:25:46 mikel Exp $    */
 
 /*
@@ -196,7 +196,7 @@ readtty(char *pr, char *src)
        fflush(stdout);
 #else
        cp = src == NULL ? "" : src;
-       while ((c = *cp++) != '\0') {
+       while ((c = (unsigned char)*cp++) != '\0') {
                if ((c_erase != _POSIX_VDISABLE && c == c_erase) ||
                    (c_kill != _POSIX_VDISABLE && c == c_kill)) {
                        ch = '\\';
@@ -262,7 +262,7 @@ redo:
        if (!ttyset)
                return(strlen(canonb) > 0 ? savestr(canonb) : NULL);
        while (*cp != '\0') {
-               c = *cp++;
+               c = (unsigned char)*cp++;
                if (c_erase != _POSIX_VDISABLE && c == c_erase) {
                        if (cp2 == canonb)
                                continue;