Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/ppt Tweak the argc/argv usage a bit more, and be a lit...



details:   https://anonhg.NetBSD.org/src/rev/df9d2292a0d0
branches:  trunk
changeset: 539823:df9d2292a0d0
user:      atatat <atatat%NetBSD.org@localhost>
date:      Tue Nov 26 23:07:36 2002 +0000

description:
Tweak the argc/argv usage a bit more, and be a little less eager about
printing newlines.

diffstat:

 games/ppt/ppt.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (61 lines):

diff -r 96cd0198d986 -r df9d2292a0d0 games/ppt/ppt.c
--- a/games/ppt/ppt.c   Tue Nov 26 23:02:37 2002 +0000
+++ b/games/ppt/ppt.c   Tue Nov 26 23:07:36 2002 +0000
@@ -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 @@
 #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 @@
        char **argv;
 {
        char *p, buf[132];
-       int c, start, dflag;
+       int c, start, neednl, dflag;
 
        /* Revoke setgid privileges */
        setgid(getgid());
@@ -98,25 +98,29 @@
                        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);



Home | Main Index | Thread Index | Old Index