From: tholo Date: Mon, 9 Dec 1996 01:18:17 +0000 (+0000) Subject: Be smarter about running tgetent() multiple times; bump major as we have X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5a552a66fabefc63b17489f8e5ee5c0c5983d8eb;p=openbsd Be smarter about running tgetent() multiple times; bump major as we have a binary incompatibility --- diff --git a/lib/libtermlib/getterm.c b/lib/libtermlib/getterm.c index f0ea6d83099..c6216ab02c5 100644 --- a/lib/libtermlib/getterm.c +++ b/lib/libtermlib/getterm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getterm.c,v 1.11 1996/09/03 16:04:57 deraadt Exp $ */ +/* $OpenBSD: getterm.c,v 1.12 1996/12/09 01:18:17 tholo Exp $ */ /* * Copyright (c) 1996 SigmaSoft, Th. Lockert @@ -31,7 +31,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: getterm.c,v 1.11 1996/09/03 16:04:57 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: getterm.c,v 1.12 1996/12/09 01:18:17 tholo Exp $"; #endif #include @@ -143,11 +143,17 @@ _ti_gettermcap(name) char *s; if ((s = home = strchr(dummy, ':')) == NULL) { - cur_term->name = strdup(name); + cur_term->name = cur_term->names = strdup(name); strncpy(ttytype, name, MAXSIZE - 1); ttytype[MAXSIZE - 1] = '\0'; } else { + int n; + + n = s - dummy - (dummy[2] == '|' ? 3 : 0); + cur_term->names = malloc(n + 1); + strncpy(cur_term->names, dummy + (dummy[2] == '|' ? 3 : 0), n); + cur_term->names[n] = '\0'; strncpy(ttytype, dummy + (dummy[2] == '|' ? 3 : 0), MIN(MAXSIZE - 1, s - dummy)); ttytype[MAXSIZE - 1] = '\0'; @@ -286,11 +292,17 @@ _ti_getterminfo(name) char *s; if ((s = home = strchr(dummy, ':')) == NULL) { - cur_term->name = strdup(name); + cur_term->name = cur_term->names = strdup(name); strncpy(ttytype, name, MAXSIZE - 1); ttytype[MAXSIZE - 1] = '\0'; } else { + int n; + + n = s - dummy - (dummy[2] == '|' ? 3 : 0); + cur_term->names = malloc(n + 1); + strncpy(cur_term->names, dummy + (dummy[2] == '|' ? 3 : 0), n); + cur_term->names[n] = '\0'; strncpy(ttytype, dummy + (dummy[2] == '|' ? 3 : 0), MIN(MAXSIZE - 1, s - dummy)); ttytype[MAXSIZE - 1] = '\0'; diff --git a/lib/libtermlib/globals.c b/lib/libtermlib/globals.c index 33197ce30e8..2d5b6f5dcb2 100644 --- a/lib/libtermlib/globals.c +++ b/lib/libtermlib/globals.c @@ -1,4 +1,4 @@ -/* $OpenBSD: globals.c,v 1.3 1996/09/16 02:41:53 tholo Exp $ */ +/* $OpenBSD: globals.c,v 1.4 1996/12/09 01:18:17 tholo Exp $ */ /* * Copyright (c) 1996 SigmaSoft, Th. Lockert @@ -31,13 +31,13 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: globals.c,v 1.3 1996/09/16 02:41:53 tholo Exp $"; +static char rcsid[] = "$OpenBSD: globals.c,v 1.4 1996/12/09 01:18:17 tholo Exp $"; #endif #include "term.h" TERMINAL _ti_empty = { - -1, 9600, { 0 }, { 0 }, "dumb", { 0 }, { 80, 0, 24 }, { 0 } + -1, 9600, { 0 }, { 0 }, "dumb", "dumb", { 0 }, { 80, 0, 24 }, { 0 } }; TERMINAL *cur_term = &_ti_empty; diff --git a/lib/libtermlib/shlib_version b/lib/libtermlib/shlib_version index 1edea46de91..b52599a164f 100644 --- a/lib/libtermlib/shlib_version +++ b/lib/libtermlib/shlib_version @@ -1,2 +1,2 @@ -major=1 +major=2 minor=0 diff --git a/lib/libtermlib/term.h.tail b/lib/libtermlib/term.h.tail index cdbc5e39c43..dccac8931ec 100644 --- a/lib/libtermlib/term.h.tail +++ b/lib/libtermlib/term.h.tail @@ -1,5 +1,5 @@ -/* $OpenBSD: term.h.tail,v 1.2 1996/06/18 20:29:41 tholo Exp $ */ +/* $OpenBSD: term.h.tail,v 1.3 1996/12/09 01:18:18 tholo Exp $ */ /* * Copyright (c) 1996 SigmaSoft, Th. Lockert @@ -12,6 +12,7 @@ typedef struct _terminal { struct termios pmode; struct termios smode; char *name; + char *names; char bools[_tBoolCnt]; short nums[_tNumCnt]; char *strs[_tStrCnt]; diff --git a/lib/libtermlib/tgetent.c b/lib/libtermlib/tgetent.c index e2a5a5e61c6..91a3ea8ddec 100644 --- a/lib/libtermlib/tgetent.c +++ b/lib/libtermlib/tgetent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tgetent.c,v 1.2 1996/07/22 03:13:55 tholo Exp $ */ +/* $OpenBSD: tgetent.c,v 1.3 1996/12/09 01:18:19 tholo Exp $ */ /* * Copyright (c) 1996 SigmaSoft, Th. Lockert @@ -31,10 +31,11 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: tgetent.c,v 1.2 1996/07/22 03:13:55 tholo Exp $"; +static char rcsid[] = "$OpenBSD: tgetent.c,v 1.3 1996/12/09 01:18:19 tholo Exp $"; #endif #include +#include #include #include #include "term.h" @@ -47,9 +48,15 @@ tgetent(bp, name) char *bp; const char *name; { + char *n; + _ti_buf = bp; - if (cur_term != NULL) + if (cur_term != NULL) { + for (n = strtok(cur_term->names, "|"); n != NULL; n = strtok(NULL, "|")) + if (strcmp(name, n) == 0) + return 1; del_curterm(cur_term); + } if ((cur_term = calloc(sizeof(TERMINAL), 1)) == NULL) errx(1, "No memory for terminal description"); if (isatty(STDOUT_FILENO))