=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mail/lex.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- src/usr.bin/mail/lex.c 2001/11/20 20:50:00 1.25 +++ src/usr.bin/mail/lex.c 2001/11/21 15:26:39 1.26 @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.25 2001/11/20 20:50:00 millert Exp $ */ +/* $OpenBSD: lex.c,v 1.26 2001/11/21 15:26:39 millert Exp $ */ /* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */ /* @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95"; +static const char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: lex.c,v 1.25 2001/11/20 20:50:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: lex.c,v 1.26 2001/11/21 15:26:39 millert Exp $"; #endif #endif /* not lint */ @@ -64,8 +64,7 @@ * signficance for mbox and so forth. */ int -setfile(name) - char *name; +setfile(char *name) { FILE *ibuf; int i, fd; @@ -114,7 +113,6 @@ * while we are reading the new file, else we will ruin * the message[] data structure. */ - holdsigs(); if (shudclob) quit(); @@ -123,9 +121,8 @@ * Copy the messages into /tmp * and set pointers. */ - readonly = 0; - if ((i = open(name, 1)) < 0) + if ((i = open(name, O_WRONLY, 0)) < 0) readonly++; else (void)close(i); @@ -136,10 +133,8 @@ shudclob = 1; edit = isedit; strcpy(prevfile, mailname); - if (name != mailname) { - strncpy(mailname, name, sizeof(mailname) - 1); - mailname[sizeof(mailname) - 1] = '\0'; - } + if (name != mailname) + strlcpy(mailname, name, sizeof(mailname)); mailsize = fsize(ibuf); (void)snprintf(tempname, sizeof(tempname), "%s/mail.RxXXXXXXXXXX", tmpdir); @@ -175,7 +170,7 @@ * started reading mail. */ int -incfile() +incfile(void) { int newsize; int omsgCount = msgCount; @@ -216,7 +211,7 @@ * print no prompt. */ void -commands() +commands(void) { int n, sig, *sigp; int eofloop = 0; @@ -301,9 +296,7 @@ * Contxt is non-zero if called while composing mail. */ int -execute(linebuf, contxt) - char linebuf[]; - int contxt; +execute(char *linebuf, int contxt) { char word[LINESIZE]; char *arglist[MAXARGC]; @@ -321,7 +314,6 @@ * Handle ! escapes differently to get the correct * lexical conventions. */ - for (cp = linebuf; isspace(*cp); cp++) ; if (*cp == '!') { @@ -344,11 +336,10 @@ * however, we ignore blank lines to eliminate * confusion. */ - if (sourcing && *word == '\0') return(0); com = lex(word); - if (com == NONE) { + if (com == NULL) { printf("Unknown command: \"%s\"\n", word); goto out; } @@ -357,7 +348,6 @@ * See if we should execute the command -- if a conditional * we always execute it, otherwise, check the state of cond. */ - if ((com->c_argtype & F) == 0) if ((cond == CRCV && !rcvmode) || (cond == CSEND && rcvmode)) return(0); @@ -368,7 +358,6 @@ * If we are sourcing an interactive command, it's * an error. */ - if (!rcvmode && (com->c_argtype & M) == 0) { printf("May not execute \"%s\" while sending\n", com->c_name); @@ -547,8 +536,7 @@ * lists to message list functions. */ void -setmsize(sz) - int sz; +setmsize(int sz) { if (msgvec != 0) @@ -562,8 +550,7 @@ */ const struct cmd * -lex(word) - char word[]; +lex(char *word) { extern const struct cmd cmdtab[]; const struct cmd *cp; @@ -573,7 +560,7 @@ for (cp = &cmdtab[0]; cp->c_name != NULL; cp++) if (isprefix(word, cp->c_name)) return(cp); - return(NONE); + return(NULL); } /* @@ -581,8 +568,7 @@ * Return true if yep. */ int -isprefix(as1, as2) - char *as1, *as2; +isprefix(char *as1, char *as2) { char *s1, *s2; @@ -601,11 +587,10 @@ * Close all open files except 0, 1, 2, and the temporary. * Also, unstack all source files. */ - int inithdr; /* am printing startup headers */ void -dointr() +dointr(void) { noreset = 0; @@ -629,7 +614,7 @@ * give the message count, and print a header listing. */ void -announce() +announce(void) { int vec[2], mdot; @@ -649,8 +634,7 @@ * Return a likely place to set dot. */ int -newfileinfo(omsgCount) - int omsgCount; +newfileinfo(int omsgCount) { struct message *mp; int u, n, mdot, d, s; @@ -680,7 +664,7 @@ } ename = mailname; if (getfold(fname, sizeof(fname)) >= 0) { - strncat(fname, "/", sizeof(fname) - strlen(fname) - 1); + strlcat(fname, "/", sizeof(fname)); if (strncmp(fname, mailname, strlen(fname)) == 0) { (void)snprintf(zname, sizeof(zname), "+%s", mailname + strlen(fname)); @@ -709,13 +693,11 @@ /* * Print the current version number. */ - /*ARGSUSED*/ int -pversion(v) - void *v; +pversion(void *v) { - extern char *version; + extern const char version[]; printf("Version %s\n", version); return(0); @@ -725,8 +707,7 @@ * Load a file of user definitions. */ void -load(name) - char *name; +load(char *name) { FILE *in, *oldin;