diff --git a/usr.bin/vis/foldit.c b/usr.bin/vis/foldit.c index 86f360c6f03d..2bbf15d92f53 100644 --- a/usr.bin/vis/foldit.c +++ b/usr.bin/vis/foldit.c @@ -32,9 +32,16 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)foldit.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ +#include + +int foldit(chunk, col, max) char *chunk; { diff --git a/usr.bin/vis/vis.1 b/usr.bin/vis/vis.1 index 6adb4e0c1a9f..2e54e92606ce 100644 --- a/usr.bin/vis/vis.1 +++ b/usr.bin/vis/vis.1 @@ -38,10 +38,10 @@ .Nm vis .Nd display non-printable characters in a visual format .Sh SYNOPSIS -.Nm vis +.Nm .Op Fl cbflnostw .Op Fl F Ar foldwidth -.Op Ar file ... +.Op Ar .Sh DESCRIPTION .Nm Vis is a filter for converting non-printable characters @@ -67,7 +67,7 @@ Request a format which displays a small subset of the non-printable characters using C-style backslash sequences. .It Fl F Causes -.Nm vis +.Nm to fold output lines to foldwidth columns (default 80), like .Xr fold 1 , except @@ -95,7 +95,7 @@ or is selected. When combined with the .Fl f flag, -.Nm vis +.Nm becomes like an invertible version of the .Xr fold 1 diff --git a/usr.bin/vis/vis.c b/usr.bin/vis/vis.c index 93bda208f114..edead0124b09 100644 --- a/usr.bin/vis/vis.c +++ b/usr.bin/vis/vis.c @@ -32,27 +32,36 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ -#include -#include +#include #include +#include +#include +#include +#include int eflags, fold, foldwidth=80, none, markeol, debug; +void process __P((FILE *, char *filename)); +static void usage __P((void)); +extern int foldit __P((char *, int, int)); + +int main(argc, argv) char *argv[]; { - extern char *optarg; - extern int optind; - extern int errno; FILE *fp; int ch; @@ -82,11 +91,8 @@ main(argc, argv) eflags |= VIS_NOSLASH; break; case 'F': - if ((foldwidth = atoi(optarg))<5) { - fprintf(stderr, - "vis: can't fold lines to less than 5 cols\n"); - exit(1); - } + if ((foldwidth = atoi(optarg))<5) + errx(1, "can't fold lines to less than 5 cols"); /*FALLTHROUGH*/ case 'f': fold++; /* fold output lines to 80 cols */ @@ -101,9 +107,7 @@ main(argc, argv) #endif case '?': default: - fprintf(stderr, - "usage: vis [-nwctsobf] [-F foldwidth]\n"); - exit(1); + usage(); } argc -= optind; argv += optind; @@ -113,8 +117,7 @@ main(argc, argv) if ((fp=fopen(*argv, "r")) != NULL) process(fp, *argv); else - fprintf(stderr, "vis: %s: %s\n", *argv, - (char *)strerror(errno)); + warn("%s", *argv); argv++; } else @@ -122,6 +125,19 @@ main(argc, argv) exit(0); } + +static void +usage() +{ +#ifdef DEBUG + fprintf(stderr, "usage: vis [-cbflnostwd] [-F foldwidth] [file ...]\n"); +#else + fprintf(stderr, "usage: vis [-cbflnostw] [-F foldwidth] [file ...]\n"); +#endif + exit(1); +} + +void process(fp, filename) FILE *fp; char *filename; @@ -129,7 +145,6 @@ process(fp, filename) static int col = 0; register char *cp = "\0"+1; /* so *(cp-1) starts out != '\n' */ register int c, rachar; - register char nc; char buff[5]; c = getc(fp);