Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/hexdump Don't use one function for two different thi...



details:   https://anonhg.NetBSD.org/src/rev/1677b67910c4
branches:  trunk
changeset: 343922:1677b67910c4
user:      dholland <dholland%NetBSD.org@localhost>
date:      Fri Mar 04 02:54:38 2016 +0000

description:
Don't use one function for two different things. Two functions is the
ticket.

diffstat:

 usr.bin/hexdump/display.c |  18 ++++++++++--------
 usr.bin/hexdump/hexdump.c |   6 +++---
 usr.bin/hexdump/hexdump.h |   5 +++--
 3 files changed, 16 insertions(+), 13 deletions(-)

diffs (97 lines):

diff -r 64aaeed61157 -r 1677b67910c4 usr.bin/hexdump/display.c
--- a/usr.bin/hexdump/display.c Fri Mar 04 02:46:19 2016 +0000
+++ b/usr.bin/hexdump/display.c Fri Mar 04 02:54:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: display.c,v 1.23 2016/03/04 02:46:19 dholland Exp $    */
+/*     $NetBSD: display.c,v 1.24 2016/03/04 02:54:38 dholland Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)display.c  8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: display.c,v 1.23 2016/03/04 02:46:19 dholland Exp $");
+__RCSID("$NetBSD: display.c,v 1.24 2016/03/04 02:54:38 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -254,7 +254,7 @@
                 * and no other files are available, zero-pad the rest of the
                 * block and set the end flag.
                 */
-               if (!length || (ateof && !next(NULL))) {
+               if (!length || (ateof && !next())) {
                        if (need == blocksize)
                                return(NULL);
                        if (!need && vflag != ALL &&
@@ -297,16 +297,18 @@
        }
 }
 
+void
+stashargv(char **argv)
+{
+       _argv = argv;
+}
+
 int
-next(char **argv)
+next(void)
 {
        static int done;
        int statok;
 
-       if (argv) {
-               _argv = argv;
-               return(1);
-       }
        for (;;) {
                if (*_argv) {
                        if (!(freopen(*_argv, "r", stdin))) {
diff -r 64aaeed61157 -r 1677b67910c4 usr.bin/hexdump/hexdump.c
--- a/usr.bin/hexdump/hexdump.c Fri Mar 04 02:46:19 2016 +0000
+++ b/usr.bin/hexdump/hexdump.c Fri Mar 04 02:54:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hexdump.c,v 1.18 2012/07/06 09:06:43 wiz Exp $ */
+/*     $NetBSD: hexdump.c,v 1.19 2016/03/04 02:54:38 dholland Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)hexdump.c  8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: hexdump.c,v 1.18 2012/07/06 09:06:43 wiz Exp $");
+__RCSID("$NetBSD: hexdump.c,v 1.19 2016/03/04 02:54:38 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -88,7 +88,7 @@
        for (tfs = fshead; tfs; tfs = tfs->nextfs)
                rewrite(tfs);
 
-       (void)next(argv);
+       stashargv(argv);
        display();
        exit(exitval);
 }
diff -r 64aaeed61157 -r 1677b67910c4 usr.bin/hexdump/hexdump.h
--- a/usr.bin/hexdump/hexdump.h Fri Mar 04 02:46:19 2016 +0000
+++ b/usr.bin/hexdump/hexdump.h Fri Mar 04 02:54:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hexdump.h,v 1.14 2016/03/04 02:46:19 dholland Exp $    */
+/*     $NetBSD: hexdump.h,v 1.15 2016/03/04 02:54:38 dholland Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -88,7 +88,8 @@
 void    doskip(const char *, int);
 void    escape(char *);
 void    hexsyntax(int, char ***);
-int     next(char **);
+void    stashargv(char **);
+int     next(void);
 void    odsyntax(int, char ***);
 void    rewrite(FS *);
 int     size(FS *);



Home | Main Index | Thread Index | Old Index