[comp.sources.bugs] Bugfixes for nethack

jonas@myab.UUCP (Jonas Olsson) (08/07/87)

Here are some bugs I have fixed in nethack:
    1: delay_output didn't work with the terminfo curses library,
       and ospeed was undefined. To fix this I have added a new option
       in config.h to tell that the terminfo package is used, changed
       the format of the delay string in termcap.c and declared ospeed
       in tty.c
    2: On terminals with no highlighting, a null pointer was sent to
       sprintf in invent.c when printing out the headers. This was
       fixed by adding a test if the pointers are null.

UUCP:       	{decvax,philabs}!mcvax!enea!chalmers!myab!jonas
Phone:      	+46-31-187512
Surface Mail:	Jonas Olsson, MYAB, Dr Forselius gata 21, S-413 26 GOTHENBURG
		SWEDEN
Feed this to patch:

*** config.h.old	Fri Aug  7 10:06:15 1987
--- config.h	Fri Jul 31 10:57:00 1987
***************
*** 28,33
  /* #define BETA		/* if a beta-test copy  [MRS] */
  #define VERSION	"1.3d"	/* version number. */
  
  /* #define PYRAMID_BUG 	/* avoid a bug on the Pyramid */
  /* #define APOLLO		/* same for the Apollo */
  /* #define STUPID		/* avoid some complicated expressions if

--- 28,34 -----
  /* #define BETA		/* if a beta-test copy  [MRS] */
  #define VERSION	"1.3d"	/* version number. */
  
+ #define TERMINFO	/* if Terminfo curses package is used (System V.[23]) */
  /* #define PYRAMID_BUG 	/* avoid a bug on the Pyramid */
  /* #define APOLLO		/* same for the Apollo */
  /* #define STUPID		/* avoid some complicated expressions if
*** invent.c.old	Fri Aug  7 10:27:08 1987
--- invent.c	Mon Aug  3 10:54:33 1987
***************
*** 1016,1022
  	static char buf[4 + 4 + 15 + 1];
  
  	if (pos == NULL) pos = obj_symbols;
! 	Sprintf(buf, "%s%s%s", HI, names[pos - obj_symbols], HE);
  	return (buf);
  }
  #endif /* SORTING /**/

--- 1016,1025 -----
  	static char buf[4 + 4 + 15 + 1];
  
  	if (pos == NULL) pos = obj_symbols;
! 	if (HI && HE)
! 	    Sprintf(buf, "%s%s%s", HI, names[pos - obj_symbols], HE);
! 	else
! 	    Sprintf(buf, "%s", names[pos - obj_symbols]);
  	return (buf);
  }
  #endif /* SORTING /**/
*** termcap.c.old	Fri Jul 31 14:13:18 1987
--- termcap.c	Fri Aug  7 10:11:46 1987
***************
*** 298,303
  	}
  #else
  	if(!flags.nonull)
  		tputs("50", 1, xputc);
  
  		/* cbosgd!cbcephus!pds for SYS V R2 */

--- 298,304 -----
  	}
  #else
  	if(!flags.nonull)
+ #ifndef TERMINFO
  		tputs("50", 1, xputc);
  #else
  		/* cbosgd!cbcephus!pds for SYS V R2 */
***************
*** 299,305
  #else
  	if(!flags.nonull)
  		tputs("50", 1, xputc);
! 
  		/* cbosgd!cbcephus!pds for SYS V R2 */
  		/* is this terminfo, or what? */
  		/* tputs("$<50>", 1, xputc); */

--- 300,306 -----
  	if(!flags.nonull)
  #ifndef TERMINFO
  		tputs("50", 1, xputc);
! #else
  		/* cbosgd!cbcephus!pds for SYS V R2 */
  		tputs("$<50>", 1, xputc);
  #endif
***************
*** 301,309
  		tputs("50", 1, xputc);
  
  		/* cbosgd!cbcephus!pds for SYS V R2 */
! 		/* is this terminfo, or what? */
! 		/* tputs("$<50>", 1, xputc); */
! 
  	else if(ospeed > 0 || ospeed < SIZE(tmspc10)) if(CM) {
  		/* delay by sending cm(here) an appropriate number of times */
  		register int cmlen = strlen(tgoto(CM, curx-1, cury-1));

--- 302,309 -----
  		tputs("50", 1, xputc);
  #else
  		/* cbosgd!cbcephus!pds for SYS V R2 */
! 		tputs("$<50>", 1, xputc);
! #endif
  	else if(ospeed > 0 || ospeed < SIZE(tmspc10)) if(CM) {
  		/* delay by sending cm(here) an appropriate number of times */
  		register int cmlen = strlen(tgoto(CM, curx-1, cury-1));
*** tty.c.old	Fri Jul 31 14:22:36 1987
--- tty.c	Fri Aug  7 10:14:47 1987
***************
*** 66,71
  
  #endif
  
  extern short ospeed;
  static char erase_char, kill_char;
  static boolean settty_needed = FALSE;

--- 66,74 -----
  
  #endif
  
+ #ifdef TERMINFO
+ short ospeed;	/* used in delay_output, terminfo doesn't declare ospeed */
+ #else
  extern short ospeed;
  #endif
  static char erase_char, kill_char;
***************
*** 67,72
  #endif
  
  extern short ospeed;
  static char erase_char, kill_char;
  static boolean settty_needed = FALSE;
  struct termstruct inittyb, curttyb;

--- 70,76 -----
  short ospeed;	/* used in delay_output, terminfo doesn't declare ospeed */
  #else
  extern short ospeed;
+ #endif
  static char erase_char, kill_char;
  static boolean settty_needed = FALSE;
  struct termstruct inittyb, curttyb;