summaryrefslogtreecommitdiffstats
path: root/ppt
diff options
context:
space:
mode:
authoratatat <atatat@NetBSD.org>2002-11-26 23:07:36 +0000
committeratatat <atatat@NetBSD.org>2002-11-26 23:07:36 +0000
commit9ec929594464eb57c26c4b8e054f894991cfb3f9 (patch)
treef0b583a3b7f3f7bef66a4e433cd5c0104436b662 /ppt
parent08f4d4c75d6e36a2cf7991ba93c9716982f438d3 (diff)
downloadbsdgames-darwin-9ec929594464eb57c26c4b8e054f894991cfb3f9.tar.gz
bsdgames-darwin-9ec929594464eb57c26c4b8e054f894991cfb3f9.tar.zst
bsdgames-darwin-9ec929594464eb57c26c4b8e054f894991cfb3f9.zip
Tweak the argc/argv usage a bit more, and be a little less eager about
printing newlines.
Diffstat (limited to 'ppt')
-rw-r--r--ppt/ppt.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ppt/ppt.c b/ppt/ppt.c
index f5a65256..af0585ce 100644
--- a/ppt/ppt.c
+++ b/ppt/ppt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ppt.c,v 1.13 2002/11/26 21:39:18 kim Exp $ */
+/* $NetBSD: ppt.c,v 1.14 2002/11/26 23:07:36 atatat Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\
#if 0
static char sccsid[] = "@(#)ppt.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: ppt.c,v 1.13 2002/11/26 21:39:18 kim Exp $");
+__RCSID("$NetBSD: ppt.c,v 1.14 2002/11/26 23:07:36 atatat Exp $");
#endif
#endif /* not lint */
@@ -74,7 +74,7 @@ main(argc, argv)
char **argv;
{
char *p, buf[132];
- int c, start, dflag;
+ int c, start, neednl, dflag;
/* Revoke setgid privileges */
setgid(getgid());
@@ -98,25 +98,29 @@ main(argc, argv)
usage();
start = 0;
+ neednl = 0;
while (fgets(buf, sizeof(buf), stdin) != NULL) {
c = getppt(buf);
if (c < 0) {
if (start) {
- /* lost sync */
- putchar('\n');
+ /* lost sync? */
+ if (neednl)
+ putchar('\n');
exit(0);
} else
continue;
}
start = 1;
putchar(c);
+ neednl = (c != '\n');
}
if (!feof(stdin))
err(1, "fgets");
- putchar('\n');
+ if (neednl)
+ putchar('\n');
} else {
(void) puts(EDGE);
- if (argc > 1)
+ if (argc > 0)
while ((p = *argv++)) {
for (; *p; ++p)
putppt((int)*p);