summaryrefslogtreecommitdiffstats
path: root/usr.bin/vis
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-08-25 06:37:37 +0000
committercharnier <charnier@FreeBSD.org>1997-08-25 06:37:37 +0000
commitbfcfa0d6a62c9eb5fcfe57efff52dfcc0b3b2ba7 (patch)
tree1d3d8d3a3431100611f720deba7591ca63b23de4 /usr.bin/vis
parenteee8c72e1ae1db05598ec258788425d0a0019356 (diff)
downloadFreeBSD-src-bfcfa0d6a62c9eb5fcfe57efff52dfcc0b3b2ba7.zip
FreeBSD-src-bfcfa0d6a62c9eb5fcfe57efff52dfcc0b3b2ba7.tar.gz
Use err(3). Add usage() and prototypes.
Diffstat (limited to 'usr.bin/vis')
-rw-r--r--usr.bin/vis/foldit.c7
-rw-r--r--usr.bin/vis/vis.18
-rw-r--r--usr.bin/vis/vis.c47
3 files changed, 42 insertions, 20 deletions
diff --git a/usr.bin/vis/foldit.c b/usr.bin/vis/foldit.c
index 86f360c..2bbf15d 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 <stdio.h>
+
+int
foldit(chunk, col, max)
char *chunk;
{
diff --git a/usr.bin/vis/vis.1 b/usr.bin/vis/vis.1
index 6adb4e0..2e54e92 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 93bda20..edead01 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 <err.h>
+#include <locale.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <vis.h>
-#include <locale.h>
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);
OpenPOWER on IntegriCloud