Clean up some ambiguous nested if/elses.

This commit is contained in:
billf 1999-07-04 17:26:16 +00:00
parent 7c7c72da38
commit 4822432874
19 changed files with 62 additions and 41 deletions

View File

@ -55,7 +55,7 @@ static char copyright[] =
static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95";
#else
static const char rcsid[] =
"$Id: finger.c,v 1.12 1997/07/02 06:34:48 charnier Exp $";
"$Id: finger.c,v 1.13 1999/05/08 00:46:04 obrien Exp $";
#endif
#endif /* not lint */
@ -208,11 +208,12 @@ main(argc, argv)
if (!sflag)
lflag = 1; /* if -s not explicit, force -l */
}
if (entries)
if (entries) {
if (lflag)
lflag_print();
else
sflag_print();
}
return (0);
}

View File

@ -1,4 +1,4 @@
/* $Id$ */
/* $Id: ruserpass.c,v 1.7 1997/12/13 20:38:20 pst Exp $ */
/* $NetBSD: ruserpass.c,v 1.14.2.1 1997/11/18 01:02:05 mellon Exp $ */
/*
@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
#else
__RCSID("$Id$");
__RCSID("$Id: ruserpass.c,v 1.7 1997/12/13 20:38:20 pst Exp $");
__RCSID_SOURCE("$NetBSD: ruserpass.c,v 1.14.2.1 1997/11/18 01:02:05 mellon Exp $");
#endif
#endif /* not lint */
@ -149,7 +149,7 @@ ruserpass(host, aname, apass, aacct)
while ((t = token()) && t != MACH && t != DEFAULT) switch(t) {
case LOGIN:
if (token())
if (token()) {
if (*aname == NULL) {
*aname = strdup(tokval);
if (*aname == NULL)
@ -158,6 +158,7 @@ ruserpass(host, aname, apass, aacct)
if (strcmp(*aname, tokval))
goto next;
}
}
break;
case PASSWD:
if ((*aname == NULL || strcmp(*aname, "anonymous")) &&

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)odsyntax.c 8.2 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
"$Id: odsyntax.c,v 1.5 1997/07/10 06:48:21 charnier Exp $";
"$Id: odsyntax.c,v 1.6 1997/11/04 05:33:14 ache Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -222,7 +222,7 @@ odoffset(argc, argvp)
return;
}
if (*p)
if (*p) {
if (*p == 'B') {
skip *= 1024;
++p;
@ -230,6 +230,7 @@ odoffset(argc, argvp)
skip *= 512;
++p;
}
}
if (*p) {
skip = 0;

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)id.c 8.2 (Berkeley) 2/16/94";
#endif
static const char rcsid[] =
"$Id: id.c,v 1.6 1998/02/18 17:35:16 steve Exp $";
"$Id: id.c,v 1.7 1998/08/21 06:47:58 obrien Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -181,16 +181,18 @@ pretty(pw)
else
(void)printf("uid\t%u\n", rid);
if ((eid = geteuid()) != rid)
if ((eid = geteuid()) != rid) {
if ((pw = getpwuid(eid)))
(void)printf("euid\t%s\n", pw->pw_name);
else
(void)printf("euid\t%u\n", eid);
if ((rid = getgid()) != (eid = getegid()))
}
if ((rid = getgid()) != (eid = getegid())) {
if ((gr = getgrgid(rid)))
(void)printf("rgid\t%s\n", gr->gr_name);
else
(void)printf("rgid\t%u\n", rid);
}
(void)printf("groups\t");
group(NULL, 1);
}

View File

@ -46,7 +46,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)indent.c 5.17 (Berkeley) 6/7/93";
#endif
static const char rcsid[] =
"$Id: indent.c,v 1.2 1997/07/15 09:50:59 charnier Exp $";
"$Id: indent.c,v 1.3 1998/10/18 04:46:24 thepish Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -208,16 +208,16 @@ main(argc, argv)
else
set_option(argv[i]);
} /* end of for */
if (input == 0) {
if (input == 0)
input = stdin;
}
if (output == 0)
if (output == 0) {
if (troff || input == stdin)
output = stdout;
else {
out_name = in_name;
bakcopy();
}
}
if (ps.com_ind <= 1)
ps.com_ind = 2; /* dont put normal comments before column 2 */
if (troff) {

View File

@ -38,7 +38,7 @@
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: io.c,v 1.3 1997/07/15 09:50:59 charnier Exp $";
#endif /* not lint */
#include <ctype.h>
@ -84,7 +84,7 @@ dump_line()
else if (!inhibit_formatting) {
suppress_blanklines = 0;
ps.bl_line = false;
if (prefix_blankline_requested && not_first_line)
if (prefix_blankline_requested && not_first_line) {
if (swallow_optional_blanklines) {
if (n_real_blanklines == 1)
n_real_blanklines = 0;
@ -93,6 +93,7 @@ dump_line()
if (n_real_blanklines == 0)
n_real_blanklines = 1;
}
}
while (--n_real_blanklines >= 0)
putc('\n', output);
n_real_blanklines = 0;
@ -238,11 +239,12 @@ dump_line()
e_com--;
cur_col = pad_output(cur_col, target);
if (!ps.box_com) {
if (star_comment_cont && (com_st[1] != '*' || e_com <= com_st + 1))
if (star_comment_cont && (com_st[1] != '*' || e_com <= com_st + 1)) {
if (com_st[1] == ' ' && com_st[0] == ' ' && e_com > com_st + 1)
com_st[1] = '*';
else
fwrite(" * ", com_st[0] == '\t' ? 2 : com_st[0] == '*' ? 1 : 3, 1, output);
}
}
fwrite(com_st, e_com - com_st, 1, output);
ps.comment_delta = ps.n_comment_delta;

View File

@ -46,7 +46,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)join.c 8.6 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
"$Id: join.c,v 1.7 1997/07/15 09:57:28 charnier Exp $";
"$Id: join.c,v 1.8 1997/08/19 15:58:15 jlemon Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -458,7 +458,7 @@ outfield(lp, fieldno, out_empty)
{
if (needsep++)
(void)printf("%c", *tabchar);
if (!ferror(stdout))
if (!ferror(stdout)) {
if (lp->fieldcnt <= fieldno || out_empty) {
if (empty != NULL)
(void)printf("%s", empty);
@ -467,6 +467,7 @@ outfield(lp, fieldno, out_empty)
return;
(void)printf("%s", lp->fields[fieldno]);
}
}
if (ferror(stdout))
err(1, "stdout");
}

View File

@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
"$Id: ncal.c,v 1.6 1998/01/15 10:23:34 helbig Exp $";
"$Id: ncal.c,v 1.7 1999/03/27 21:08:13 helbig Exp $";
#endif /* not lint */
#include <calendar.h>
@ -482,7 +482,7 @@ printyear(int y, int jd_flag)
mw, year[j + 2].lines[i],
year[j + 3].lines[i]);
}
if (flag_weeks)
if (flag_weeks) {
if (mpl == 3)
printf(" %-*s%-*s%-s\n",
mw, year[j].weeks,
@ -494,6 +494,7 @@ printyear(int y, int jd_flag)
mw, year[j + 1].weeks,
mw, year[j + 2].weeks,
year[j + 3].weeks);
}
}
}

View File

@ -67,12 +67,13 @@ main(argc, argv)
if (argc < 2)
usage();
if (argv[1][0] == '-')
if (argv[1][0] == '-') {
if (argv[1][1] == '-' || isdigit(argv[1][1])) {
niceness = atoi(argv[1] + 1);
++argv;
} else
errx(1, "illegal option -- %s", argv[1]);
}
if (argv[1] == NULL)
usage();

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)expand.c 8.1 (Berkeley) 6/9/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: expand.c,v 1.6 1998/04/06 06:18:20 charnier Exp $";
#endif /* not lint */
#include "defs.h"
@ -508,7 +508,7 @@ amatch(s, p)
while (*s)
addpath(*s++);
addpath('/');
if (stat(path, &stb) == 0 && ISDIR(stb.st_mode))
if (stat(path, &stb) == 0 && ISDIR(stb.st_mode)) {
if (*p == '\0') {
if (which & E_TILDE)
Cat(path, "");
@ -516,6 +516,7 @@ amatch(s, p)
Cat(tilde, tpathp);
} else
expsh(p);
}
pathp = spathp;
*pathp = '\0';
return (0);

View File

@ -34,7 +34,7 @@
static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI";
#endif
static const char rcsid[] =
"$Id$";
"$Id: rpc_cout.c,v 1.5 1997/08/06 06:47:39 charnier Exp $";
#endif
/*
@ -466,7 +466,7 @@ int flag;
}
}
} else {
if (i > 0)
if (i > 0) {
if (sizestr == NULL && size < inline){
/*
* don't expand into inline code
@ -482,7 +482,7 @@ int flag;
if (sizestr == NULL)
f_print(fout, "buf = XDR_INLINE(xdrs, %d * BYTES_PER_XDR_UNIT);",
size);
else
else {
if (size == 0)
f_print(fout,
"buf = XDR_INLINE(xdrs, (%s) * BYTES_PER_XDR_UNIT);",
@ -492,6 +492,7 @@ int flag;
"buf = XDR_INLINE(xdrs, (%d + (%s)) * BYTES_PER_XDR_UNIT);",
size, sizestr);
}
f_print(fout, "\n");
tabify(fout, indent + 1);
f_print(fout,
@ -514,6 +515,7 @@ int flag;
tabify(fout, indent + 1);
f_print(fout, "}\n");
}
}
size = 0;
i = 0;
sizestr = NULL;

View File

@ -154,7 +154,7 @@ main(argc, argv)
* If style not specified, the default is the whole file for -r, and
* the last 10 lines if not -r.
*/
if (style == NOTSET)
if (style == NOTSET) {
if (rflag) {
off = 0;
style = REVERSE;
@ -162,6 +162,7 @@ main(argc, argv)
off = 10;
style = RLINES;
}
}
if (*argv)
for (first = 1; fname = *argv++;) {

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)tcopy.c 8.2 (Berkeley) 4/17/94";
#endif
static const char rcsid[] =
"$Id: tcopy.c,v 1.4 1997/08/14 06:41:00 charnier Exp $";
"$Id: tcopy.c,v 1.5 1999/04/30 13:13:32 phk Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -282,11 +282,12 @@ void
intr(signo)
int signo;
{
if (record)
if (record) {
if (record - lastrec > 1)
fprintf(msg, "records %qu to %qu\n", lastrec, record);
else
fprintf(msg, "record %qu\n", lastrec);
}
fprintf(msg, "interrupt at file %d: record %qu\n", filen, record);
fprintf(msg, "total length: %ld bytes\n", tsize + size);
exit(1);

View File

@ -129,7 +129,7 @@ main(argc, argv)
for (rval = 0; *argv; ++argv) {
/* See if the file exists. */
if (stat(*argv, &sb))
if (stat(*argv, &sb)) {
if (!cflag) {
/* Create the file. */
fd = open(*argv,
@ -145,6 +145,7 @@ main(argc, argv)
continue;
} else
continue;
}
if (!aflag)
TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec);

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)term.c 8.1 (Berkeley) 6/9/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: term.c,v 1.2 1997/08/18 07:27:56 charnier Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -104,11 +104,12 @@ found: if ((p = getenv("TERMCAP")) != NULL && *p != '/')
* ttype now contains a pointer to the type of the terminal.
* If the first character is '?', ask the user.
*/
if (ttype[0] == '?')
if (ttype[0] == '?') {
if (ttype[1] != '\0')
ttype = askuser(ttype + 1);
else
ttype = askuser(NULL);
}
/* Find the termcap entry. If it doesn't exist, ask the user. */
while ((rval = tgetent(tbuf, ttype)) == 0) {

View File

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: tsort.c,v 1.7 1997/03/11 14:48:14 peter Exp $
* $Id: tsort.c,v 1.8 1997/03/29 04:33:15 imp Exp $
*/
#ifndef lint
@ -340,7 +340,7 @@ tsort()
err(1, NULL);
}
for (n = graph; n != NULL; n = n->n_next)
if (!(n->n_flags & NF_ACYCLIC))
if (!(n->n_flags & NF_ACYCLIC)) {
if ((cnt = find_cycle(n, n, 0, 0))) {
if (!quiet) {
warnx("cycle in data");
@ -356,6 +356,7 @@ tsort()
n->n_flags |= NF_ACYCLIC;
clear_cycle();
}
}
if (n == NULL)
errx(1, "internal error -- could not find cycle");

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)w.c 8.4 (Berkeley) 4/16/94";
#endif
static const char rcsid[] =
"$Id: w.c,v 1.33 1999/03/31 21:01:39 brian Exp $";
"$Id: w.c,v 1.34 1999/04/22 23:40:56 ache Exp $";
#endif /* not lint */
/*
@ -325,7 +325,7 @@ main(argc, argv)
}
}
if (!nflag)
if (!nflag) {
if (gethostname(domain, sizeof(domain) - 1) < 0 ||
(p = strchr(domain, '.')) == 0)
domain[0] = '\0';
@ -333,6 +333,7 @@ main(argc, argv)
domain[sizeof(domain) - 1] = '\0';
memmove(domain, p, strlen(p) + 1);
}
}
for (ep = ehead; ep != NULL; ep = ep->next) {
char host_buf[UT_HOSTSIZE + 1];

View File

@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id: write.c,v 1.9 1997/09/15 00:17:38 ache Exp $";
"$Id: write.c,v 1.10 1997/09/15 00:40:34 ache Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -259,11 +259,12 @@ do_write(tty, mytty, myuid)
char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
/* Determine our login name before the we reopen() stdout */
if ((login = getlogin()) == NULL)
if ((login = getlogin()) == NULL) {
if ((pwd = getpwuid(myuid)))
login = pwd->pw_name;
else
login = "???";
}
(void)snprintf(path, sizeof(path), "%s%s", _PATH_DEV, tty);
if ((freopen(path, "w", stdout)) == NULL)

View File

@ -39,7 +39,7 @@
static char const sccsid[] = "@(#)mkpar.c 5.3 (Berkeley) 1/20/91";
#endif
static const char rcsid[] =
"$Id$";
"$Id: mkpar.c,v 1.7 1997/08/28 06:33:53 charnier Exp $";
#endif /* not lint */
#include <stdlib.h>
@ -245,11 +245,12 @@ unused_rules()
for (i = 3; i < nrules; ++i)
if (!rules_used[i]) ++nunused;
if (nunused)
if (nunused) {
if (nunused == 1)
warnx("1 rule never reduced");
else
warnx("%d rules never reduced", nunused);
}
}