🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.bugs
Article #814

Re: Nethack Problems

#814
From: Guy Harris
Date: Tue, 11 Aug 1987 17:49
127 lines
4476 bytes
>  I have nethack working fine on our BSD system. However in trying
> to make it work on our 3b2/310 running system V I always get
> "Terminal must Backspace" in trying to run nethack.  I use vt100
> for my terminal type. Is it a problem with the terminal library

Probably.

> if so what terminal library did you other sysV users use. 

One with the problem fixed.

The trick here is that the part of the "curses" library that's being used is
the part that emulates the old "termcap" routines.  "nethack" is checking the
"bs" capability; this capability has no direct equivalent in "terminfo".  To
determine whether it should say the "bs" capability is present or not, the
emulation library looks at the "cub1" capability; if it is the string "\b", it
says that the "bs" capability is present, otherwise it doesn't.

The version distributed with the VAX S5R2 just looks directly at the
capability; if there are any delays in the string, it says "this string is not
just a backspace, so this terminal can't backspace".  The "cub1" capability in
the S5R2 "terminfo" entry for the VT100 has no delays, so that version may
work.)

The S5R3 and S5R3.1 versions fix the problem by stripping the delays;
unfortunately, the fix has a bug.  There is a routine "stripdelay" (in the S5R3
version) or "_stripdelay" (in the S5R3.1 version) that makes a copy of a
capability string after stripping all delays out.  Unfortunately, it doesn't
properly null-terminate the string.  These versions run the risk of screwing up
even if "cub1" has no delays in it.

I don't know if the 3B2 S5R2 has the same "terminfo" or "curses" that the VAX
S5R2 does; if it has a later version, this bug may exist in the 3B2 S5R2.

Here's the fix to the S5R3 "termcap.form":

*** /arch/s5r3/usr/src/lib/libcurses/screen/termcap.form	Fri Jan 30 15:36:38 1987
--- ./termcap.form	Tue Aug 11 10:32:56 1987
***************
*** 41,47 ****
  	
  	if (inbuf == NULL)
  		return 0;
! 	else
  		while (size && *inbuf)
  			if (*inbuf == '$' && *(inbuf+1) == '<')
  				while (*inbuf && *inbuf++ != '>')
--- 41,47 ----
  	
  	if (inbuf == NULL)
  		return 0;
! 	else {
  		while (size && *inbuf)
  			if (*inbuf == '$' && *(inbuf+1) == '<')
  				while (*inbuf && *inbuf++ != '>')
***************
*** 50,55 ****
--- 50,58 ----
  				size--;
  				*outbuf++ = *inbuf++;
  			}
+ 		if (size)
+ 			*outbuf = '\0';
+ 	}
  	return saveoutbuf;
  }
  


and the fix to the S5R3.1 "termcap.ed":

*** /arch/s5r3.1/usr/src/lib/libcurses/screen/termcap.ed	Wed Oct 29 06:52:39 1986
--- ./termcap.ed	Tue Aug 11 10:28:10 1987
***************
*** 46,52 ****
  
      if (inbuf == NULL)
  	return (0);
!     else
  	while (size && *inbuf)
  	    if (*inbuf == '$' && *(inbuf+1) == '<')
  		while (*inbuf && *inbuf++ != '>')
--- 46,52 ----
  
      if (inbuf == NULL)
  	return (0);
!     else {
  	while (size && *inbuf)
  	    if (*inbuf == '$' && *(inbuf+1) == '<')
  		while (*inbuf && *inbuf++ != '>')
***************
*** 56,61 ****
--- 56,64 ----
  		size--;
  		*outbuf++ = *inbuf++;
  	    }
+ 	if (size)
+ 	    *outbuf = '\0';
+     }
      return (saveoutbuf);
  }
  
***************
*** 165,171 ****
      if (offset == -1)
  	return (0);
      rv = str_array[offset];
!     if (area && *area)
      {
  	(void) strcpy(*area, rv);
  	*area += strlen(rv) + 1;
--- 168,174 ----
      if (offset == -1)
  	return (0);
      rv = str_array[offset];
!     if (area && *area && rv)
      {
  	(void) strcpy(*area, rv);
  	*area += strlen(rv) + 1;

The latter also includes a fix to another null pointer dereferencing problem
(sigh - WHEN will they make the damn "-z" flag to the linker the default, so
that these bugs get caught *before* the code gets in the hands of people whose
systems never map in location 0?).
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com
Technical Details
Message-ID: <25323@sun.uucp>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!sri-unix!sri-spam!ames!amdcad!sun!gorodish!guy
References: <2693@sdsu.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!sri-unix!sri-spam!ames!amdcad!sun!gorodish!guy
From: guy%gorodish@Sun.COM (Guy Harris)
Newsgroups: comp.sources.bugs,comp.bugs.sys5
Subject: Re: Nethack Problems
Message-ID: <25323@sun.uucp>
Date: Tue, 11-Aug-87 13:49:40 EDT
Article-I.D.: sun.25323
Posted: Tue Aug 11 13:49:40 1987
Date-Received: Thu, 13-Aug-87 06:30:10 EDT
References: <2693@sdsu.UUCP>
Sender: news@sun.uucp
Followup-To: comp.sources.bugs
Lines: 127