[comp.unix.microport] HACKBUGS for System V/AT 286

root@qetzal.UUCP (Admin) (12/18/87)

[Submitted courtesy of John Rupley reachable at arizona!rupley!local]

Attached is a description of changes to the new nethack release, for 
SysV r.2 running on an 80286 machine.

Environment: Microport release 2.2 (when will the 2 month-old order for 
2.3 be filled?) on a Bell Technologies clone with Hub6 card handling 
a Televideo 920/925 and several Otrona 8/16 computers in terminal mode
-- all very primitive.

Summary of changes:

1)	fight.c		cosmetic: test out of print of empty string
			at (avoiding of) hit of dog.

2)	rnd.c		SysV-specific bug and fix: replace call of 
			BSD specific routine random()
			with call of rand(), that is appropriately
			#defined elsewhere

3)	termcap.c	two significant changes:
			(a) bug: if not standout mode, then there is
				a memory error = SIGSEGV
			    fix: fill HI and HE without use of SO and SE
				if SO || SE are NULL
			(b) bug: some actions (eg throws) dump core
			    fix: replace xputs by xputc as the function
				passed in a tputs delay

			several minor changes:
			(a) define ospeed  (else it is not defined anywhere
				and it is declared external elsewhere)
			(b) kludge for a deviant terminfo (for an otrona!!)
				for which the HO string is not sent correctly
				from nethack (it works with vi, emacs, etc)
			(c) force a set of backspace (BC)

4)	??		bug?: tabs in text displays (help, hh) are not 
				passed 	properly to terminals on Hub6; 
				display is fine on ansi AT console
			work-around: detab the help and hh files; not
				worth tracking the problem down; may
				have something to do with stip passed
				to display routine


Previous net postings have brought up the two significant bugs remedied 
in termcap.  Apparently they are not specific for a Microport system, 
and I expect they should show up on any SysV-like machine.

The listing attached gives details of the above, and also the
adapatation of the config.h and Makefile for use with Microport
(should be about the same for Xenix).

Comments: The nethack code is exquisitely portable.  With the most 
minimal changes it compiled in an environment that, judging from the 
comments within the source, is foreign for the principal authors of 
nethack.  One wishes ATT would do as well; the new awk source has 
unreasonably many instances of the use of int for char *, and porting
to an 80286 was unpleasant.

The point is, unfortunately, that in spite of clean code, termcap in a 
SysV environment under curses/terminfo does not behave well.  I expect 
other people with other terminals hung from a SysV machine will have to 
find their own customized work-arounds.  So that's news ):-?

John Rupley
 uucp: ..{ihnp4 | hao!noao}!arizona!rupley!local
 internet: rupley!local@megaron.arizona.edu
 telex: 9103508679(JARJAR)
 (H) 30 Calle Belleza, Tucson AZ 85716 - (602) 325-4533
 (O) Dept. Biochemistry, Univ. Arizona, Tucson AZ 85721 - (602) 621-3929


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

NOTE-- THE FOLLOWING IS A TEXT FILE, NOT FOR USE WITH PATCH

Thu Dec 10 00:30:14 MST 1987

diff  distribution_version  (vs)  modified_version

fight.c compared with ../nethack/fight.c
469c469,471
< 		if (dname = NAME(mtmp))
---
> /* didn't try to trace the logic, but if dname is empty, */
> /* it seems that all you should be able to do is hit the unnamed dog */
> 		if (strlen(dname = NAME(mtmp)))




rnd.c compared with ../nethack/rnd.c
5c5,6
< #define RND(x)	(random() % (x))
---
> /* #define RND(x)	(random() % (x)) */
> #define RND(x)	(rand() % (x))




termcap.c compared with ../nethack/termcap.c
6a7
> 
18a20,21
> #else
> 	short ospeed = 0;	/* ????????????????????? */
19a23
> 
72a77,85
> /* some declarations so can use sdb with only termcap compiled -g */
> extern char tbuf[];
> extern char *HO, *CL, *CE, *UP, *CM, *ND, *XD, *BC, *SO, *SE, *TI, *TE;
> extern char *VS, *VE, *US, *UE;
> extern int SG;
> extern char PC;
> extern char *CD;
> extern int CO, LI;
> 
85,86c98,105
< 		if(!tgetflag("bs"))
< 			error("Terminal must backspace.");
---
> /* this change is a must for an otrona in terminal mode, and by extension, */
> /* something else probably will show the same problem */
> /* the change is *not* needed for AT console = vt100 ansi */
> /* don't know why it isn't??  "bc" is not in any of my terminfos */
> /*  (if you don't like to force backspace = backspace */
> /*  try "le" = "cub1" = move cursor left one space = "\b") */
> /*		if(!tgetflag("bs"))	*/
> /*			error("Terminal must backspace.");	*/
91a111,114
> /* kludge to correct a feature of otrona terminfo */
> /* that seems not to have proper delays when sent out from here */
> 	if (!strncmp(term, "otr", 3))
> 		HO = NULL;
120c143,151
< 	if(!SO || !SE || (SG > 0)) SO = SE = US = UE = 0;
---
> /* should NULL a pointer, just to be safe in these int -ne char * things  */ 
> 	if(!SO || !SE || (SG > 0)) SO = SE = US = UE = NULL;
> /* the following is disabled; it is left in as a reminder */
> /* in case problems crop up with other terminals */
> /* a kludge to force no standout mode for */
> /* terminal types for which terminfo is broken-- */
> /*	if (!strncmp(term, "otr", 3) || !strncmp(term, "tvi", 3))
> 		SO = SE = US = UE = NULL;
> */
122a154,157
> /* we have neither TI nor TE, */
> /* but let's be safe in case there is one but not the other */
> 	if (!TI || !TE)
> 		TI = TE = NULL;
129a165,171
> /* this change is a must for a televideo terminal, for an otrona, */
> /* and by extension for other varieties of things hanging off the machine */
> /* it is *not* needed for AT console = vt100 ansi */
> /* bug: without the fix below, if no standout mode, */
> /* there is a segmentation violation, as there should be with strlen(0) */
> 	if (SO && SE)
> 	{
137a180,189
> 	}
> 	else
> 	{
> /* should be able to use: 	HE = HI = ""; */
> /* but let's do it the long way */
> 		HI = (char *) alloc(1 + 1);
> 	 	HE = (char *) alloc(1 + 1);
> 		*HI = '\0';
> 		*HE = '\0';
> 	}
341c393,396
< 		tputs("$<50>", 1, xputs);
---
> /* shouldn't this be a pointer to xputc, to avoid calling tputs twice???? */
> /* bug: without the fix below, which is xputs -> xputc, */
> /* certain moves (eg, throws and zaps) dump core */
> 		tputs("$<50>", 1, xputc);




config.h compared with ../nethack/config.h
23,24c23,24
< #define BSD		/* defind for 4.n BSD  */
< /* #define SYSV		/* define for System V */
---
> /* #define BSD		/* defind for 4.n BSD  */
> #define SYSV		/* define for System V */
29c29
< #define PYRAMID_BUG 	/* avoid a bug on the Pyramid */
---
> /* #define PYRAMID_BUG 	/* avoid a bug on the Pyramid */
33c33
< /* #define TERMINFO		/* uses "curses" rather than termcap */
---
> #define TERMINFO		/* uses "curses" rather than termcap */
40c40,41
< #define WIZARD  "mike"	/* the person allowed to use the -D option */
---
> /* #define WIZARD  "mike"	/* the person allowed to use the -D option */
> #define WIZARD  "john"	/* the person allowed to use the -D option */
69c70,71
< #define	DEF_MAILREADER	"/usr/bin/mail"		/* or e.g. /bin/mail */
---
> /* #define	DEF_MAILREADER	"/usr/bin/mail"		/* or e.g. /bin/mail */
> #define	DEF_MAILREADER	"/usr/bin/mailx"		/* or e.g. /bin/mail */
134c136
< typedef	char	schar;
---
> typedef	short int	schar;		/*???????????????????*/




Makefile compared with ../nethack/Makefile
11,12c11,12
< CFLAGS = -O
< LFLAGS =
---
> CFLAGS = -Ml
> LFLAGS = -Ml
15c15,16
< TERMLIB = -ltermlib
---
> # TERMLIB = -ltermlib
> TERMLIB = -lcurses
25c26
< MANDIR   = /usr/man/man6
---
> MANDIR   = /usr/catman/man/man0		# keep all nonstandard in man0
66c67
< 	@cc $(LFLAGS) -o $(GAME) $(HOBJ) $(TERMLIB)
---
> 	@cc $(CFLAGS) $(LFLAGS) -o $(GAME) $(HOBJ) $(TERMLIB)
75c76
< 	cc -o makedefs alloc.o makedefs.c
---
> 	cc $(CFLAGS) $(LFLAGS) -o makedefs alloc.o makedefs.c
151,152d151
< 	chown $(GAMEUID) $(SHELLDIR)/$(GAME) $(GAMEDIR)/*
< 	chgrp $(GAMEGRP) $(SHELLDIR)/$(GAME) $(GAMEDIR)/*
155,156c154,157
< 	-cp nethack.6 $(MANDIR)/$(GAME).$(MANEXT)
< 
---
> 	chgrp $(GAMEGRP) $(SHELLDIR)/$(GAME) $(GAMEDIR)/*
> 	chown $(GAMEUID) $(SHELLDIR)/$(GAME) $(GAMEDIR)/*
> #	-cp nethack.6 $(MANDIR)/$(GAME).$(MANEXT)
> 	cd /usr/catman/man/man0; roffman /usr/games/src/nethack/*.6



-- 
//////////////////286 Moderator -- comp.unix.microport\\\\\\\\\\\\\\\\\
Email to microport@uwspan for info on the newsgroup comp.unix.microport.
otherwise mail to microport@uwspan with a Subject containing one of:
386 286 Bug Source Merge or "Send Buglist" (rutgers!uwvax!uwspan!microport)