static char *sccsid
= "@(#)ul.c 4.1 (Berkeley) %G%";
char *stul
, *endul
, *chul
;
termtype
= getenv("TERM");
while (argc
> 0 && argv
[0][0] == '-') {
case 'T': /* for nroff compatibility */
printf("Usage: ul [ -i ] [ -tTerm ] file...\n");
switch(tgetent(termcap
, termtype
)) {
if ((backspace
= tgetstr("bc",&cp
)) == NULL
)
* Handle terminals that have start underline/stop
* underline sequences, as well as those with
* underline char sequences (we assume the sequence
* moves the cursor forward one character).
* If we can't find underline sequences, we
* settle for standout sequences.
if ((chul
=tgetstr("uc",&cp
)) == NULL
)
if ((stul
=tgetstr("us",&cp
)) == NULL
&& !tgetflag("ul") &&
(!*chul
) && (stul
=tgetstr("so",&cp
)) == NULL
)
if ((endul
=tgetstr("ue",&cp
)) == NULL
&& !tgetflag("ul") &&
(!*chul
) && (endul
=tgetstr("se",&cp
)) == NULL
)
if (chul
==0&&stul
==0&&endul
==0&&tgetflag("ul"))
fprintf(stderr
,"trouble reading termcap");
/* fall through to ... */
/* No such terminal type - assume dumb */
stul
= endul
= chul
= "";
else for (i
=0; i
<argc
; i
++) {
} else if (c
=='_' && isul
[p
]==0 && buf
[p
]) {
tputs(isul
[p
] ? stul
: endul
, 1, outc
);
char linebuf
[BUFSIZ
], genbuf
[BUFSIZ
];
if (freopen(argv
[0], "r", stdin
) == NULL
) {
while (fgets(linebuf
, sizeof linebuf
, stdin
) != 0) {
for (lp
= linebuf
; *lp
; lp
++)
for (lp
= linebuf
; c
= *lp
++;) {
if (c
< ' ' || c
== 0177)
for (lp
= linebuf
; c
= *lp
++;) {
if (gp
>= &genbuf
[BUFSIZ
- 2])
if (gp
>= &genbuf
[BUFSIZ
- 2]) {
fprintf(stderr
, "Line too long\n");
for (lp
= linebuf
, gp
= genbuf
; c
= *lp
; gp
++, lp
++)
while (gp
>= genbuf
&& *gp
== ' ')