Delint (partially).

This commit is contained in:
mycroft 1998-07-28 02:23:37 +00:00
parent 2c49105697
commit cdbd74da57
18 changed files with 503 additions and 217 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: alloc.c,v 1.7 1997/07/04 21:23:51 christos Exp $ */
/* $NetBSD: alloc.c,v 1.8 1998/07/28 02:23:37 mycroft Exp $ */
/*-
* Copyright (c) 1983, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)alloc.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: alloc.c,v 1.7 1997/07/04 21:23:51 christos Exp $");
__RCSID("$NetBSD: alloc.c,v 1.8 1998/07/28 02:23:37 mycroft Exp $");
#endif
#endif /* not lint */
@ -68,6 +68,7 @@ Malloc(n)
if ((ptr = malloc(n)) == (ptr_t) 0) {
child++;
stderror(ERR_NOMEM);
/* NOTREACHED */
}
return (ptr);
}
@ -84,6 +85,7 @@ Realloc(p, n)
if ((ptr = realloc(p, n)) == (ptr_t) 0) {
child++;
stderror(ERR_NOMEM);
/* NOTREACHED */
}
return (ptr);
}
@ -99,6 +101,7 @@ Calloc(s, n)
if ((ptr = calloc(s, n)) == (ptr_t) 0) {
child++;
stderror(ERR_NOMEM);
/* NOTREACHED */
}
return (ptr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: csh.c,v 1.20 1998/07/27 15:32:04 mycroft Exp $ */
/* $NetBSD: csh.c,v 1.21 1998/07/28 02:23:37 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993\n\
#if 0
static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93";
#else
__RCSID("$NetBSD: csh.c,v 1.20 1998/07/27 15:32:04 mycroft Exp $");
__RCSID("$NetBSD: csh.c,v 1.21 1998/07/28 02:23:37 mycroft Exp $");
#endif
#endif /* not lint */
@ -321,8 +321,10 @@ main(argc, argv)
break;
case 'c': /* -c Command input from arg */
if (argc == 1)
if (argc == 1) {
xexit(0);
/* NOTREACHED */
}
argc--, tempv++;
arginp = SAVE(tempv[0]);
prompt = 0;
@ -397,6 +399,7 @@ main(argc, argv)
if (nofile < 0) {
child = 1; /* So this doesn't return */
stderror(ERR_SYSTEM, tempv[0], strerror(errno));
/* NOTREACHED */
}
ffile = SAVE(tempv[0]);
/*
@ -417,7 +420,7 @@ main(argc, argv)
break;
default:
stderror(ERR_SYSTEM, tempv[0], strerror(errno));
break;
/* NOTREACHED */
}
(void) ioctl(SHIN, FIOCLEX, NULL);
prompt = 0;
@ -431,6 +434,7 @@ main(argc, argv)
errno = EACCES;
child = 1; /* So this doesn't return */
stderror(ERR_SYSTEM, "csh", strerror(errno));
/* NOTREACHED */
}
}
/*
@ -605,7 +609,7 @@ notty:
}
rechist();
exitstat();
return (0);
/* NOTREACHED */
}
void
@ -797,8 +801,10 @@ srcunit(unit, onlyown, hflg)
/*
* If process reset() (effectively an unwind) then we must also unwind.
*/
if (my_reenter)
if (my_reenter) {
stderror(ERR_SILENT);
/* NOTREACHED */
}
insource = oinsource;
}
@ -865,9 +871,10 @@ goodbye()
(void) srccat(value(STRhome), STRsldtlogout);
}
exitstat();
/* NOTREACHED */
}
void
__dead void
exitstat()
{
Char *s;
@ -882,6 +889,7 @@ exitstat()
child = 1;
s = value(STRstatus);
xexit(s ? getn(s) : 0);
/* NOTREACHED */
}
/*
@ -924,6 +932,7 @@ int sig;
}
}
xexit(sig);
/* NOTREACHED */
}
Char *jobargv[2] = {STRjobs, 0};
@ -961,6 +970,7 @@ pintr1(wantnl)
(void) fprintf(cshout, "\n");
dojobs(jobargv, NULL);
stderror(ERR_NAME | ERR_INTR);
/* NOTREACHED */
}
}
sigdelset(&osigset, SIGCHLD);
@ -987,6 +997,7 @@ pintr1(wantnl)
(void) fputc('\n', cshout);
}
stderror(ERR_SILENT);
/* NOTREACHED */
}
/*
@ -1107,8 +1118,10 @@ process(catch)
/*
* Print lexical error messages, except when sourcing history lists.
*/
if (!enterhist && seterr)
if (!enterhist && seterr) {
stderror(ERR_OLD);
/* NOTREACHED */
}
/*
* If had a history command :p modifier then this is as far as we
@ -1123,8 +1136,10 @@ process(catch)
* Parse the words of the input into a parse tree.
*/
savet = syntax(paraml.next, &paraml, 0);
if (seterr)
if (seterr) {
stderror(ERR_OLD);
/* NOTREACHED */
}
execute(savet, (tpgrp > 0 ? tpgrp : -1), NULL, NULL);
@ -1151,16 +1166,20 @@ dosource(v, t)
v++;
if (*v && eq(*v, STRmh)) {
if (*++v == NULL)
if (*++v == NULL) {
stderror(ERR_NAME | ERR_HFLAG);
/* NOTREACHED */
}
hflg++;
}
(void) Strcpy(buf, *v);
f = globone(buf, G_ERROR);
(void) strcpy((char *) buf, short2str(f));
xfree((ptr_t) f);
if (!srcfile((char *) buf, 0, hflg) && !hflg)
if (!srcfile((char *) buf, 0, hflg) && !hflg) {
stderror(ERR_SYSTEM, (char *) buf, strerror(errno));
/* NOTREACHED */
}
}
/*
@ -1324,7 +1343,7 @@ initdesc()
}
void
__dead void
#ifdef PROF
done(i)
#else
@ -1334,6 +1353,7 @@ xexit(i)
{
untty();
_exit(i);
/* NOTREACHED */
}
#ifndef _PATH_DEFPATH

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.12 1998/07/27 15:32:04 mycroft Exp $ */
/* $NetBSD: dir.c,v 1.13 1998/07/28 02:23:38 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: dir.c,v 1.12 1998/07/27 15:32:04 mycroft Exp $");
__RCSID("$NetBSD: dir.c,v 1.13 1998/07/28 02:23:38 mycroft Exp $");
#endif
#endif /* not lint */
@ -103,9 +103,11 @@ dinit(hp)
cp = NULL;
if (cp == NULL) {
(void) fprintf(csherr, emsg, "/");
if (chdir("/") == -1)
if (chdir("/") == -1) {
/* I am not even try to print an error message! */
xexit(1);
/* NOTREACHED */
}
cp = SAVE("/");
}
}
@ -185,7 +187,7 @@ skipargs(v, str)
break;
default:
stderror(ERR_DIRUS, vis_str(**v), str);
break;
/* NOTREACHED */
}
*v = n;
}
@ -201,8 +203,10 @@ dodirs(v, t)
{
skipargs(&v, "");
if (*v != NULL)
if (*v != NULL) {
stderror(ERR_DIRUS, "dirs", "");
/* NOTREACHED */
}
printdirs();
}
@ -311,13 +315,15 @@ dnormalize(cp)
else
break;
}
while (dotdot > 0)
if ((dp = Strrchr(cwd, '/'))) {
while (dotdot > 0) {
dp = Strrchr(cwd, '/');
if (dp) {
*dp = '\0';
dotdot--;
}
else
break;
}
if (*cp) {
cwd[dotdot = Strlen(cwd)] = '/';
@ -352,23 +358,28 @@ dochngd(v, t)
skipargs(&v, " [<dir>]");
printd = 0;
if (*v == NULL) {
if ((cp = value(STRhome)) == NULL || *cp == 0)
if ((cp = value(STRhome)) == NULL || *cp == 0) {
stderror(ERR_NAME | ERR_NOHOMEDIR);
if (chdir(short2str(cp)) < 0)
/* NOTREACHED */
}
if (chdir(short2str(cp)) < 0) {
stderror(ERR_NAME | ERR_CANTCHANGE);
/* NOTREACHED */
}
cp = Strsave(cp);
}
else if (v[1] != NULL) {
stderror(ERR_NAME | ERR_TOOMANY);
/* NOTREACHED */
return;
}
else if ((dp = dfind(*v)) != 0) {
char *tmp;
printd = 1;
if (chdir(tmp = short2str(dp->di_name)) < 0)
if (chdir(tmp = short2str(dp->di_name)) < 0) {
stderror(ERR_SYSTEM, tmp, strerror(errno));
/* NOTREACHED */
}
dcwd->di_prev->di_next = dcwd->di_next;
dcwd->di_next->di_prev = dcwd->di_prev;
dfree(dcwd);
@ -482,7 +493,7 @@ dfollow(cp)
(void) strcpy(ebuf, short2str(cp));
xfree((ptr_t) cp);
stderror(ERR_SYSTEM, ebuf, strerror(serrno));
return (NULL);
/* NOTREACHED */
}
@ -506,8 +517,10 @@ dopushd(v, t)
if ((dp = dcwd->di_prev) == &dhead)
dp = dhead.di_prev;
if (dp == dcwd)
if (dp == dcwd) {
stderror(ERR_NAME | ERR_NODIR);
/* NOTREACHED */
}
if (chdir(tmp = short2str(dp->di_name)) < 0)
stderror(ERR_SYSTEM, tmp, strerror(errno));
dp->di_prev->di_next = dp->di_next;
@ -520,13 +533,14 @@ dopushd(v, t)
else if (v[1] != NULL) {
stderror(ERR_NAME | ERR_TOOMANY);
/* NOTREACHED */
return;
}
else if ((dp = dfind(*v)) != NULL) {
char *tmp;
if (chdir(tmp = short2str(dp->di_name)) < 0)
if (chdir(tmp = short2str(dp->di_name)) < 0) {
stderror(ERR_SYSTEM, tmp, strerror(errno));
/* NOTREACHED */
}
}
else {
Char *ccp;
@ -566,8 +580,10 @@ dfind(cp)
for (dp = dcwd; i != 0; i--) {
if ((dp = dp->di_prev) == &dhead)
dp = dp->di_prev;
if (dp == dcwd)
if (dp == dcwd) {
stderror(ERR_NAME | ERR_DEEP);
/* NOTREACHED */
}
}
return (dp);
}
@ -591,19 +607,24 @@ dopopd(v, t)
else if (v[1] != NULL) {
stderror(ERR_NAME | ERR_TOOMANY);
/* NOTREACHED */
return;
}
else if ((dp = dfind(*v)) == 0)
else if ((dp = dfind(*v)) == 0) {
stderror(ERR_NAME | ERR_BADDIR);
if (dp->di_prev == &dhead && dp->di_next == &dhead)
/* NOTREACHED */
}
if (dp->di_prev == &dhead && dp->di_next == &dhead) {
stderror(ERR_NAME | ERR_EMPTY);
/* NOTREACHED */
}
if (dp == dcwd) {
char *tmp;
if ((p = dp->di_prev) == &dhead)
p = dhead.di_prev;
if (chdir(tmp = short2str(p->di_name)) < 0)
if (chdir(tmp = short2str(p->di_name)) < 0) {
stderror(ERR_SYSTEM, tmp, strerror(errno));
/* NOTREACHED */
}
}
dp->di_prev->di_next = dp->di_next;
dp->di_next->di_prev = dp->di_prev;
@ -881,8 +902,8 @@ dcanon(cp, p)
*/
if (p1 && *p1 == '/' &&
(Strncmp(p1, cp, cc) != 0 || (cp[cc] != '/' && cp[cc] != '\0'))) {
static ino_t home_ino = -1;
static dev_t home_dev = -1;
static ino_t home_ino;
static dev_t home_dev = NODEV;
static Char *home_ptr = NULL;
struct stat statbuf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dol.c,v 1.10 1997/07/04 21:23:56 christos Exp $ */
/* $NetBSD: dol.c,v 1.11 1998/07/28 02:23:38 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)dol.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: dol.c,v 1.10 1997/07/04 21:23:56 christos Exp $");
__RCSID("$NetBSD: dol.c,v 1.11 1998/07/28 02:23:38 mycroft Exp $");
#endif
#endif /* not lint */
@ -147,6 +147,7 @@ Dfix1(cp)
if (gargc != 1) {
setname(vis_str(cp));
stderror(ERR_NAME | ERR_AMBIG);
/* NOTREACHED */
}
cp = Strsave(gargv[0]);
blkfree(gargv), gargv = 0;
@ -210,8 +211,10 @@ Dpack(wbuf, wp)
Gcat(STRNULL, wbuf);
return (NULL);
}
if (--i <= 0)
if (--i <= 0) {
stderror(ERR_WTOOLONG);
/* NOTREACHED */
}
*wp++ = c;
}
}
@ -242,7 +245,7 @@ Dword()
return (0);
/* finish this word and catch the code above the next time */
unDredc(c);
/* fall into ... */
/* FALLTHROUGH */
case '\n':
*wp = 0;
@ -257,6 +260,7 @@ Dword()
case '`':
/* We preserve ` quotations which are done yet later */
*wp++ = c, --i;
/* FALLTHROUGH */
case '\'':
case '"':
/*
@ -269,12 +273,16 @@ Dword()
c = DgetC(dolflg);
if (c == c1)
break;
if (c == '\n' || c == DEOF)
if (c == '\n' || c == DEOF) {
stderror(ERR_UNMATCHED, c1);
/* NOTREACHED */
}
if ((c & (QUOTE | TRIM)) == ('\n' | QUOTE))
--wp, ++i;
if (--i <= 0)
if (--i <= 0) {
stderror(ERR_WTOOLONG);
/* NOTREACHED */
}
switch (c1) {
case '"':
@ -397,6 +405,7 @@ dolerror(s)
{
setname(vis_str(s));
stderror(ERR_NAME | ERR_RANGE);
/* NOTREACHED */
}
/*
@ -427,8 +436,10 @@ Dgetdol()
switch (c) {
case '!':
if (dimen || bitset)
if (dimen || bitset) {
stderror(ERR_SYNTAX);
/* NOTREACHED */
}
if (backpid != 0) {
if (dolbang)
xfree((ptr_t) dolbang);
@ -437,20 +448,28 @@ Dgetdol()
goto eatbrac;
case '$':
if (dimen || bitset)
if (dimen || bitset) {
stderror(ERR_SYNTAX);
/* NOTREACHED */
}
setDolp(doldol);
goto eatbrac;
case '<' | QUOTE:
if (bitset)
if (bitset) {
stderror(ERR_NOTALLOWED, "$?<");
if (dimen)
/* NOTREACHED */
}
if (dimen) {
stderror(ERR_NOTALLOWED, "$?#");
/* NOTREACHED */
}
for (np = wbuf; read(OLDSTD, &tnp, 1) == 1; np++) {
*np = (unsigned char) tnp;
if (np >= &wbuf[BUFSIZ - 1])
if (np >= &wbuf[BUFSIZ - 1]) {
stderror(ERR_LTOOLONG);
/* NOTREACHED */
}
if (tnp == '\n')
break;
}
@ -471,7 +490,6 @@ Dgetdol()
case '\n':
stderror(ERR_SYNTAX);
/* NOTREACHED */
break;
case '*':
(void) Strcpy(name, STRargv);
@ -482,8 +500,10 @@ Dgetdol()
default:
np = name;
if (Isdigit(c)) {
if (dimen)
if (dimen) {
stderror(ERR_NOTALLOWED, "$#<num>");
/* NOTREACHED */
}
subscr = 0;
do {
subscr = subscr * 10 + c - '0';
@ -499,14 +519,18 @@ Dgetdol()
dolp = ffile ? STR1 : STR0;
goto eatbrac;
}
if (ffile == 0)
if (ffile == 0) {
stderror(ERR_DOLZERO);
/* NOTREACHED */
}
fixDolMod();
setDolp(ffile);
goto eatbrac;
}
if (bitset)
if (bitset) {
stderror(ERR_DOLQUEST);
/* NOTREACHED */
}
vp = adrof(STRargv);
if (vp == 0) {
vp = &nulargv;
@ -514,15 +538,19 @@ Dgetdol()
}
break;
}
if (!alnum(c))
if (!alnum(c)) {
stderror(ERR_VARALNUM);
/* NOTREACHED */
}
for (;;) {
*np++ = c;
c = DgetC(0);
if (!alnum(c))
break;
if (np >= &name[MAXVARLEN])
if (np >= &name[MAXVARLEN]) {
stderror(ERR_VARTOOLONG);
/* NOTREACHED */
}
}
*np++ = 0;
unDredc(c);
@ -550,17 +578,25 @@ Dgetdol()
c = DgetC(DODOL); /* Allow $ expand within [ ] */
if (c == ']')
break;
if (c == '\n' || c == DEOF)
if (c == '\n' || c == DEOF) {
stderror(ERR_INCBR);
if (np >= &name[sizeof(name) / sizeof(Char) - 2])
/* NOTREACHED */
}
if (np >= &name[sizeof(name) / sizeof(Char) - 2]) {
stderror(ERR_VARTOOLONG);
/* NOTREACHED */
}
*np++ = c;
}
*np = 0, np = name;
if (dolp || dolcnt) /* $ exp must end before ] */
if (dolp || dolcnt) /* $ exp must end before ] */ {
stderror(ERR_EXPORD);
if (!*np)
/* NOTREACHED */
}
if (!*np) {
stderror(ERR_SYNTAX);
/* NOTREACHED */
}
if (Isdigit(*np)) {
int i;
@ -576,9 +612,10 @@ Dgetdol()
}
if (*np == '*')
np++;
else if (*np != '-')
else if (*np != '-') {
stderror(ERR_MISSING, '-');
else {
/* NOTREACHED */
} else {
int i = upb;
np++;
@ -603,8 +640,10 @@ Dgetdol()
}
upb = -1;
}
if (*np)
if (*np) {
stderror(ERR_SYNTAX);
/* NOTREACHED */
}
}
else {
if (subscr > 0)
@ -629,8 +668,10 @@ eatmod:
eatbrac:
if (sc == '{') {
c = Dredc();
if (c != '}')
if (c != '}') {
stderror(ERR_MISSING, '}');
/* NOTREACHED */
}
}
}
@ -681,8 +722,10 @@ fixDolMod()
}
continue;
}
if (!any("htrqxes", c))
if (!any("htrqxes", c)) {
stderror(ERR_BADMOD, c);
/* NOTREACHED */
}
dolmod[dolnmod++] = c;
if (c == 'q')
dolmcnt = 10000;
@ -794,8 +837,10 @@ setDolp(cp)
addla(cp);
dolp = STRNULL;
if (seterr)
if (seterr) {
stderror(ERR_OLD);
/* NOTREACHED */
}
}
static void
@ -854,8 +899,10 @@ heredoc(term)
char *tmp;
tmp = short2str(shtemp);
if (open(tmp, O_RDWR | O_CREAT | O_TRUNC, 0600) < 0)
if (open(tmp, O_RDWR | O_CREAT | O_TRUNC, 0600) < 0) {
stderror(ERR_SYSTEM, tmp, strerror(errno));
/* NOTREACHED */
}
(void) unlink(tmp); /* 0 0 inode! */
Dv[0] = term;
Dv[1] = NULL;
@ -880,6 +927,7 @@ heredoc(term)
if (--lcnt < 0) {
setname("<<");
stderror(ERR_NAME | ERR_OVERFLOW);
/* NOTREACHED */
}
}
}
@ -937,6 +985,7 @@ heredoc(term)
if (--mcnt == 0) {
setname("<<");
stderror(ERR_NAME | ERR_OVERFLOW);
/* NOTREACHED */
}
}
*mbp++ = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.10 1998/07/27 17:55:17 mycroft Exp $ */
/* $NetBSD: err.c,v 1.11 1998/07/28 02:23:38 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: err.c,v 1.10 1998/07/27 17:55:17 mycroft Exp $");
__RCSID("$NetBSD: err.c,v 1.11 1998/07/28 02:23:38 mycroft Exp $");
#endif
#endif /* not lint */
@ -61,7 +61,7 @@ char *seterr = NULL; /* Holds last error if there was one */
#define ERR_SILENT 0x20000000
#define ERR_OLD 0x40000000
static char *errorlist[] =
static const char *errorlist[] =
{
#define ERR_SYNTAX 0
"Syntax Error",
@ -353,7 +353,7 @@ stderror(id, va_alist)
id &= ~ERR_FLAGS;
if ((flags & ERR_OLD) && seterr == NULL)
return;
abort();
if (id < 0 || id > sizeof(errorlist) / sizeof(errorlist[0]))
id = ERR_INVALID;
@ -398,8 +398,10 @@ stderror(id, va_alist)
/*
* Go away if -e or we are a child shell
*/
if (exiterr || child)
if (exiterr || child) {
xexit(1);
/* NOTREACHED */
}
/*
* Reset the state of the input. This buffered seek to end of file will

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.c,v 1.12 1998/07/26 14:53:46 mycroft Exp $ */
/* $NetBSD: exec.c,v 1.13 1998/07/28 02:23:38 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)exec.c 8.3 (Berkeley) 5/23/95";
#else
__RCSID("$NetBSD: exec.c,v 1.12 1998/07/26 14:53:46 mycroft Exp $");
__RCSID("$NetBSD: exec.c,v 1.13 1998/07/28 02:23:38 mycroft Exp $");
#endif
#endif /* not lint */
@ -138,6 +138,7 @@ doexec(v, t)
if (pv == 0) {
setname(vis_str(blk[0]));
stderror(ERR_NAME | ERR_NOMATCH);
/* NOTREACHED */
}
gargv = 0;
}
@ -169,6 +170,7 @@ doexec(v, t)
blkfree(pv);
setname(vis_str(expath));
stderror(ERR_NAME | ERR_NOMATCH);
/* NOTREACHED */
}
gargv = 0;
}
@ -261,7 +263,9 @@ pexerr()
setname("");
if (exerr)
stderror(ERR_NAME | ERR_STRING, exerr);
stderror(ERR_NAME | ERR_COMMAND);
else
stderror(ERR_NAME | ERR_COMMAND);
/* NOTREACHED */
}
/*
@ -306,6 +310,7 @@ texec(sf, st)
* We *know* what ENOEXEC means.
*/
stderror(ERR_ARCH, f, strerror(errno));
/* NOTREACHED */
}
}
#ifdef _PATH_BSHELL
@ -345,10 +350,11 @@ texec(sf, st)
(void) execve(f, t, environ);
Vt = 0;
blkfree((Char **) t);
/* The sky is falling, the sky is falling! */
/* FALLTHROUGH */
case ENOMEM:
stderror(ERR_SYSTEM, f, strerror(errno));
/* NOTREACHED */
case ENOENT:
break;
@ -431,8 +437,10 @@ execash(t, kp)
OLDSTD = dmove(saveSTD, oOLDSTD);
resexit(osetexit);
if (my_reenter)
if (my_reenter) {
stderror(ERR_SILENT);
/* NOTREACHED */
}
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: exp.c,v 1.9 1997/10/19 17:38:05 mycroft Exp $ */
/* $NetBSD: exp.c,v 1.10 1998/07/28 02:23:38 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)exp.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: exp.c,v 1.9 1997/10/19 17:38:05 mycroft Exp $");
__RCSID("$NetBSD: exp.c,v 1.10 1998/07/28 02:23:38 mycroft Exp $");
#endif
#endif /* not lint */
@ -405,15 +405,19 @@ exp5(vp, ignore)
case '/':
i = egetn(p2);
if (i == 0)
if (i == 0) {
stderror(ERR_DIV0);
/* NOTREACHED */
}
i = egetn(p1) / i;
break;
case '%':
i = egetn(p2);
if (i == 0)
if (i == 0) {
stderror(ERR_MOD0);
/* NOTREACHED */
}
i = egetn(p1) % i;
break;
}
@ -432,8 +436,10 @@ exp6(vp, ignore)
int ccode, i = 0;
Char *cp, *dp, *ep;
if (**vp == 0)
if (**vp == 0) {
stderror(ERR_NAME | ERR_EXPRESSION);
/* NOTREACHED */
}
if (eq(**vp, STRbang)) {
(*vp)++;
cp = exp6(vp, ignore);
@ -460,8 +466,10 @@ exp6(vp, ignore)
#ifdef EDEBUG
etraci("exp6 () ccode", ccode, vp);
#endif
if (*vp == 0 || **vp == 0 || ***vp != ')')
if (*vp == 0 || **vp == 0 || ***vp != ')') {
stderror(ERR_NAME | ERR_EXPRESSION);
/* NOTREACHED */
}
(*vp)++;
return (putn(ccode));
}
@ -479,8 +487,10 @@ exp6(vp, ignore)
(*vp)++;
v = *vp;
for (;;) {
if (!**vp)
if (!**vp) {
stderror(ERR_NAME | ERR_MISSING, '}');
/* NOTREACHED */
}
if (eq(*(*vp)++, STRRbrace))
break;
}
@ -491,6 +501,7 @@ exp6(vp, ignore)
*--(*vp) = 0;
evalav(v);
exitstat();
/* NOTREACHED */
}
pwait();
prestjob();
@ -505,8 +516,10 @@ exp6(vp, ignore)
if (*cp == '-' && any("erwxfdzopls", cp[1])) {
struct stat stb;
if (cp[2] != '\0')
if (cp[2] != '\0') {
stderror(ERR_NAME | ERR_FILEINQ);
/* NOTREACHED */
}
/*
* Detect missing file names by checking for operator in the file name
* position. However, if an operator name appears there, we must make
@ -514,8 +527,10 @@ exp6(vp, ignore)
* an error. Even this check isn't quite right, since it doesn't take
* globbing into account.
*/
if (isa(**vp, ANYOP) && stat(short2str(**vp), &stb))
if (isa(**vp, ANYOP) && stat(short2str(**vp), &stb)) {
stderror(ERR_NAME | ERR_FILENAME);
/* NOTREACHED */
}
dp = *(*vp)++;
if (ignore & IGNORE)
@ -625,8 +640,10 @@ evalav(v)
hp->prev = wdp;
alias(&paraml1);
t = syntax(paraml1.next, &paraml1, 0);
if (seterr)
if (seterr) {
stderror(ERR_OLD);
/* NOTREACHED */
}
execute(t, -1, NULL, NULL);
freelex(&paraml1), freesyn(t);
}
@ -684,8 +701,10 @@ static int
egetn(cp)
Char *cp;
{
if (*cp && *cp != '-' && !Isdigit(*cp))
if (*cp && *cp != '-' && !Isdigit(*cp)) {
stderror(ERR_NAME | ERR_EXPRESSION);
/* NOTREACHED */
}
return (getn(cp));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.10 1998/07/26 19:37:11 mycroft Exp $ */
/* $NetBSD: extern.h,v 1.11 1998/07/28 02:23:38 mycroft Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -42,7 +42,7 @@
*/
int gethdir __P((Char *));
void dosource __P((Char **, struct command *));
void exitstat __P((void));
__dead void exitstat __P((void)) __attribute__((noreturn));
void goodbye __P((void));
void importpath __P((Char *));
void initdesc __P((void));
@ -55,9 +55,9 @@ void untty __P((void));
int vis_fputc __P((int, FILE *));
#ifdef PROF
void done __P((int));
__dead void done __P((int)) __attribute__((noreturn));
#else
void xexit __P((int));
__dead void xexit __P((int)) __attribute__((noreturn));
#endif
/*
@ -86,7 +86,7 @@ void heredoc __P((Char *));
* err.c
*/
void seterror __P((int, ...));
void stderror __P((int, ...));
__dead void stderror __P((int, ...)) __attribute__((noreturn));
/*
* exec.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: func.c,v 1.13 1997/07/04 21:24:01 christos Exp $ */
/* $NetBSD: func.c,v 1.14 1998/07/28 02:23:38 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)func.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: func.c,v 1.13 1997/07/04 21:24:01 christos Exp $");
__RCSID("$NetBSD: func.c,v 1.14 1998/07/28 02:23:38 mycroft Exp $");
#endif
#endif /* not lint */
@ -61,7 +61,6 @@ __RCSID("$NetBSD: func.c,v 1.13 1997/07/04 21:24:01 christos Exp $");
extern char **environ;
static int zlast = -1;
static void islogin __P((void));
static void reexecute __P((struct command *));
static void preread __P((void));
@ -125,10 +124,14 @@ func(t, bp)
xechoit(t->t_dcom);
setname(bp->bname);
i = blklen(t->t_dcom) - 1;
if (i < bp->minargs)
if (i < bp->minargs) {
stderror(ERR_NAME | ERR_TOOFEW);
if (i > bp->maxargs)
/* NOTREACHED */
}
if (i > bp->maxargs) {
stderror(ERR_NAME | ERR_TOOMANY);
/* NOTREACHED */
}
(*bp->bfunct) (t->t_dcom, t);
}
@ -144,8 +147,10 @@ doonintr(v, t)
if (parintr == SIG_IGN)
return;
if (setintr && intty)
if (setintr && intty) {
stderror(ERR_NAME | ERR_TERMINAL);
/* NOTREACHED */
}
cp = gointr;
gointr = 0;
xfree((ptr_t) cp);
@ -174,8 +179,10 @@ donohup(v, t)
Char **v;
struct command *t;
{
if (intty)
if (intty) {
stderror(ERR_NAME | ERR_TERMINAL);
/* NOTREACHED */
}
if (setintr == 0) {
(void) signal(SIGHUP, SIG_IGN);
}
@ -220,6 +227,7 @@ doalias(v, t)
if (eq(p, STRalias) || eq(p, STRunalias)) {
setname(vis_str(p));
stderror(ERR_NAME | ERR_DANGER);
/* NOTREACHED */
}
set1(strip(p), saveblk(v), &aliases);
}
@ -256,6 +264,7 @@ dologin(v, t)
(void) execl(_PATH_LOGIN, "login", short2str(v[1]), NULL);
untty();
xexit(1);
/* NOTREACHED */
}
static void
@ -266,6 +275,7 @@ islogin()
if (loginsh)
return;
stderror(ERR_NOTLOGIN);
/* NOTREACHED */
}
void
@ -279,11 +289,15 @@ doif(v, kp)
v++;
i = expr(&v);
vv = v;
if (*vv == NULL)
if (*vv == NULL) {
stderror(ERR_NAME | ERR_EMPTYIF);
/* NOTREACHED */
}
if (eq(*vv, STRthen)) {
if (*++vv)
if (*++vv) {
stderror(ERR_NAME | ERR_IMPRTHEN);
/* NOTREACHED */
}
setname(vis_str(STRthen));
/*
* If expression was zero, then scan to else, otherwise just fall into
@ -352,7 +366,6 @@ gotolab(lab)
* While we still can, locate any unknown ends of existing loops. This
* obscure code is the WORST result of the fact that we don't really parse.
*/
zlast = T_GOTO;
for (wp = whyles; wp; wp = wp->w_next)
if (wp->w_end.type == F_SEEK && wp->w_end.f_seek == 0) {
search(T_BREAK, 0, NULL);
@ -376,13 +389,17 @@ doswitch(v, t)
Char *cp, *lp;
v++;
if (!*v || *(*v++) != '(')
if (!*v || *(*v++) != '(') {
stderror(ERR_SYNTAX);
/* NOTREACHED */
}
cp = **v == ')' ? STRNULL : *v++;
if (*(*v++) != ')')
v--;
if (*v)
if (*v) {
stderror(ERR_SYNTAX);
/* NOTREACHED */
}
search(T_SWITCH, 0, lp = globone(cp, G_ERROR));
xfree((ptr_t) lp);
}
@ -395,8 +412,10 @@ dobreak(v, t)
{
if (whyles)
toend();
else
else {
stderror(ERR_NAME | ERR_NOTWHILE);
/* NOTREACHED */
}
}
void
@ -413,8 +432,10 @@ doexit(v, t)
v++;
if (*v) {
set(STRstatus, putn(expr(&v)));
if (*v)
if (*v) {
stderror(ERR_NAME | ERR_EXPRESSION);
/* NOTREACHED */
}
}
btoeof();
if (intty)
@ -432,22 +453,32 @@ doforeach(v, t)
v++;
sp = cp = strip(*v);
if (!letter(*sp))
if (!letter(*sp)) {
stderror(ERR_NAME | ERR_VARBEGIN);
/* NOTREACHED */
}
while (*cp && alnum(*cp))
cp++;
if (*cp)
if (*cp) {
stderror(ERR_NAME | ERR_VARALNUM);
if ((cp - sp) > MAXVARLEN)
/* NOTREACHED */
}
if ((cp - sp) > MAXVARLEN) {
stderror(ERR_NAME | ERR_VARTOOLONG);
/* NOTREACHED */
}
cp = *v++;
if (v[0][0] != '(' || v[blklen(v) - 1][0] != ')')
if (v[0][0] != '(' || v[blklen(v) - 1][0] != ')') {
stderror(ERR_NAME | ERR_NOPAREN);
/* NOTREACHED */
}
v++;
gflag = 0, tglob(v);
v = globall(v);
if (v == 0)
if (v == 0) {
stderror(ERR_NAME | ERR_NOMATCH);
/* NOTREACHED */
}
nwp = (struct whyle *) xcalloc(1, sizeof *nwp);
nwp->w_fe = nwp->w_fe0 = v;
gargv = 0;
@ -459,7 +490,6 @@ doforeach(v, t)
/*
* Pre-read the loop so as to be more comprehensible to a terminal user.
*/
zlast = T_FOREACH;
if (intty)
preread();
doagain();
@ -484,8 +514,10 @@ dowhile(v, t)
status = !exp0(&v, 1);
else
status = !expr(&v);
if (*v)
if (*v) {
stderror(ERR_NAME | ERR_EXPRESSION);
/* NOTREACHED */
}
if (!again) {
struct whyle *nwp =
(struct whyle *) xcalloc(1, sizeof(*nwp));
@ -495,7 +527,6 @@ dowhile(v, t)
nwp->w_end.f_seek = 0;
nwp->w_next = whyles;
whyles = nwp;
zlast = T_WHILE;
if (intty) {
/*
* The tty preread
@ -534,8 +565,10 @@ doend(v, t)
Char **v;
struct command *t;
{
if (!whyles)
if (!whyles) {
stderror(ERR_NAME | ERR_NOTWHILE);
/* NOTREACHED */
}
btell(&whyles->w_end);
doagain();
}
@ -546,8 +579,10 @@ docontin(v, t)
Char **v;
struct command *t;
{
if (!whyles)
if (!whyles) {
stderror(ERR_NAME | ERR_NOTWHILE);
/* NOTREACHED */
}
doagain();
}
@ -799,22 +834,26 @@ past:
case T_IF:
stderror(ERR_NAME | ERR_NOTFOUND, "then/endif");
/* NOTREACHED */
case T_ELSE:
stderror(ERR_NAME | ERR_NOTFOUND, "endif");
/* NOTREACHED */
case T_BRKSW:
case T_SWITCH:
stderror(ERR_NAME | ERR_NOTFOUND, "endsw");
/* NOTREACHED */
case T_BREAK:
stderror(ERR_NAME | ERR_NOTFOUND, "end");
/* NOTREACHED */
case T_GOTO:
setname(vis_str(Sgoal));
stderror(ERR_NAME | ERR_NOTFOUND, "label");
/* NOTREACHED */
}
/* NOTREACHED */
return (0);
}
@ -934,8 +973,10 @@ xecho(sep, v)
gflag = 0, tglob(v);
if (gflag) {
v = globall(v);
if (v == 0)
if (v == 0) {
stderror(ERR_NAME | ERR_NOMATCH);
/* NOTREACHED */
}
}
else {
v = gargv = saveblk(v);
@ -1137,18 +1178,20 @@ doumask(v, t)
i = 0;
while (Isdigit(*cp) && *cp != '8' && *cp != '9')
i = i * 8 + *cp++ - '0';
if (*cp || i < 0 || i > 0777)
if (*cp || i < 0 || i > 0777) {
stderror(ERR_NAME | ERR_MASK);
/* NOTREACHED */
}
(void) umask(i);
}
typedef quad_t RLIM_TYPE;
static struct limits {
static const struct limits {
int limconst;
char *limname;
const char *limname;
int limdiv;
char *limscale;
const char *limscale;
} limits[] = {
{ RLIMIT_CPU, "cputime", 1, "seconds" },
{ RLIMIT_FSIZE, "filesize", 1024, "kbytes" },
@ -1162,23 +1205,25 @@ static struct limits {
{ -1, NULL, 0, NULL }
};
static struct limits *findlim __P((Char *));
static RLIM_TYPE getval __P((struct limits *, Char **));
static const struct limits *findlim __P((Char *));
static RLIM_TYPE getval __P((const struct limits *, Char **));
static void limtail __P((Char *, char *));
static void plim __P((struct limits *, Char));
static int setlim __P((struct limits *, Char, RLIM_TYPE));
static void plim __P((const struct limits *, Char));
static int setlim __P((const struct limits *, Char, RLIM_TYPE));
static struct limits *
static const struct limits *
findlim(cp)
Char *cp;
{
struct limits *lp, *res;
const struct limits *lp, *res;
res = (struct limits *) NULL;
for (lp = limits; lp->limconst >= 0; lp++)
if (prefix(cp, str2short(lp->limname))) {
if (res)
if (res) {
stderror(ERR_NAME | ERR_AMBIG);
/* NOTREACHED */
}
res = lp;
}
if (res)
@ -1194,7 +1239,7 @@ dolimit(v, t)
Char **v;
struct command *t;
{
struct limits *lp;
const struct limits *lp;
RLIM_TYPE limit;
char hard = 0;
@ -1214,13 +1259,15 @@ dolimit(v, t)
return;
}
limit = getval(lp, v + 1);
if (setlim(lp, hard, limit) < 0)
if (setlim(lp, hard, limit) < 0) {
stderror(ERR_SILENT);
/* NOTREACHED */
}
}
static RLIM_TYPE
getval(lp, v)
struct limits *lp;
const struct limits *lp;
Char **v;
{
float f;
@ -1278,8 +1325,9 @@ getval(lp, v)
limtail(cp, "unlimited");
return (RLIM_INFINITY);
default:
badscal:
badscal:
stderror(ERR_NAME | ERR_SCALEF);
/* NOTREACHED */
}
f += 0.5;
if (f > (float) RLIM_INFINITY)
@ -1295,15 +1343,17 @@ limtail(cp, str)
{
while (*cp && *cp == *str)
cp++, str++;
if (*cp)
if (*cp) {
stderror(ERR_BADSCALE, str);
/* NOTREACHED */
}
}
/*ARGSUSED*/
static void
plim(lp, hard)
struct limits *lp;
const struct limits *lp;
Char hard;
{
struct rlimit rlim;
@ -1330,7 +1380,7 @@ dounlimit(v, t)
Char **v;
struct command *t;
{
struct limits *lp;
const struct limits *lp;
int lerr = 0;
Char hard = 0;
@ -1343,20 +1393,24 @@ dounlimit(v, t)
for (lp = limits; lp->limconst >= 0; lp++)
if (setlim(lp, hard, (RLIM_TYPE) RLIM_INFINITY) < 0)
lerr++;
if (lerr)
if (lerr) {
stderror(ERR_SILENT);
/* NOTREACHED */
}
return;
}
while (*v) {
lp = findlim(*v++);
if (setlim(lp, hard, (RLIM_TYPE) RLIM_INFINITY) < 0)
if (setlim(lp, hard, (RLIM_TYPE) RLIM_INFINITY) < 0) {
stderror(ERR_SILENT);
/* NOTREACHED */
}
}
}
static int
setlim(lp, hard, limit)
struct limits *lp;
const struct limits *lp;
Char hard;
RLIM_TYPE limit;
{
@ -1390,8 +1444,10 @@ dosuspend(v, t)
void (*old) __P((int));
if (loginsh)
if (loginsh) {
stderror(ERR_SUSPLOG);
/* NOTREACHED */
}
untty();
old = signal(SIGTSTP, SIG_DFL);
@ -1461,8 +1517,10 @@ doeval(v, t)
if (gflag) {
gv = v = globall(v);
gargv = 0;
if (v == 0)
if (v == 0) {
stderror(ERR_NOMATCH);
/* NOTREACHED */
}
v = copyblk(v);
}
else {
@ -1501,8 +1559,10 @@ doeval(v, t)
blkfree(gv), gv = NULL;
resexit(osetexit);
gv = savegv;
if (my_reenter)
if (my_reenter) {
stderror(ERR_SILENT);
/* NOTREACHED */
}
}
void
@ -1520,6 +1580,8 @@ doprintf(v, t)
(void) fflush(csherr);
blkfree((Char **) c);
if (ret)
if (ret) {
stderror(ERR_SILENT);
/* NOTREACHED */
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: glob.c,v 1.14 1998/06/19 22:58:04 kleink Exp $ */
/* $NetBSD: glob.c,v 1.15 1998/07/28 02:23:39 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)glob.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: glob.c,v 1.14 1998/06/19 22:58:04 kleink Exp $");
__RCSID("$NetBSD: glob.c,v 1.15 1998/07/28 02:23:39 mycroft Exp $");
#endif
#endif /* not lint */
@ -121,6 +121,7 @@ globtilde(nv, s)
stderror(ERR_UNKUSER, vis_str(gstart));
else
stderror(ERR_NOHOME);
/* NOTREACHED */
}
b = &gstart[Strlen(gstart)];
while (*s)
@ -251,6 +252,7 @@ expbrace(nvp, elp, size)
if ((len = globbrace(s, b, &bl)) < 0) {
xfree((ptr_t) nv);
stderror(ERR_MISSING, -len);
/* NOTREACHED */
}
xfree((ptr_t) s);
if (len == 1) {
@ -366,7 +368,7 @@ handleone(str, vl, action)
setname(vis_str(str));
blkfree(vl);
stderror(ERR_NAME | ERR_AMBIG);
break;
/* NOTREACHED */
case G_APPEND:
trim(vlp);
str = Strsave(*vlp++);
@ -481,6 +483,7 @@ globone(str, action)
if (vl == NULL) {
setname(vis_str(str));
stderror(ERR_NAME | ERR_NOMATCH);
/* NOTREACHED */
}
if (vl[0] == NULL) {
xfree((ptr_t) vl);
@ -641,8 +644,11 @@ dobackp(cp, literal)
if (!*rp)
goto oops;
}
if (!*rp)
oops: stderror(ERR_UNMATCHED, '`');
if (!*rp) {
oops:
stderror(ERR_UNMATCHED, '`');
/* NOTREACHED */
}
ep = Strsave(lp);
ep[rp - lp] = 0;
backeval(ep, literal);
@ -718,12 +724,16 @@ backeval(cp, literal)
alvecp = NULL;
evalp = NULL;
(void) lex(&paraml);
if (seterr)
if (seterr) {
stderror(ERR_OLD);
/* NOTREACHED */
}
alias(&paraml);
t = syntax(paraml.next, &paraml, 0);
if (seterr)
if (seterr) {
stderror(ERR_OLD);
/* NOTREACHED */
}
if (t)
t->t_dflg |= F_NOFORK;
(void) signal(SIGTSTP, SIG_IGN);
@ -731,6 +741,7 @@ backeval(cp, literal)
(void) signal(SIGTTOU, SIG_IGN);
execute(t, -1, NULL, NULL);
exitstat();
/* NOTREACHED */
}
xfree((ptr_t) cp);
(void) close(pvec[1]);
@ -792,8 +803,10 @@ static void
psave(c)
int c;
{
if (--pnleft <= 0)
if (--pnleft <= 0) {
stderror(ERR_WTOOLONG);
/* NOTREACHED */
}
*pargcp++ = c;
}
@ -879,8 +892,10 @@ pmatch(string, pattern)
else
match = (stringc == (rangec & TRIM));
}
if (rangec == 0)
if (rangec == 0) {
stderror(ERR_NAME | ERR_MISSING, ']');
/* NOTREACHED */
}
if (match == negate_range)
return (0);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: hist.c,v 1.9 1997/07/04 21:24:03 christos Exp $ */
/* $NetBSD: hist.c,v 1.10 1998/07/28 02:23:39 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: hist.c,v 1.9 1997/07/04 21:24:03 christos Exp $");
__RCSID("$NetBSD: hist.c,v 1.10 1998/07/28 02:23:39 mycroft Exp $");
#endif
#endif /* not lint */
@ -152,7 +152,7 @@ dohist(v, t)
break;
default:
stderror(ERR_HISTUS);
break;
/* NOTREACHED */
}
}
if (*v)

View File

@ -1,4 +1,4 @@
/* $NetBSD: lex.c,v 1.12 1998/03/29 04:36:29 mrg Exp $ */
/* $NetBSD: lex.c,v 1.13 1998/07/28 02:23:39 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: lex.c,v 1.12 1998/03/29 04:36:29 mrg Exp $");
__RCSID("$NetBSD: lex.c,v 1.13 1998/07/28 02:23:39 mycroft Exp $");
#endif
#endif /* not lint */
@ -277,7 +277,7 @@ loop:
} while (c != '\n');
if (c1 == '\\')
goto loop;
/* fall into ... */
/* FALLTHROUGH */
case ';':
case '(':
@ -296,6 +296,7 @@ loop:
if (c != HIST)
*wp++ = '\\', --i;
c |= QUOTE;
break;
}
c1 = 0;
dolflg = DOALL;
@ -367,7 +368,7 @@ getC1(flag)
{
Char c;
while (1) {
for (;;) {
if ((c = peekc) != '\0') {
peekc = 0;
return (c);
@ -598,8 +599,10 @@ getdol()
c = 's';
}
if (!any("htrqxes", c)) {
if ((amodflag || gmodflag) && c == '\n')
if ((amodflag || gmodflag) && c == '\n') {
stderror(ERR_VARSYN); /* strike */
/* NOTREACHED */
}
seterror(ERR_VARMOD, c);
*np = 0;
addla(name);
@ -760,8 +763,7 @@ getsub(en)
case 'x':
case 'q':
global |= 1;
/* fall into ... */
/* FALLTHROUGH */
case 'h':
case 'r':
@ -960,7 +962,7 @@ subword(cp, type, adid)
case '\\':
if (np[1] == '&')
np++;
/* fall into ... */
/* FALLTHROUGH */
default:
if (--i < 0) {
@ -1182,7 +1184,7 @@ gethent(sc)
case '-':
back = 1;
c = getC(0);
/* FALLSTHROUGH */
/* FALLTHROUGH */
default:
if (any("(=~", c)) {
@ -1390,6 +1392,7 @@ top:
if (wanteof)
return (-1);
exitstat();
/* NOTREACHED */
}
if (arginp) {
if ((c = *arginp++) == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: misc.c,v 1.9 1997/07/04 21:24:06 christos Exp $ */
/* $NetBSD: misc.c,v 1.10 1998/07/28 02:23:39 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: misc.c,v 1.9 1997/07/04 21:24:06 christos Exp $");
__RCSID("$NetBSD: misc.c,v 1.10 1998/07/28 02:23:39 mycroft Exp $");
#endif
#endif /* not lint */
@ -422,6 +422,7 @@ udvar(name)
setname(vis_str(name));
stderror(ERR_NAME | ERR_UNDVAR);
/* NOTREACHED */
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.8 1997/07/04 21:24:07 christos Exp $ */
/* $NetBSD: parse.c,v 1.9 1998/07/28 02:23:39 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: parse.c,v 1.8 1997/07/04 21:24:07 christos Exp $");
__RCSID("$NetBSD: parse.c,v 1.9 1998/07/28 02:23:39 mycroft Exp $");
#endif
#endif /* not lint */
@ -96,8 +96,10 @@ alias(lex)
resexit(osetexit);
reset();
}
if (--aleft == 0)
if (--aleft == 0) {
stderror(ERR_ALIASLOOP);
/* NOTREACHED */
}
asyntax(lex->next, lex);
resexit(osetexit);
}
@ -132,8 +134,10 @@ asyn0(p1, p2)
case ')':
l--;
if (l < 0)
if (l < 0) {
stderror(ERR_TOOMANYRP);
/* NOTREACHED */
}
continue;
case '>':
@ -187,6 +191,7 @@ asyn3(p1, p2)
if (seterr) {
freelex(&alout);
stderror(ERR_OLD);
/* NOTREACHED */
}
if (p1->word[0] && eq(p1->word, alout.next->word)) {
Char *cp = alout.next->word;
@ -277,7 +282,7 @@ syn0(p1, p2, flags)
case '|':
if (p->word[1] == '|')
continue;
/* fall into ... */
/* FALLTHROUGH */
case '>':
if (p->next != p2 && eq(p->next->word, STRand))
@ -645,9 +650,11 @@ again:
t->t_dlef = Strsave(p->word);
continue;
savep:
savep:
if (!specp)
continue;
/* FALLTHROUGH */
default:
if (l != 0 && !specp)
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.c,v 1.12 1998/05/10 18:32:46 kleink Exp $ */
/* $NetBSD: proc.c,v 1.13 1998/07/28 02:23:39 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)proc.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: proc.c,v 1.12 1998/05/10 18:32:46 kleink Exp $");
__RCSID("$NetBSD: proc.c,v 1.13 1998/07/28 02:23:39 mycroft Exp $");
#endif
#endif /* not lint */
@ -82,7 +82,7 @@ static void okpcntl __P((void));
* childs status. Top level routines (like pwait) must be sure
* to mask interrupts when playing with the proclist data structures!
*/
/* ARGUSED */
/* ARGSUSED */
void
pchild(notused)
int notused;
@ -346,8 +346,10 @@ pjwait(pp)
(void) fprintf(cshout, "Exit %d\n", reason);
}
set(STRstatus, putn(reason));
if (reason && exiterr)
if (reason && exiterr) {
exitstat();
/* NOTREACHED */
}
pflush(pp);
}
@ -867,8 +869,10 @@ dojobs(v, t)
if (chkstop)
chkstop = 2;
if (*++v) {
if (v[1] || !eq(*v, STRml))
if (v[1] || !eq(*v, STRml)) {
stderror(ERR_JOBS);
/* NOTREACHED */
}
flag |= FANCY | JOBDIR;
}
for (i = 1; i <= pmaxindex; i++)
@ -980,12 +984,16 @@ dokill(v, t)
if (v[0] && v[0][0] == '-') {
if (v[0][1] == 'l') {
if (v[1]) {
if (!Isdigit(v[1][0]))
if (!Isdigit(v[1][0])) {
stderror(ERR_NAME | ERR_BADSIG);
/* NOTREACHED */
}
signum = atoi(short2str(v[1]));
if (signum < 0 || signum >= NSIG)
if (signum < 0 || signum >= NSIG) {
stderror(ERR_NAME | ERR_BADSIG);
/* NOTREACHED */
}
else if (signum == 0)
(void) fputc('0', cshout); /* 0's symbolic name is '0' */
else
@ -1002,8 +1010,10 @@ dokill(v, t)
}
if (Isdigit(v[0][1])) {
signum = atoi(short2str(v[0] + 1));
if (signum < 0 || signum > NSIG)
if (signum < 0 || signum > NSIG) {
stderror(ERR_NAME | ERR_BADSIG);
/* NOTREACHED */
}
}
else {
if (v[0][1] == 's' && (Isspace(v[0][2]) || v[0][2] == '\0'))
@ -1013,7 +1023,7 @@ dokill(v, t)
if (v[0] == NULL || v[1] == NULL) {
stderror(ERR_NAME | ERR_TOOFEW);
return;
/* NOTREACHED */
}
name = short2str(&v[0][0]);
@ -1027,6 +1037,7 @@ dokill(v, t)
else {
setname(vis_str(&v[0][0]));
stderror(ERR_NAME | ERR_UNKSIG);
/* NOTREACHED */
}
}
}
@ -1054,8 +1065,10 @@ pkill(v, signum)
gflag = 0, tglob(v);
if (gflag) {
v = globall(v);
if (v == 0)
if (v == 0) {
stderror(ERR_NAME | ERR_NOMATCH);
/* NOTREACHED */
}
}
else {
v = gargv = saveblk(v);
@ -1097,8 +1110,10 @@ pkill(v, signum)
if (signum == SIGTERM || signum == SIGHUP)
(void) kill(-pp->p_jobid, SIGCONT);
}
else if (!(Isdigit(*cp) || *cp == '-'))
else if (!(Isdigit(*cp) || *cp == '-')) {
stderror(ERR_NAME | ERR_JOBARGS);
/* NOTREACHED */
}
else {
pid = atoi(short2str(cp));
if (kill((pid_t) pid, signum) < 0) {
@ -1115,8 +1130,10 @@ cont:
if (gargv)
blkfree(gargv), gargv = 0;
sigprocmask(SIG_UNBLOCK, &sigset, NULL);
if (err1)
if (err1) {
stderror(ERR_SILENT);
/* NOTREACHED */
}
}
/*
@ -1164,8 +1181,10 @@ panystop(neednl)
chkstop = 2;
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_flags & PSTOPPED)
if (pp->p_flags & PSTOPPED) {
stderror(ERR_STOPPED, neednl ? "\n" : "");
/* NOTREACHED */
}
}
struct process *
@ -1175,13 +1194,17 @@ pfind(cp)
struct process *pp, *np;
if (cp == 0 || cp[1] == 0 || eq(cp, STRcent2) || eq(cp, STRcentplus)) {
if (pcurrent == NULL)
if (pcurrent == NULL) {
stderror(ERR_NAME | ERR_JOBCUR);
/* NOTREACHED */
}
return (pcurrent);
}
if (eq(cp, STRcentminus) || eq(cp, STRcenthash)) {
if (pprevious == NULL)
if (pprevious == NULL) {
stderror(ERR_NAME | ERR_JOBPREV);
/* NOTREACHED */
}
return (pprevious);
}
if (Isdigit(cp[1])) {
@ -1191,6 +1214,7 @@ pfind(cp)
if (pp->p_index == idx && pp->p_pid == pp->p_jobid)
return (pp);
stderror(ERR_NAME | ERR_NOSUCHJOB);
/* NOTREACHED */
}
np = NULL;
for (pp = proclist.p_next; pp; pp = pp->p_next)
@ -1207,8 +1231,10 @@ pfind(cp)
}
else if (prefix(cp + 1, pp->p_command)) {
match:
if (np)
if (np) {
stderror(ERR_NAME | ERR_AMBIG);
/* NOTREACHED */
}
np = pp;
}
}
@ -1292,8 +1318,10 @@ pfork(t, wanttty)
/*
* Check for maximum nesting of 16 processes to avoid Forking loops
*/
if (child == 16)
if (child == 16) {
stderror(ERR_NESTING, 16);
/* NOTREACHED */
}
/*
* Hold SIGCHLD until we have the process installed in our table.
*/
@ -1306,6 +1334,7 @@ pfork(t, wanttty)
else {
sigprocmask(SIG_SETMASK, &osigset, NULL);
stderror(ERR_NOPROC);
/* NOTREACHED */
}
if (pid == 0) {
settimes();
@ -1361,6 +1390,7 @@ okpcntl()
stderror(ERR_JOBCONTROL);
if (tpgrp == 0)
stderror(ERR_JOBCTRLSUB);
/* NOTREACHED */
}
/*
@ -1398,6 +1428,7 @@ pgetty(wanttty, pgrp)
if (setpgid(0, pgrp) == -1) {
(void) fprintf(csherr, "csh: setpgid error.\n");
xexit(0);
/* NOTREACHED */
}
if (wanttty > 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.c,v 1.11 1997/07/04 21:24:08 christos Exp $ */
/* $NetBSD: sem.c,v 1.12 1998/07/28 02:23:39 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)sem.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: sem.c,v 1.11 1997/07/04 21:24:08 christos Exp $");
__RCSID("$NetBSD: sem.c,v 1.12 1998/07/28 02:23:39 mycroft Exp $");
#endif
#endif /* not lint */
@ -100,7 +100,7 @@ execute(t, wanttty, pipein, pipeout)
Dfix(t); /* $ " ' \ */
if (t->t_dcom[0] == 0)
return;
/* fall into... */
/* FALLTHROUGH */
case NODE_PAREN:
if (t->t_dflg & F_PIPEOUT)
@ -273,6 +273,7 @@ execute(t, wanttty, pipein, pipeout)
if (pid < 0) {
sigprocmask(SIG_SETMASK, &osigset, NULL);
stderror(ERR_NOPROC);
/* NOTREACHED */
}
forked++;
if (pid) { /* parent */
@ -382,8 +383,10 @@ execute(t, wanttty, pipein, pipeout)
*/
if (bifunc) {
func(t, bifunc);
if (forked)
if (forked) {
exitstat();
/* NOTREACHED */
}
break;
}
if (t->t_dtyp != NODE_PAREN) {
@ -403,6 +406,7 @@ execute(t, wanttty, pipein, pipeout)
t->t_dspr->t_dflg |= t->t_dflg & F_NOINTERRUPT;
execute(t->t_dspr, wanttty, NULL, NULL);
exitstat();
/* NOTREACHED */
case NODE_PIPE:
t->t_dcar->t_dflg |= F_PIPEOUT |
@ -512,6 +516,7 @@ splicepipe(t, cp)
setname(vis_str(blk[0]));
xfree((ptr_t) blk[0]);
stderror(ERR_NAME | ERR_NOMATCH);
/* NOTREACHED */
}
gargv = NULL;
if (pv[1] != NULL) { /* we need to fix the command vector */
@ -560,8 +565,10 @@ doio(t, pipein, pipeout)
(void) strncpy(tmp, short2str(cp), MAXPATHLEN);
tmp[MAXPATHLEN] = '\0';
xfree((ptr_t) cp);
if ((fd = open(tmp, O_RDONLY)) < 0)
if ((fd = open(tmp, O_RDONLY)) < 0) {
stderror(ERR_SYSTEM, tmp, strerror(errno));
/* NOTREACHED */
}
(void) dmove(fd, 0);
}
else if (flags & F_PIPEIN) {
@ -601,12 +608,16 @@ doio(t, pipein, pipeout)
#endif
else {
if (!(flags & F_OVERWRITE) && adrof(STRnoclobber)) {
if (flags & F_APPEND)
if (flags & F_APPEND) {
stderror(ERR_SYSTEM, tmp, strerror(errno));
/* NOTREACHED */
}
chkclob(tmp);
}
if ((fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
if ((fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
stderror(ERR_SYSTEM, tmp, strerror(errno));
/* NOTREACHED */
}
}
(void) dmove(fd, 1);
}
@ -644,6 +655,7 @@ mypipe(pv)
return;
oops:
stderror(ERR_PIPE);
/* NOTREACHED */
}
static void
@ -657,4 +669,5 @@ chkclob(cp)
if (S_ISCHR(stb.st_mode))
return;
stderror(ERR_EXISTS, cp);
/* NOTREACHED */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: set.c,v 1.10 1997/07/04 21:24:09 christos Exp $ */
/* $NetBSD: set.c,v 1.11 1998/07/28 02:23:40 mycroft Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: set.c,v 1.10 1997/07/04 21:24:09 christos Exp $");
__RCSID("$NetBSD: set.c,v 1.11 1998/07/28 02:23:40 mycroft Exp $");
#endif
#endif /* not lint */
@ -98,11 +98,13 @@ doset(v, t)
if (letter(*p))
for (; alnum(*p); p++)
continue;
if (vp == p || !letter(*vp))
if (vp == p || !letter(*vp)) {
stderror(ERR_NAME | ERR_VARBEGIN);
/* NOTREACHED */
}
if ((p - vp) > MAXVARLEN) {
stderror(ERR_NAME | ERR_VARTOOLONG);
return;
/* NOTREACHED */
}
if (*p == '[') {
hadsub++;
@ -118,16 +120,22 @@ doset(v, t)
if (*v)
p = *v++;
}
if (op && op != '=')
if (op && op != '=') {
stderror(ERR_NAME | ERR_SYNTAX);
/* NOTREACHED */
}
if (eq(p, STRLparen)) {
Char **e = v;
if (hadsub)
if (hadsub) {
stderror(ERR_NAME | ERR_SYNTAX);
/* NOTREACHED */
}
for (;;) {
if (!*e)
if (!*e) {
stderror(ERR_NAME | ERR_MISSING, ')');
/* NOTREACHED */
}
if (**e == ')')
break;
e++;
@ -197,8 +205,10 @@ getinx(cp, ip)
*cp++ = 0;
while (*cp && Isdigit(*cp))
*ip = *ip * 10 + *cp++ - '0';
if (*cp++ != ']')
if (*cp++ != ']') {
stderror(ERR_NAME | ERR_SUBSCRIPT);
/* NOTREACHED */
}
return (cp);
}
@ -223,8 +233,10 @@ getvx(vp, subscr)
if (v == 0)
udvar(vp);
if (subscr < 1 || subscr > blklen(v->vec))
if (subscr < 1 || subscr > blklen(v->vec)) {
stderror(ERR_NAME | ERR_RANGE);
/* NOTREACHED */
}
return (v);
}
@ -251,10 +263,14 @@ dolet(v, t)
if (letter(*p))
for (; alnum(*p); p++)
continue;
if (vp == p || !letter(*vp))
if (vp == p || !letter(*vp)) {
stderror(ERR_NAME | ERR_VARBEGIN);
if ((p - vp) > MAXVARLEN)
/* NOTREACHED */
}
if ((p - vp) > MAXVARLEN) {
stderror(ERR_NAME | ERR_VARTOOLONG);
/* NOTREACHED */
}
if (*p == '[') {
hadsub++;
p = getinx(p, &subscr);
@ -263,11 +279,15 @@ dolet(v, t)
p = *v++;
if ((op = *p) != '\0')
*p++ = 0;
else
else {
stderror(ERR_NAME | ERR_ASSIGN);
/* NOTREACHED */
}
if (*p == '\0' && *v == NULL)
if (*p == '\0' && *v == NULL) {
stderror(ERR_NAME | ERR_ASSIGN);
/* NOTREACHED */
}
vp = Strsave(vp);
if (op == '=') {
@ -277,19 +297,24 @@ dolet(v, t)
else {
c = *p++;
if (any("+-", c)) {
if (c != op || *p)
if (c != op || *p) {
stderror(ERR_NAME | ERR_UNKNOWNOP);
/* NOTREACHED */
}
p = Strsave(STR1);
}
else {
if (any("<>", op)) {
if (c != op)
if (c != op) {
stderror(ERR_NAME | ERR_UNKNOWNOP);
/* NOTREACHED */
}
c = *p++;
stderror(ERR_NAME | ERR_SYNTAX);
}
if (c != '=')
stderror(ERR_NAME | ERR_UNKNOWNOP);
/* NOTREACHED */
p = xset(p, &v);
}
}
@ -353,8 +378,10 @@ operate(op, vp, p)
*v++ = p;
*v++ = 0;
i = expr(&vecp);
if (*vecp)
if (*vecp) {
stderror(ERR_NAME | ERR_EXPRESSION);
/* NOTREACHED */
}
return (putn(i));
}
@ -415,14 +442,18 @@ getn(cp)
if (*cp == '-') {
sign++;
cp++;
if (!Isdigit(*cp))
if (!Isdigit(*cp)) {
stderror(ERR_NAME | ERR_BADNUM);
/* NOTREACHED */
}
}
n = 0;
while (Isdigit(*cp))
n = n * 10 + *cp++ - '0';
if (*cp)
if (*cp) {
stderror(ERR_NAME | ERR_BADNUM);
/* NOTREACHED */
}
return (sign ? -n : n);
}
@ -498,7 +529,7 @@ set1(var, vec, head)
if (vec == 0) {
blkfree(oldv);
stderror(ERR_NAME | ERR_NOMATCH);
return;
/* NOTREACHED */
}
blkfree(oldv);
gargv = 0;
@ -650,8 +681,10 @@ shift(v, t)
argv = adrof(name);
if (argv == 0)
udvar(name);
if (argv->vec[0] == 0)
if (argv->vec[0] == 0) {
stderror(ERR_NAME | ERR_NOMORE);
/* NOTREACHED */
}
lshift(argv->vec, 1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: str.c,v 1.9 1998/07/26 19:37:11 mycroft Exp $ */
/* $NetBSD: str.c,v 1.10 1998/07/28 02:23:40 mycroft Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)str.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: str.c,v 1.9 1998/07/26 19:37:11 mycroft Exp $");
__RCSID("$NetBSD: str.c,v 1.10 1998/07/28 02:23:40 mycroft Exp $");
#endif
#endif /* not lint */
@ -321,7 +321,6 @@ s_strncmp(str1, str2, n)
return (1);
else
return (*str1 - *str2);
break;
}
if (*str1 == '\0')
return(0);