* ul - General underline filter. Converts underlines by
* the standard backspacing method to the code used by the
* particular terminal to underline.
char *stul
, *endul
, *chul
;
main(argc
,argv
) char **argv
; {
/* Figure out kind of terminal and set up special strings. */
termtype
= getenv("TERM");
while (argc
>= 2 && argv
[1][0] == '-') {
case 'T': /* for nroff compatibility */
printf("Bad switch: %s\n",argv
[1]);
switch(tgetent(termcap
, termtype
)) {
case 1: /* All is well */
/* Terminals that don't need any help. */
if (tgetflag("ul") || tgetflag("os"))
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
&&
(!*chul
) && (stul
=tgetstr("so",&cp
)) == NULL
)
if ( (endul
=tgetstr("ue",&cp
)) == NULL
&&
(!*chul
) && (endul
=tgetstr("se",&cp
)) == NULL
)
default:/* error opening/reading termcap */
fprintf(stderr
,"trouble reading termcap");
/* fall through to ... */
case 0: /* No such terminal type - assume dumb */
stul
= endul
= chul
= "";
if (argc
< 2) filter(stdin
);
else for (i
=1; i
<argc
; i
++) {
printf("Can't open %s\n",argv
[i
]);
} else if (c
=='_' && isul
[p
]==0 && buf
[p
]) {
tputs(isul
[p
] ? stul
: endul
, 1, outc
);