Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!ssc-vax!uvicctr!tholm
From: tholm@uvicctr.UUCP (Terrence W. Holm)
Newsgroups: comp.os.minix
Subject: termcap(3) fixes
Message-ID: <444@uvicctr.UUCP>
Date: 7 Jul 88 23:50:36 GMT
Reply-To: tholm@uvicctr.UUCP (Terrence W. Holm)
Organization: University of Victoria, Victoria B.C. Canada
Lines: 85

While checking the MINIX 1.3 library patches I noticed that
my fix to termcap(3) has not been applied. Besides missing
a couple of features, the old termcap(3) does not compare
terminal names properly (ie. "vt100" == "vt100-np") and
the ^x escapes are wrong in tgetstr(3).

So here are the patches again, to be applied to the 1.3 termcap(3):

--------------------------------------------------------------------

EFTH Minix report #9  - May 1988 -  termcap(3) fixes


Following are some fixes for the termcap(3) supplied with Minix 1.2a/1.3.

The earlier version will get confused if $TERMCAP is defined, but
$TERM is not the same as the current terminal. The terminal name
was not compared correctly. Also the ^x escapes were incorrect.

We have also made a "man" page for the Minix termcap(3) [available
from the archives.]

--------------------------------------------------------------------
9a10,17
> 
> /*    efth      1988-Apr-29
> 
>     - Correct when TERM != name and TERMCAP is defined   [tgetent]
>     - Correct the comparison for the terminal name       [tgetent]
>     - Correct the value of ^x escapes                    [tgetstr]
> */
> 
44,54c52,73
< 	if ((file = getenv("TERMCAP")) != (char *) NULL) {
< 		if (*file != '/' &&
< 		    (cp = getenv("TERM")) != NULL && strcmp(name, cp) == 0) {
< 			(void) strcpy(bp, file);
< 			return(1);
< 		}
< 	} else
< 		file = "/etc/termcap";
< 	if ((fp = fopen(file, "r")) == (FILE *) NULL)
< 		return(-1); 
< 	while (fgets(bp, 1024, fp) != NULL) {
---
> 
> 	/* Fixed problem: If TERM != name and TERMCAP was defined,  */
> 	/* then should look in /etc/termcap, but didn't.  (efth)    */
> 
> 	if ( (file = getenv("TERMCAP")) == NULL )
> 	    file = "/etc/termcap";
> 	else if ( *file != '/' )
> 	    if ( (cp = getenv("TERM")) != NULL && strcmp( name, cp ) == 0 ) {
> 		strcpy( bp, file );
> 		return( 1 );
> 	    } else
> 		file = "/etc/termcap";
> 
> 
> 	if ((fp = fopen(file, "r")) == (FILE *) NULL)
> 		return(-1); 
> 
> 	while (fgets(bp, 1024, fp) != NULL) {
> 		/*  Read in the rest of the definition now  (efth)  */
> 		while (*(cp = &bp[strlen(bp) - 2]) == '\\')
> 			fgets(cp, 1024, fp);
> 		
60,62c79,81
< 		if (strncmp(name, cp, len) == 0) {
< 			while (*(cp = &bp[strlen(bp) - 2]) == '\\')
< 				fgets(cp, 1024, fp);
---
> 
> 		/*  Make sure "name" matches exactly  (efth)  */
> 		if (strncmp(name, cp, len) == 0  &&  cp[len] == '|') {
160c179
< 					**area = *++cp - 'A';
---
> 					**area = *++cp - '@'; /* fix (efth)*/
--------------------------------------------------------------------
               Edwin L. Froese
                  uw-beaver!ubc-cs!mprg!handel!froese

               Terrence W. Holm
                  uw-beaver!ubc-cs!uvicctr!sirius!tholm