From d2e7017adfac394b475c39572724f946b6a86df9 Mon Sep 17 00:00:00 2001 From: charnier Date: Wed, 20 Aug 1997 11:01:59 +0000 Subject: [PATCH] Use err(3), add usage() and prototypes. Move setmode() to setnewmode() because of a conflict with setmode(2 or 3). --- usr.bin/ul/ul.1 | 2 +- usr.bin/ul/ul.c | 78 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 26 deletions(-) diff --git a/usr.bin/ul/ul.1 b/usr.bin/ul/ul.1 index 953dd1721cea..3d525b948de5 100644 --- a/usr.bin/ul/ul.1 +++ b/usr.bin/ul/ul.1 @@ -56,7 +56,7 @@ If the terminal is incapable of underlining, but is capable of a standout mode then that is used instead. If the terminal can overstrike, or handles underlining automatically, -.Nm ul +.Nm degenerates to .Xr cat 1 . If the terminal cannot underline, underlining is ignored. diff --git a/usr.bin/ul/ul.c b/usr.bin/ul/ul.c index cf9f9efebe2a..19a74e6b56ad 100644 --- a/usr.bin/ul/ul.c +++ b/usr.bin/ul/ul.c @@ -32,16 +32,25 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1980, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)ul.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ +#include #include +#include +#include +#include +#include #define IESC '\033' #define SO '\016' @@ -75,20 +84,30 @@ int halfpos; int upln; int iflag; -int outchar(); +static void usage __P((void)); +void setnewmode __P((int)); +void initcap __P((void)); +void reverse __P((void)); +int outchar __P((int)); +void fwd __P((void)); +void initbuf __P((void)); +void iattr __P((void)); +void overstrike __P((void)); +void flushln __P((void)); +void filter __P((FILE *)); +void outc __P((int)); + #define PRINT(s) if (s == NULL) /* void */; else tputs(s, 1, outchar) +void main(argc, argv) int argc; char **argv; { - extern int optind; - extern char *optarg; int c; char *termtype; FILE *f; char termcap[1024]; - char *getenv(), *strcpy(); termtype = getenv("TERM"); if (termtype == NULL || (argv[0][0] == 'c' && !isatty(1))) @@ -103,12 +122,8 @@ main(argc, argv) case 'i': iflag = 1; break; - default: - fprintf(stderr, - "usage: %s [ -i ] [ -tTerm ] file...\n", - argv[0]); - exit(1); + usage(); } switch(tgetent(termcap, termtype)) { @@ -117,7 +132,7 @@ main(argc, argv) break; default: - fprintf(stderr,"trouble reading termcap"); + warnx("trouble reading termcap"); /* fall through to ... */ case 0: @@ -134,15 +149,22 @@ main(argc, argv) filter(stdin); else for (; optind