Module Name:    src
Committed By:   snj
Date:           Tue Aug  4 20:04:40 UTC 2009

Modified Files:
        src/lib/libterm [netbsd-5]: termcap.3 termcap.c

Log Message:
Pull up following revision(s) (requested by bad in ticket #875):
        lib/libterm/termcap.3: revision 1.33
        lib/libterm/termcap.c: revision 1.55
Only add the ZZ capability for termcap entries that are larger than 1023
bytes.
This fixes the problem that enabling the titeInhibit Xresource of xterm has
no effect, because xterm exports a TERMCAP string without ti/te sequences
but doesn't remove the ZZ capability because it doesn't know about it and
termcap(3) ignores the stringe because of the ZZ.
Discussed with and OK'ed by bl...@.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.32.18.1 src/lib/libterm/termcap.3
cvs rdiff -u -r1.54 -r1.54.18.1 src/lib/libterm/termcap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libterm/termcap.3
diff -u src/lib/libterm/termcap.3:1.32 src/lib/libterm/termcap.3:1.32.18.1
--- src/lib/libterm/termcap.3:1.32	Mon Dec 18 13:27:25 2006
+++ src/lib/libterm/termcap.3	Tue Aug  4 20:04:39 2009
@@ -1,4 +1,4 @@
-.\"	$NetBSD: termcap.3,v 1.32 2006/12/18 13:27:25 kleink Exp $
+.\"	$NetBSD: termcap.3,v 1.32.18.1 2009/08/04 20:04:39 snj Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -468,7 +468,8 @@
 .Fa entry
 is assumed to be a valid termcap entry.
 .Pp
-NOTE: A special capability of
+NOTE: For termcap entries that are larger than 1023 bytes a special
+capability of
 .Fa ZZ
 is added to the end of the termcap entry retrieved.
 The number that follows this entry is the address of the buffer allocated

Index: src/lib/libterm/termcap.c
diff -u src/lib/libterm/termcap.c:1.54 src/lib/libterm/termcap.c:1.54.18.1
--- src/lib/libterm/termcap.c:1.54	Tue Dec 19 02:02:03 2006
+++ src/lib/libterm/termcap.c	Tue Aug  4 20:04:39 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: termcap.c,v 1.54 2006/12/19 02:02:03 uwe Exp $	*/
+/*	$NetBSD: termcap.c,v 1.54.18.1 2009/08/04 20:04:39 snj Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)termcap.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: termcap.c,v 1.54 2006/12/19 02:02:03 uwe Exp $");
+__RCSID("$NetBSD: termcap.c,v 1.54.18.1 2009/08/04 20:04:39 snj Exp $");
 #endif
 #endif /* not lint */
 
@@ -281,29 +281,32 @@
 
 	if (i == 1) {
 		/*
+		 * if the termcap entry is larger than 1023 bytes,
 		 * stash the full buffer pointer as the ZZ capability
 		 * in the termcap buffer passed.
 		 */
-                plen = asprintf(&ptrbuf, ":ZZ=%p", fbuf->info);
-		(void)strlcpy(bp, fbuf->info, 1024);
-                elen = strlen(bp);
-		/*
-		 * backup over the entry if the addition of the full
-		 * buffer pointer will overflow the buffer passed.  We
-		 * want to truncate the termcap entry on a capability
-		 * boundary.
-		 */
-                if ((elen + plen) > 1023) {
-			bp[1023 - plen] = '\0';
-			for (c = (elen - plen); c > 0; c--) {
-				if (bp[c] == ':') {
-					bp[c] = '\0';
-					break;
+		if (strlcpy(bp, fbuf->info, 1024) >= 1024) {
+			plen = asprintf(&ptrbuf, ":ZZ=%p", fbuf->info);
+			(void)strlcpy(bp, fbuf->info, 1024);
+			elen = strlen(bp);
+			/*
+			 * backup over the entry if the addition of the full
+			 * buffer pointer will overflow the buffer passed.  We
+			 * want to truncate the termcap entry on a capability
+			 * boundary.
+			 */
+			if ((elen + plen) > 1023) {
+				bp[1023 - plen] = '\0';
+				for (c = (elen - plen); c > 0; c--) {
+					if (bp[c] == ':') {
+						bp[c] = '\0';
+						break;
+					}
 				}
+
 			}
+			strcat(bp, ptrbuf);
 		}
-
-		strcat(bp, ptrbuf);
                 tbuf = bp;
 	}
 

Reply via email to