Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/ul Use new termcap interface.
details: https://anonhg.NetBSD.org/src/rev/c3384794f090
branches: trunk
changeset: 486768:c3384794f090
user: blymn <blymn%NetBSD.org@localhost>
date: Sun May 28 10:27:13 2000 +0000
description:
Use new termcap interface.
diffstat:
usr.bin/ul/ul.c | 53 +++++++++++++++++++++++++++++------------------------
1 files changed, 29 insertions(+), 24 deletions(-)
diffs (118 lines):
diff -r 12f26a4a4ac5 -r c3384794f090 usr.bin/ul/ul.c
--- a/usr.bin/ul/ul.c Sun May 28 10:25:25 2000 +0000
+++ b/usr.bin/ul/ul.c Sun May 28 10:27:13 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ul.c,v 1.9 2000/04/14 06:11:10 simonb Exp $ */
+/* $NetBSD: ul.c,v 1.10 2000/05/28 10:27:13 blymn Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)ul.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: ul.c,v 1.9 2000/04/14 06:11:10 simonb Exp $");
+__RCSID("$NetBSD: ul.c,v 1.10 2000/05/28 10:27:13 blymn Exp $");
#endif /* not lint */
#include <stdio.h>
@@ -67,6 +67,7 @@
#define UNDERL 010 /* Ul */
#define BOLD 020 /* Bold */
+struct tinfo *info;
int must_use_uc, must_overstrike;
char *CURS_UP, *CURS_RIGHT, *CURS_LEFT,
*ENTER_STANDOUT, *EXIT_STANDOUT, *ENTER_UNDERLINE, *EXIT_UNDERLINE,
@@ -108,7 +109,6 @@
int c;
char *termtype;
FILE *f;
- char termcap[1024];
termtype = getenv("TERM");
if (termtype == NULL || (argv[0][0] == 'c' && !isatty(1)))
@@ -131,7 +131,7 @@
exit(1);
}
- switch(tgetent(termcap, termtype)) {
+ switch(t_getent(&info, termtype)) {
case 1:
break;
@@ -142,12 +142,17 @@
case 0:
/* No such terminal type - assume dumb */
- (void)strcpy(termcap, "dumb:os:col#80:cr=^M:sf=^J:am:");
+ if (t_setinfo(&info, "dumb:os:col#80:cr=^M:sf=^J:am:") < 0) {
+ fprintf(stderr, "t_setinfo failed, cannot continue\n");
+ exit(1);
+ }
+
break;
}
initcap();
- if ( (tgetflag("os") && ENTER_BOLD==NULL ) ||
- (tgetflag("ul") && ENTER_UNDERLINE==NULL && UNDER_CHAR==NULL))
+ if ( (t_getflag(info, "os") && ENTER_BOLD==NULL ) ||
+ (t_getflag(info, "ul") && ENTER_UNDERLINE==NULL
+ && UNDER_CHAR==NULL))
must_overstrike = 1;
initbuf();
if (optind == argc)
@@ -418,28 +423,28 @@
void
initcap()
{
- static char tcapbuf[512];
- char *bp = tcapbuf;
+ static char *tcapbuf=NULL;
+ char *bp;
/* This nonsense attempts to work with both old and new termcap */
- CURS_UP = tgetstr("up", &bp);
- CURS_RIGHT = tgetstr("ri", &bp);
+ CURS_UP = t_agetstr(info, "up", &tcapbuf, &bp);
+ CURS_RIGHT = t_agetstr(info, "ri", &tcapbuf, &bp);
if (CURS_RIGHT == NULL)
- CURS_RIGHT = tgetstr("nd", &bp);
- CURS_LEFT = tgetstr("le", &bp);
+ CURS_RIGHT = t_agetstr(info, "nd", &tcapbuf, &bp);
+ CURS_LEFT = t_agetstr(info, "le", &tcapbuf, &bp);
if (CURS_LEFT == NULL)
- CURS_LEFT = tgetstr("bc", &bp);
- if (CURS_LEFT == NULL && tgetflag("bs"))
+ CURS_LEFT = t_agetstr(info, "bc", &tcapbuf, &bp);
+ if (CURS_LEFT == NULL && t_getflag(info, "bs"))
CURS_LEFT = "\b";
- ENTER_STANDOUT = tgetstr("so", &bp);
- EXIT_STANDOUT = tgetstr("se", &bp);
- ENTER_UNDERLINE = tgetstr("us", &bp);
- EXIT_UNDERLINE = tgetstr("ue", &bp);
- ENTER_DIM = tgetstr("mh", &bp);
- ENTER_BOLD = tgetstr("md", &bp);
- ENTER_REVERSE = tgetstr("mr", &bp);
- EXIT_ATTRIBUTES = tgetstr("me", &bp);
+ ENTER_STANDOUT = t_agetstr(info, "so", &tcapbuf, &bp);
+ EXIT_STANDOUT = t_agetstr(info, "se", &tcapbuf, &bp);
+ ENTER_UNDERLINE = t_agetstr(info, "us", &tcapbuf, &bp);
+ EXIT_UNDERLINE = t_agetstr(info, "ue", &tcapbuf, &bp);
+ ENTER_DIM = t_agetstr(info, "mh", &tcapbuf, &bp);
+ ENTER_BOLD = t_agetstr(info, "md", &tcapbuf, &bp);
+ ENTER_REVERSE = t_agetstr(info, "mr", &tcapbuf, &bp);
+ EXIT_ATTRIBUTES = t_agetstr(info, "me", &tcapbuf, &bp);
if (!ENTER_BOLD && ENTER_REVERSE)
ENTER_BOLD = ENTER_REVERSE;
@@ -464,7 +469,7 @@
* letters the 37 has.
*/
- UNDER_CHAR = tgetstr("uc", &bp);
+ UNDER_CHAR = t_agetstr(info, "uc", &tcapbuf, &bp);
must_use_uc = (UNDER_CHAR && !ENTER_UNDERLINE);
}
Home |
Main Index |
Thread Index |
Old Index