From 75e5dfa3fc08288e085341d70369e2de188e7bf6 Mon Sep 17 00:00:00 2001 From: charnier Date: Mon, 24 Jul 2000 20:22:49 +0000 Subject: Start enumerate option with `The following options are available' like most of the utilities. .Nm prog -> .Nm Remove unused include Make use of getopt() instead of parsing params by hand. --- usr.bin/colcrt/colcrt.1 | 8 ++++---- usr.bin/colcrt/colcrt.c | 32 +++++++++++++++----------------- 2 files changed, 19 insertions(+), 21 deletions(-) (limited to 'usr.bin/colcrt') diff --git a/usr.bin/colcrt/colcrt.1 b/usr.bin/colcrt/colcrt.1 index 1167e46..ba7d70c 100644 --- a/usr.bin/colcrt/colcrt.1 +++ b/usr.bin/colcrt/colcrt.1 @@ -51,8 +51,8 @@ is destructive. Half-line characters and underlining (changed to dashing `\-') are placed on new lines in between the normal output lines. .Pp -Available options: -.Bl -tag -width Ds +The following options are available: +.Bl -tag -width indent .It Fl Suppress all underlining. This option is especially useful for previewing @@ -60,7 +60,7 @@ This option is especially useful for previewing tables from .Xr tbl 1 . .It Fl 2 -Causes all half-lines to be printed, effectively double spacing the output. +Cause all half-lines to be printed, effectively double spacing the output. Normally, a minimal space output format is used which will suppress empty lines. The program never suppresses two consecutive empty lines, however. @@ -71,7 +71,7 @@ contains superscripts and subscripts which would otherwise be invisible. .El .Sh EXAMPLES A typical use of -.Nm colcrt +.Nm would be .Bd -literal tbl exum2.n \&| nroff \-ms \&| colcrt \- \&| more diff --git a/usr.bin/colcrt/colcrt.c b/usr.bin/colcrt/colcrt.c index 67f4b06..4b5b525 100644 --- a/usr.bin/colcrt/colcrt.c +++ b/usr.bin/colcrt/colcrt.c @@ -46,7 +46,6 @@ static const char rcsid[] = #endif /* not lint */ #include -#include #include #include #include @@ -86,23 +85,22 @@ main(argc, argv) { int c; char *cp, *dp; + int ch; - argc--; - argv++; - while (argc > 0 && argv[0][0] == '-') { - switch (argv[0][1]) { - case 0: - suppresul = 1; - break; - case '2': - printall = 1; - break; - default: - usage(); + while ((ch = getopt(argc, argv, "-2")) != -1) + switch (ch) { + case '-': + suppresul = 1; + break; + case '2': + printall = 1; + break; + default: + usage(); } - argc--; - argv++; - } + argc -= optind; + argv += optind; + do { if (argc > 0) { close(0); @@ -193,7 +191,7 @@ main(argc, argv) static void usage() { - fprintf(stderr, "usage: colcrt [ - ] [ -2 ] [ file ... ]\n"); + fprintf(stderr, "usage: colcrt [-] [-2] [file ...]\n"); exit(1); } -- cgit v1.1