From 6d48fa438787d4171b4023215a25a490db1bb389 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Wed, 19 Dec 2001 21:50:22 +0000 Subject: [PATCH] Add (unsigned char) cast to ctype macros ftell->ftello, fseek->fseeko File 'newsize' type int->off_t Add visible (long) cast to fsize() when it called to small one message file and result is assigned to long. --- usr.bin/mail/aux.c | 4 ++-- usr.bin/mail/cmd2.c | 6 +++--- usr.bin/mail/collect.c | 8 ++++---- usr.bin/mail/edit.c | 2 +- usr.bin/mail/fio.c | 12 ++++++------ usr.bin/mail/head.c | 12 ++++++------ usr.bin/mail/lex.c | 10 +++++----- usr.bin/mail/list.c | 10 +++++----- usr.bin/mail/send.c | 4 ++-- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c index 4db5b8506d1e..2f735b1b2723 100644 --- a/usr.bin/mail/aux.c +++ b/usr.bin/mail/aux.c @@ -181,7 +181,7 @@ gethfield(f, linebuf, rem, colon) return (-1); if ((c = readline(f, linebuf, LINESIZE)) <= 0) return (-1); - for (cp = linebuf; isprint(*cp) && *cp != ' ' && *cp != ':'; + for (cp = linebuf; isprint((unsigned char)*cp) && *cp != ' ' && *cp != ':'; cp++) ; if (*cp != ':' || cp == linebuf) @@ -256,7 +256,7 @@ istrncpy(dest, src, dsize) strlcpy(dest, src, dsize); while (*dest) - *dest++ = tolower(*dest); + *dest++ = tolower((unsigned char)*dest); } /* diff --git a/usr.bin/mail/cmd2.c b/usr.bin/mail/cmd2.c index 5ab6b85a8d92..b25af303713c 100644 --- a/usr.bin/mail/cmd2.c +++ b/usr.bin/mail/cmd2.c @@ -249,7 +249,7 @@ snarf(linebuf, flag) * Strip away trailing blanks. */ - while (cp > linebuf && isspace(*cp)) + while (cp > linebuf && isspace((unsigned char)*cp)) cp--; *++cp = '\0'; @@ -257,13 +257,13 @@ snarf(linebuf, flag) * 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') { printf("No file specified.\n"); return (NULL); } - if (isspace(*cp)) + if (isspace((unsigned char)*cp)) *cp++ = '\0'; else *flag = 0; diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c index 4c42c9072cb1..6fc74935b158 100644 --- a/usr.bin/mail/collect.c +++ b/usr.bin/mail/collect.c @@ -248,7 +248,7 @@ collect(hp, printheaders) * Set the Subject line. */ cp = &linebuf[2]; - while (isspace(*cp)) + while (isspace((unsigned char)*cp)) cp++; hp->h_subject = savestr(cp); break; @@ -257,7 +257,7 @@ collect(hp, printheaders) * Set the Reply-To line. */ cp = &linebuf[2]; - while (isspace(*cp)) + while (isspace((unsigned char)*cp)) cp++; hp->h_replyto = savestr(cp); break; @@ -287,7 +287,7 @@ collect(hp, printheaders) * then open it and copy the contents to collf. */ cp = &linebuf[2]; - while (isspace(*cp)) + while (isspace((unsigned char)*cp)) cp++; if (*cp == '\0') { printf("Interpolate what file?\n"); @@ -563,7 +563,7 @@ forward(ms, fp, fn, f) tabst = NULL; else if ((tabst = value("indentprefix")) == NULL) tabst = "\t"; - ig = isupper(f) ? NULL : ignore; + ig = isupper((unsigned char)f) ? NULL : ignore; printf("Interpolating:"); for (; *msgvec != 0; msgvec++) { struct message *mp = message + *msgvec - 1; diff --git a/usr.bin/mail/edit.c b/usr.bin/mail/edit.c index e8d54deccb54..8e5e14abcf05 100644 --- a/usr.bin/mail/edit.c +++ b/usr.bin/mail/edit.c @@ -115,7 +115,7 @@ edit1(msgvec, type) size = ftello(otf); mp->m_block = blockof(size); mp->m_offset = boffsetof(size); - mp->m_size = fsize(fp); + mp->m_size = (long)fsize(fp); mp->m_lines = 0; mp->m_flag |= MODIFY; rewind(fp); diff --git a/usr.bin/mail/fio.c b/usr.bin/mail/fio.c index 0c78e3eb0a88..a10021b498d5 100644 --- a/usr.bin/mail/fio.c +++ b/usr.bin/mail/fio.c @@ -82,15 +82,15 @@ setptr(ibuf, offset) msgCount = 0; } else { /* Seek into the file to get to the new messages */ - (void)fseek(ibuf, offset, SEEK_SET); + (void)fseeko(ibuf, offset, SEEK_SET); /* * We need to make "offset" a pointer to the end of * the temp file that has the copy of the mail file. * If any messages have been edited, this will be * different from the offset into the mail file. */ - (void)fseek(otf, 0L, SEEK_END); - offset = ftell(otf); + (void)fseeko(otf, (off_t)0, SEEK_END); + offset = ftello(otf); } omsgCount = msgCount; maybe = 1; @@ -138,7 +138,7 @@ setptr(ibuf, offset) } else if (inhead) { for (cp = linebuf, cp2 = "status";; cp++) { if ((c = *cp2++) == '\0') { - while (isspace(*cp++)) + while (isspace((unsigned char)*cp++)) ; if (cp[-1] != ':') break; @@ -150,7 +150,7 @@ setptr(ibuf, offset) inhead = 0; break; } - if (*cp != c && *cp != toupper(c)) + if (*cp != c && *cp != toupper((unsigned char)c)) break; } } @@ -221,7 +221,7 @@ setinput(mp) (void)fflush(otf); if (fseeko(itf, positionof(mp->m_block, mp->m_offset), SEEK_SET) < 0) - err(1, "fseek"); + err(1, "fseeko"); return (itf); } diff --git a/usr.bin/mail/head.c b/usr.bin/mail/head.c index 806ab6dc7c12..61f43daec2c6 100644 --- a/usr.bin/mail/head.c +++ b/usr.bin/mail/head.c @@ -204,11 +204,11 @@ cmatch(cp, tp) while (*cp != '\0' && *tp != '\0') 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 ' ': @@ -216,20 +216,20 @@ cmatch(cp, 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; diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c index c7f674ce7b1f..46255b8f9d56 100644 --- a/usr.bin/mail/lex.c +++ b/usr.bin/mail/lex.c @@ -143,7 +143,7 @@ setfile(name) * the mail file, so reset mailsize to be where * we really are in the file... */ - mailsize = ftell(ibuf); + mailsize = ftello(ibuf); (void)Fclose(ibuf); relsesigs(); sawcom = 0; @@ -162,7 +162,7 @@ setfile(name) int incfile() { - int newsize; + off_t newsize; int omsgCount = msgCount; FILE *ibuf; @@ -179,7 +179,7 @@ incfile() return (0); /* no new mail */ setptr(ibuf, mailsize); setmsize(msgCount); - mailsize = ftell(ibuf); + mailsize = ftello(ibuf); (void)Fclose(ibuf); relsesigs(); return (msgCount - omsgCount); @@ -290,7 +290,7 @@ execute(linebuf, contxt) * lexical conventions. */ - for (cp = linebuf; isspace(*cp); cp++) + for (cp = linebuf; isspace((unsigned char)*cp); cp++) ; if (*cp == '!') { if (sourcing) { @@ -398,7 +398,7 @@ execute(linebuf, contxt) * Just the straight string, with * leading blanks removed. */ - while (isspace(*cp)) + while (isspace((unsigned char)*cp)) cp++; e = (*com->c_func)(cp); break; diff --git a/usr.bin/mail/list.c b/usr.bin/mail/list.c index 1dbc587ae174..be5df83f9f08 100644 --- a/usr.bin/mail/list.c +++ b/usr.bin/mail/list.c @@ -555,9 +555,9 @@ scan(sp) * Return TNUMBER when done. */ - if (isdigit(c)) { + if (isdigit((unsigned char)c)) { lexnumber = 0; - while (isdigit(c)) { + while (isdigit((unsigned char)c)) { lexnumber = lexnumber*10 + c - '0'; *cp2++ = c; c = *cp++; @@ -678,7 +678,7 @@ matchsender(str, mesg) while (*cp2 != '\0') { if (*cp == '\0') return (1); - if (toupper(*cp++) != toupper(*cp2++)) { + if (toupper((unsigned char)*cp++) != toupper((unsigned char)*cp2++)) { cp2 = ++backup; cp = str; } @@ -717,7 +717,7 @@ matchto(str, mesg) while (*cp2 != '\0') { if (*cp == '\0') return (1); - if (toupper(*cp++) != toupper(*cp2++)) { + if (toupper((unsigned char)*cp++) != toupper((unsigned char)*cp2++)) { cp2 = ++backup; cp = str; } @@ -775,7 +775,7 @@ matchsubj(str, mesg) while (*cp2 != '\0') { if (*cp == '\0') return (1); - if (toupper(*cp++) != toupper(*cp2++)) { + if (toupper((unsigned char)*cp++) != toupper((unsigned char)*cp2++)) { cp2 = ++backup; cp = str; } diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c index 58f029aea84b..7351cc55d6e6 100644 --- a/usr.bin/mail/send.c +++ b/usr.bin/mail/send.c @@ -123,10 +123,10 @@ sendmessage(mp, obuf, doign, prefix) * Pick up the header field if we have one. */ for (cp = line; (c = *cp++) != '\0' && c != ':' && - !isspace(c);) + !isspace((unsigned char)c);) ; cp2 = --cp; - while (isspace(*cp++)) + while (isspace((unsigned char)*cp++)) ; if (cp[-1] != ':') { /*