From 959ab2631ce2d64cd8e704b0942eeb8d4510709b Mon Sep 17 00:00:00 2001 From: christos Date: Mon, 7 Mar 2011 00:27:51 +0000 Subject: [PATCH] Restore historical behavior of tgoto() to return "OOPS" on failure. This is best for now because there are too many programs that don't check the return value of it. Of course cursor motion commands from $TERMCAP have 0 chance of working now, since their % escapes are not translated to terminfo. In the window case %+ expects one param from the stack in the termcap case and two in the terminfo so we barf. We need proper captoinfo handling for the % escapes, like the one in ncurses. Hi Roy :-) --- lib/libterminfo/termcap.3 | 12 +++++++++--- lib/libterminfo/termcap.c | 11 +++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/libterminfo/termcap.3 b/lib/libterminfo/termcap.3 index da08d246ca81..2a3a5cb44425 100644 --- a/lib/libterminfo/termcap.3 +++ b/lib/libterminfo/termcap.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: termcap.3,v 1.4 2010/02/04 09:12:55 wiz Exp $ +.\" $NetBSD: termcap.3,v 1.5 2011/03/07 00:27:51 christos Exp $ .\" .\" Copyright (c) 2009 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd December 7, 2009 +.Dd March 6, 2011 .Dt TERMCAP 3 .Os .Sh NAME @@ -124,7 +124,13 @@ function returns a cursor addressing string decoded from to go to column .Fa destcol in line -.Fa destline . +.Fa destline , +or +.Dq OOPS +if it could not decode +a +.Dv % +sequence. .Sh SEE ALSO .Xr terminfo 3 , .Xr terminfo 5 diff --git a/lib/libterminfo/termcap.c b/lib/libterminfo/termcap.c index e9d422532c72..ecfd6d090c13 100644 --- a/lib/libterminfo/termcap.c +++ b/lib/libterminfo/termcap.c @@ -1,4 +1,4 @@ -/* $NetBSD: termcap.c,v 1.10 2010/10/12 12:49:27 christos Exp $ */ +/* $NetBSD: termcap.c,v 1.11 2011/03/07 00:27:51 christos Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include -__RCSID("$NetBSD: termcap.c,v 1.10 2010/10/12 12:49:27 christos Exp $"); +__RCSID("$NetBSD: termcap.c,v 1.11 2011/03/07 00:27:51 christos Exp $"); #include #include @@ -178,9 +178,12 @@ tgetstr(const char *id, char **area) char * tgoto(const char *cm, int destcol, int destline) { - + static char OOPS[] = "OOPS"; + char *p; + _DIAGASSERT(cm != NULL); - return vtparm(cm, destline, destcol); + p = vtparm(cm, destline, destcol); + return p ? p : OOPS; } static const char *