Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/pr ANSIfy, static + __dead



details:   https://anonhg.NetBSD.org/src/rev/1ff072ed1f31
branches:  trunk
changeset: 769322:1ff072ed1f31
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Sep 06 18:26:06 2011 +0000

description:
ANSIfy, static + __dead

diffstat:

 usr.bin/pr/egetopt.c |   11 +-
 usr.bin/pr/extern.h  |   23 +---
 usr.bin/pr/pr.c      |  283 ++++++++++++++++++++++----------------------------
 3 files changed, 131 insertions(+), 186 deletions(-)

diffs (truncated from 683 to 300 lines):

diff -r f9fce20780bf -r 1ff072ed1f31 usr.bin/pr/egetopt.c
--- a/usr.bin/pr/egetopt.c      Tue Sep 06 18:25:14 2011 +0000
+++ b/usr.bin/pr/egetopt.c      Tue Sep 06 18:26:06 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: egetopt.c,v 1.8 2009/04/13 00:37:05 lukem Exp $        */
+/*     $NetBSD: egetopt.c,v 1.9 2011/09/06 18:26:06 joerg Exp $        */
 
 /*-
  * Copyright (c) 1991 Keith Muller.
@@ -38,7 +38,7 @@
 #if 0
 from: static char sccsid[] = "@(#)egetopt.c    8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: egetopt.c,v 1.8 2009/04/13 00:37:05 lukem Exp $");
+__RCSID("$NetBSD: egetopt.c,v 1.9 2011/09/06 18:26:06 joerg Exp $");
 #endif
 #endif /* not lint */
 
@@ -67,13 +67,10 @@
 char   *eoptarg;               /* argument associated with option */
 
 #define        BADCH   (int)'?'
-char EMSG[1] = { '\0' };
+static char EMSG[1] = { '\0' };
 
 int
-egetopt(nargc, nargv, ostr)
-       int nargc;
-       char * const *nargv;
-       const char *ostr;
+egetopt(int nargc, char * const *nargv, const char *ostr)
 {
        static char *place = EMSG;      /* option letter processing */
        char *oli;                      /* option letter list index */
diff -r f9fce20780bf -r 1ff072ed1f31 usr.bin/pr/extern.h
--- a/usr.bin/pr/extern.h       Tue Sep 06 18:25:14 2011 +0000
+++ b/usr.bin/pr/extern.h       Tue Sep 06 18:26:06 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.5 2009/04/13 00:37:05 lukem Exp $ */
+/*     $NetBSD: extern.h,v 1.6 2011/09/06 18:26:06 joerg Exp $ */
 
 /*-
  * Copyright (c) 1991 Keith Muller.
@@ -33,27 +33,10 @@
  * SUCH DAMAGE.
  *
  *      from: @(#)extern.h     8.1 (Berkeley) 6/6/93
- *     $NetBSD: extern.h,v 1.5 2009/04/13 00:37:05 lukem Exp $
+ *     $NetBSD: extern.h,v 1.6 2011/09/06 18:26:06 joerg Exp $
  */
 
 extern int eoptind;
 extern char *eoptarg;
 
-void    addnum __P((char *, int, int));
-int     egetopt __P((int, char * const *, const char *));
-void    flsh_errs __P((void));
-int     horzcol __P((int, char **));
-int     inln __P((FILE *, char *, int, int *, int, int *));
-int     inskip __P((FILE *, int, int));
-void    mfail __P((void));
-int     mulfile __P((int, char **));
-FILE   *nxtfile __P((int, char **, const char **, char *, int));
-int     onecol __P((int, char **));
-int     otln __P((char *, int, int *, int *, int));
-void    pfail __P((void));
-int     prhead __P((char *, const char *, int));
-int     prtail __P((int, int));
-int     setup __P((int, char **));
-void    terminate __P((int));
-void    usage __P((void));
-int     vertcol __P((int, char **));
+int     egetopt(int, char * const *, const char *);
diff -r f9fce20780bf -r 1ff072ed1f31 usr.bin/pr/pr.c
--- a/usr.bin/pr/pr.c   Tue Sep 06 18:25:14 2011 +0000
+++ b/usr.bin/pr/pr.c   Tue Sep 06 18:26:06 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr.c,v 1.20 2009/04/13 00:37:05 lukem Exp $    */
+/*     $NetBSD: pr.c,v 1.21 2011/09/06 18:26:06 joerg Exp $    */
 
 /*-
  * Copyright (c) 1991 Keith Muller.
@@ -43,7 +43,7 @@
 #if 0
 from: static char sccsid[] = "@(#)pr.c 8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: pr.c,v 1.20 2009/04/13 00:37:05 lukem Exp $");
+__RCSID("$NetBSD: pr.c,v 1.21 2011/09/06 18:26:06 joerg Exp $");
 #endif
 #endif /* not lint */
 
@@ -77,43 +77,57 @@
 /*
  * parameter variables
  */
-int    pgnm;                   /* starting page number */
-int    clcnt;                  /* number of columns */
-int    colwd;                  /* column data width - multiple columns */
-int    across;                 /* mult col flag; write across page */
-int    dspace;                 /* double space flag */
-char   inchar;                 /* expand input char */
-int    ingap;                  /* expand input gap */
-int    formfeed;               /* use formfeed as trailer */
-char   *header;                /* header name instead of file name */
-char   ochar;                  /* contract output char */
-int    ogap;                   /* contract output gap */
-int    lines;                  /* number of lines per page */
-int    merge;                  /* merge multiple files in output */
-char   nmchar;                 /* line numbering append char */
-int    nmwd;                   /* width of line number field */
-int    offst;                  /* number of page offset spaces */
-int    nodiag;                 /* do not report file open errors */
-char   schar;                  /* text column separation character */
-int    sflag;                  /* -s option for multiple columns */
-int    nohead;                 /* do not write head and trailer */
-int    pgwd;                   /* page width with multiple col output */
-const char *timefrmt = TIMEFMT;        /* time conversion string */
+static int     pgnm;                   /* starting page number */
+static int     clcnt;                  /* number of columns */
+static int     colwd;                  /* column data width - multiple columns */
+static int     across;                 /* mult col flag; write across page */
+static int     dspace;                 /* double space flag */
+static char    inchar;                 /* expand input char */
+static int     ingap;                  /* expand input gap */
+static int     formfeed;               /* use formfeed as trailer */
+static char    *header;                /* header name instead of file name */
+static char    ochar;                  /* contract output char */
+static int     ogap;                   /* contract output gap */
+static int     lines;                  /* number of lines per page */
+static int     merge;                  /* merge multiple files in output */
+static char    nmchar;                 /* line numbering append char */
+static int     nmwd;                   /* width of line number field */
+static int     offst;                  /* number of page offset spaces */
+static int     nodiag;                 /* do not report file open errors */
+static char    schar;                  /* text column separation character */
+static int     sflag;                  /* -s option for multiple columns */
+static int     nohead;                 /* do not write head and trailer */
+static int     pgwd;                   /* page width with multiple col output */
+static const char *timefrmt = TIMEFMT; /* time conversion string */
 
 /*
  * misc globals
  */
-FILE   *err;                   /* error message file pointer */
-int    addone;                 /* page length is odd with double space */
-int    errcnt;                 /* error count on file processing */
-char   digs[] = "0123456789";  /* page number translation map */
+static FILE    *errf;                  /* error message file pointer */
+static int     addone;                 /* page length is odd with double space */
+static int     errcnt;                 /* error count on file processing */
+static const char      digs[] = "0123456789";  /* page number translation map */
 
-int    main __P((int, char **));
+static void     addnum(char *, int, int);
+static void     flsh_errs(void);
+static int      horzcol(int, char **);
+static int      inln(FILE *, char *, int, int *, int, int *);
+static int      inskip(FILE *, int, int);
+static void     mfail(void);
+static int      mulfile(int, char **);
+static FILE    *nxtfile(int, char **, const char **, char *, int);
+static int      onecol(int, char **);
+static int      otln(char *, int, int *, int *, int);
+static void     pfail(void);
+static int      prhead(char *, const char *, int);
+static int      prtail(int, int);
+static int      setup(int, char **);
+__dead static void      terminate(int);
+static void     usage(void);
+static int      vertcol(int, char **);
 
 int
-main(argc, argv)
-        int argc;
-        char *argv[];
+main(int argc, char *argv[])
 {
        int ret_val;
 
@@ -144,10 +158,8 @@
  * onecol:     print files with only one column of output.
  *             Line length is unlimited.
  */
-int
-onecol(argc, argv)
-        int argc;
-        char *argv[];
+static int
+onecol(int argc, char *argv[])
 {
        int cnt = -1;
        int off;
@@ -285,10 +297,8 @@
 oomem:
        mfail();
 out:
-       if (obuf)
-               free(obuf);
-       if (hbuf)
-               free(hbuf);
+       free(obuf);
+       free(hbuf);
        if (inf != NULL && inf != stdin)
                (void)fclose(inf);
        return error;
@@ -297,10 +307,8 @@
 /*
  * vertcol:    print files with more than one column of output down a page
  */
-int
-vertcol(argc, argv)
-        int argc;
-        char *argv[];
+static int
+vertcol(int argc, char *argv[])
 {
        char *ptbf;
        char **lstdat = NULL;
@@ -607,16 +615,11 @@
 oomem:
        mfail();
 out:
-       if (buf)
-               free(buf);
-       if (hbuf)
-               free(hbuf);
-       if (vc)
-               free(vc);
-       if (lstdat)
-               free(lstdat);
-       if (indy)
-               free(lindy);
+       free(buf);
+       free(hbuf);
+       free(vc);
+       free(lstdat);
+       free(lindy);
        if (inf != NULL && inf != stdin)
                (void)fclose(inf);
        return error;
@@ -625,10 +628,8 @@
 /*
  * horzcol:    print files with more than one column of output across a page
  */
-int
-horzcol(argc, argv)
-        int argc;
-        char *argv[];
+static int
+horzcol(int argc, char *argv[])
 {
        char *ptbf;
        int pln;
@@ -763,10 +764,8 @@
 oomem:
        mfail();
 out:
-       if (buf)
-               free(buf);
-       if (hbuf)
-               free(hbuf);
+       free(buf);
+       free(hbuf);
        if (inf != NULL && inf != stdin)
                (void)fclose(inf);
        return error;
@@ -776,10 +775,8 @@
  * mulfile:    print files with more than one column of output and
  *             more than one file concurrently
  */
-int
-mulfile(argc, argv)
-        int argc;
-        char *argv[];
+static int
+mulfile(int argc, char *argv[])
 {
        char *ptbf;
        int j;
@@ -850,7 +847,7 @@
                pgwd = ((colwd + 1) * clcnt) - 1;
        }
        if (colwd < 1) {
-               (void)fprintf(err,
+               (void)fprintf(errf,
                  "pr: page width too small for %d columns\n", clcnt);
                goto out;
        }
@@ -982,10 +979,8 @@
                                (void)fclose(fbuf[j]);
                free(fbuf);
        }
-       if (hbuf)
-               free(hbuf);
-       if (buf)
-               free(buf);
+       free(hbuf);
+       free(buf);
        return error;
 }



Home | Main Index | Thread Index | Old Index