From cejkar@dcse.fee.vutbr.cz  Sat Dec 11 09:40:50 1999
Return-Path: <cejkar@dcse.fee.vutbr.cz>
Received: from boco.fee.vutbr.cz (boco.fee.vutbr.cz [147.229.9.11])
	by hub.freebsd.org (Postfix) with ESMTP id 2E08A14E99
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 11 Dec 1999 09:40:48 -0800 (PST)
	(envelope-from cejkar@dcse.fee.vutbr.cz)
Received: from kazi.dcse.fee.vutbr.cz (kazi.dcse.fee.vutbr.cz [147.229.8.12])
	by boco.fee.vutbr.cz (8.9.3/8.9.3) with ESMTP id SAA58626
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 11 Dec 1999 18:40:46 +0100 (CET)
Received: (from cejkar@localhost)
	by kazi.dcse.fee.vutbr.cz (8.9.3/8.9.3) id SAA74237;
	Sat, 11 Dec 1999 18:40:45 +0100 (CET)
Message-Id: <199912111740.SAA74237@kazi.dcse.fee.vutbr.cz>
Date: Sat, 11 Dec 1999 18:40:45 +0100 (CET)
From: cejkar@dcse.fee.vutbr.cz
Reply-To: cejkar@dcse.fee.vutbr.cz
To: FreeBSD-gnats-submit@freebsd.org
Subject: tput(1) doesn't work with new libncurses.so.5
X-Send-Pr-Version: 3.2

>Number:         15418
>Category:       bin
>Synopsis:       tput(1) doesn't work with new libncurses.so.5
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 11 09:50:01 PST 1999
>Closed-Date:    Sat Aug 17 07:56:10 PDT 2002
>Last-Modified:  Sat Aug 17 07:56:10 PDT 2002
>Originator:     Rudolf Cejka
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
Brno University of Technology, FEE&CS, Czech Republic
>Environment:

4.0-CURRENT, Dec 10 1999

>Description:

This is similar problem to bin/14202, but instead of Emacs the problem
is in tput(1): It parses a result of tgetstr() and expects a termcap
format. But new ncurses library returns the result in a terminfo format.
(Parsing is needed for discovering a number of parameters.)

>How-To-Repeat:

# tput cm 0 0
tput: unknown % escape `p' for capability `cm'
tput: unknown % escape `p' for capability `cm'

>Fix:

Follows patch constructed according to termcap(5):
(Hmm. In tput.c there is no $Id$ nor $FreeBSD$...)

--- tput.c.orig	Sat Dec 11 16:34:23 1999
+++ tput.c	Sat Dec 11 18:11:17 1999
@@ -47,6 +47,7 @@
 #include <termcap.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 #undef putchar
@@ -139,34 +140,40 @@
 	    "too many arguments (%d) for capability `%s'";
 	static char erresc[] =
 	    "unknown %% escape `%c' for capability `%s'";
+	static char errcap[] =
+	    "unexpected end of capability `%s'";
 	char *cp;
 	int arg_need, arg_rows, arg_cols;
 
 	/* Count how many values we need for this capability. */
 	for (cp = str, arg_need = 0; *cp != '\0'; cp++)
 		if (*cp == '%')
-			    switch (*++cp) {
-			    case 'd':
-			    case '2':
-			    case '3':
-			    case '.':
-			    case '+':
-				    arg_need++;
-				    break;
-			    case '%':
-			    case '>':
-			    case 'i':
-			    case 'r':
-			    case 'n':
-			    case 'B':
-			    case 'D':
-				    break;
-			    default:
-				/*
-				 * hpux has lot's of them, but we complain
-				 */
-				 warnx(erresc, *cp, cap);
-			    }
+			switch (*++cp) {
+			case 'p':
+				if (*++cp == '\0') {
+					warnx(errcap, cap);
+					cp--;
+					break;
+				}
+				if (*cp >= '1' && *cp <= '9' && *cp > arg_need)
+					arg_need = *cp - '0';
+				break;
+			case '\'':
+				if (*++cp == '\0') {
+					warnx(errcap, cap);
+					cp--;
+				}
+				break;
+			case '\0':
+				warnx(errcap, cap);
+				cp--;
+				break;
+			default:
+				if (strchr("%:# 0123456789.doxXs" /* + */
+				    "cPg{l+-*/m&|^=><AO!~i?te;", *cp) == NULL)
+					warnx(erresc, *cp, cap);
+				break;
+			}
 
 	/* And print them. */
 	switch (arg_need) {


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: iedowse 
State-Changed-When: Mon Jan 21 13:47:39 PST 2002 
State-Changed-Why:  

Does this problem still exist? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=15418 

From: Ian Dowse <iedowse@maths.tcd.ie>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/15418: tput(1) doesn't work with new libncurses.so.5 
Date: Sun, 02 Jun 2002 13:07:30 +0100

 Add to the audit trail a message I had forgotten about:
 
 In message <20020122124724.A68521@fit.vutbr.cz>, Cejka Rudolf writes:
 >iedowse@FreeBSD.org wrote (2002/01/21):
 >> Synopsis: tput(1) doesn't work with new libncurses.so.5
 >> 
 >> State-Changed-From-To: open->feedback
 >> State-Changed-By: iedowse
 >> State-Changed-When: Mon Jan 21 13:47:39 PST 2002
 >> State-Changed-Why: 
 >> 
 >> Does this problem still exist?
 >> 
 >> http://www.FreeBSD.org/cgi/query-pr.cgi?pr=15418
 >
 >Well, it seems that I should get up now...
 >
 >Right now I have updated my system to FreeBSD 5.0-CURRENT #0:
 >Tue Jan 22 11:12:25 CET 2002. 
 >
 >* Yes, the problem is still here and transition to libncurses.so.5
 >  is still just partial without supporting utilities. Unfortunatelly,
 >  libncurses.so.5 is currently in both -current and -stable, so at
 >  this time it is not a problem just in -current, but in -stable too.
 >
 >* You can test this problem very easily. Run command "tput cm 0 0",
 >  which should move cursor to position 0, 0, and you will see
 >  additional error messages:
 >
 >tput: unknown % escape `p' for capability `cm'
 >tput: unknown % escape `p' for capability `cm'
 >
 >* Furthermore, because of similar problems due to changes in
 >  libncurses.so.5 tercap compilation utility tconv (alias tic
 >  and captoinfo) has been disconnected from build. You can
 >  see /usr/src/usr.bin/Makefile. It is very interesting that
 >  this utility isn't missing to anybody except me ;-)
 >
 >* I do not understand if maintainer (is it you, peter?) wanted
 >  to compile these utilities directly from /usr/src/contrib/ncurses
 >  (tput/tic/infocmp) and forgot on this or he wanted to update
 >  standard BSD sources and does not have time or he does not know
 >  about this???
 >
 >-- 
 >Rudolf Cejka <cejkar at fit.vutbr.cz> http://www.fit.vutbr.cz/~cejkar
 >Brno University of Technology, Faculty of Information Technology
 >Bozetechova 2, 612 66  Brno, Czech Republic
State-Changed-From-To: feedback->analyzed 
State-Changed-By: ache 
State-Changed-When: Mon Jun 3 03:45:04 PDT 2002 
State-Changed-Why:  
Fixed in -current by skipping %pN in tput.c 

http://www.freebsd.org/cgi/query-pr.cgi?pr=15418 
State-Changed-From-To: analyzed->patched 
State-Changed-By: ache 
State-Changed-When: Sat Jun 8 13:03:53 PDT 2002 
State-Changed-Why:  
This PR state must be "patched" according to guideline 

http://www.freebsd.org/cgi/query-pr.cgi?pr=15418 
State-Changed-From-To: patched->closed 
State-Changed-By: tjr 
State-Changed-When: Sat Aug 17 07:53:34 PDT 2002 
State-Changed-Why:  
I've MFC'd ache's fix at the request of Michael Lestinsky. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=15418 
>Unformatted:
