Source-Changes-HG archive

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

[src/netbsd-1-6]: src/usr.sbin/pkg_install/info Pull up revision 1.25 (reques...



details:   https://anonhg.NetBSD.org/src/rev/cdf32d2349b4
branches:  netbsd-1-6
changeset: 528517:cdf32d2349b4
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sun Jul 21 05:00:08 2002 +0000

description:
Pull up revision 1.25 (requested by yamt in ticket #530):
show_file: don't append '\n' if fopen failed.

diffstat:

 usr.sbin/pkg_install/info/show.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (44 lines):

diff -r 66d555a1a1dc -r cdf32d2349b4 usr.sbin/pkg_install/info/show.c
--- a/usr.sbin/pkg_install/info/show.c  Sun Jul 21 04:59:48 2002 +0000
+++ b/usr.sbin/pkg_install/info/show.c  Sun Jul 21 05:00:08 2002 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: show.c,v 1.21.2.2 2002/07/21 04:59:48 lukem Exp $      */
+/*     $NetBSD: show.c,v 1.21.2.3 2002/07/21 05:00:08 lukem Exp $      */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: show.c,v 1.11 1997/10/08 07:47:38 charnier Exp";
 #else
-__RCSID("$NetBSD: show.c,v 1.21.2.2 2002/07/21 04:59:48 lukem Exp $");
+__RCSID("$NetBSD: show.c,v 1.21.2.3 2002/07/21 05:00:08 lukem Exp $");
 #endif
 #endif
 
@@ -104,7 +104,6 @@
        FILE   *fp;
        char    line[1024];
        int     n;
-       int     have_nl = 0;
 
        if (!Quiet) {
                printf("%s%s", InfoPrefix, title);
@@ -112,14 +111,15 @@
        if ((fp = fopen(fname, "r")) == (FILE *) NULL) {
                printf("ERROR: show_file: Can't open '%s' for reading!\n", fname);
        } else {
+               int append_nl = 0;
                while ((n = fread(line, 1, sizeof(line), fp)) != 0) {
                        fwrite(line, 1, n, stdout);
-                       have_nl = (line[n - 1] == '\n');
+                       append_nl = (line[n - 1] != '\n');
                }
                (void) fclose(fp);
+               if (append_nl)
+                       printf("\n");
        }
-       if (!have_nl)
-               printf("\n");
        printf("\n");           /* just in case */
 }
 



Home | Main Index | Thread Index | Old Index