Subject: bin/3964: adventure won't compile with -Werror or a modern cpp
To: None <gnats-bugs@gnats.netbsd.org>
From: Eric Fischer <eric@fudge.uchicago.edu>
List: netbsd-bugs
Date: 08/10/1997 15:25:02
>Number:         3964
>Category:       bin
>Synopsis:       adventure won't compile with -Werror or a modern cpp
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 10 13:35:00 1997
>Last-Modified:
>Originator:     Eric Fischer
>Organization:
The University of Chicago
>Release:        1.2
>Environment:
System: NetBSD fudge 1.2 NetBSD 1.2 (FUDGE) #7: Sun Jan 19 16:26:56 CST 1997 eric@fudge:/usr/people/eric/usrsrc/sys/arch/sparc/compile/FUDGE sparc


>Description:

	Adventure won't compile with -Werror (because of the return type
	of its signal handlers) or with a modern C preprocessor (because
	it expects macro substitutions to affect things in quotes).

>How-To-Repeat:

	Try to compile adventure with an ANSI C compiler.

>Fix:

	Apply the following patch, which makes the signal handler return
	void, quotes the DECR() macro's arguments rather than making the 
	macro do it, and comments the text following #endifs.

diff -rc ../../../src/games/adventure/Makefile ./Makefile
*** ../../../src/games/adventure/Makefile	Tue Mar 21 06:04:53 1995
--- ./Makefile	Sat Aug  9 19:31:13 1997
***************
*** 4,10 ****
  PROG=	adventure
  SRCS=	main.c init.c done.c save.c subr.c vocab.c wizard.c io.c data.c crc.c
  MAN=	adventure.6
- CFLAGS+=-traditional-cpp
  HIDEGAME=hidegame
  CLEANFILES+=setup data.c
  
--- 4,9 ----
Only in .: adventure
Only in .: adventure.cat6
Only in .: crc.o
Only in .: data.c
Only in .: data.o
Only in .: done.o
diff -rc ../../../src/games/adventure/hdr.h ./hdr.h
*** ../../../src/games/adventure/hdr.h	Tue Mar 21 06:05:02 1995
--- ./hdr.h	Sun Aug 10 15:12:57 1997
***************
*** 86,92 ****
  struct text
  #ifdef OLDSTUFF
  {       int seekadr;                    /* DATFILE must be < 2**16      */
! #endif OLDSTUFF
  {       char *seekadr;                  /* Msg start in virtual disk    */
  	int txtlen;                     /* length of msg starting here  */
  };
--- 86,92 ----
  struct text
  #ifdef OLDSTUFF
  {       int seekadr;                    /* DATFILE must be < 2**16      */
! #endif /* OLDSTUFF */
  {       char *seekadr;                  /* Msg start in virtual disk    */
  	int txtlen;                     /* length of msg starting here  */
  };
***************
*** 162,166 ****
  char *decr();
  unsigned long crc();
  
! /* We need to get a little tricky to avoid strings */
! #define DECR(a,b,c,d,e) decr('a'+'+','b'+'-','c'+'#','d'+'&','e'+'%')
--- 162,165 ----
  char *decr();
  unsigned long crc();
  
! #define DECR(a,b,c,d,e) decr(a+'+',b+'-',c+'#',d+'&',e+'%')
diff -rc ../../../src/games/adventure/init.c ./init.c
*** ../../../src/games/adventure/init.c	Tue May 21 16:53:05 1996
--- ./init.c	Sun Aug 10 15:07:43 1997
***************
*** 108,174 ****
  	}
  
  	/* define mnemonics */
! 	keys = vocab(DECR(k,e,y,s,\0), 1);
! 	lamp = vocab(DECR(l,a,m,p,\0), 1);
! 	grate = vocab(DECR(g,r,a,t,e), 1);
! 	cage  = vocab(DECR(c,a,g,e,\0),1);
! 	rod   = vocab(DECR(r,o,d,\0,\0),1);
  	rod2=rod+1;
! 	steps=vocab(DECR(s,t,e,p,s),1);
! 	bird  = vocab(DECR(b,i,r,d,\0),1);
! 	door  = vocab(DECR(d,o,o,r,\0),1);
! 	pillow= vocab(DECR(p,i,l,l,o), 1);
! 	snake = vocab(DECR(s,n,a,k,e), 1);
! 	fissur= vocab(DECR(f,i,s,s,u), 1);
! 	tablet= vocab(DECR(t,a,b,l,e), 1);
! 	clam  = vocab(DECR(c,l,a,m,\0),1);
! 	oyster= vocab(DECR(o,y,s,t,e), 1);
! 	magzin= vocab(DECR(m,a,g,a,z), 1);
! 	dwarf = vocab(DECR(d,w,a,r,f), 1);
! 	knife = vocab(DECR(k,n,i,f,e), 1);
! 	food  = vocab(DECR(f,o,o,d,\0),1);
! 	bottle= vocab(DECR(b,o,t,t,l), 1);
! 	water = vocab(DECR(w,a,t,e,r), 1);
! 	oil   = vocab(DECR(o,i,l,\0,\0),1);
! 	plant = vocab(DECR(p,l,a,n,t), 1);
  	plant2=plant+1;
! 	axe   = vocab(DECR(a,x,e,\0,\0),1);
! 	mirror= vocab(DECR(m,i,r,r,o), 1);
! 	dragon= vocab(DECR(d,r,a,g,o), 1);
! 	chasm = vocab(DECR(c,h,a,s,m), 1);
! 	troll = vocab(DECR(t,r,o,l,l), 1);
  	troll2=troll+1;
! 	bear  = vocab(DECR(b,e,a,r,\0),1);
! 	messag= vocab(DECR(m,e,s,s,a), 1);
! 	vend  = vocab(DECR(v,e,n,d,i), 1);
! 	batter= vocab(DECR(b,a,t,t,e), 1);
! 
! 	nugget= vocab(DECR(g,o,l,d,\0),1);
! 	coins = vocab(DECR(c,o,i,n,s), 1);
! 	chest = vocab(DECR(c,h,e,s,t), 1);
! 	eggs  = vocab(DECR(e,g,g,s,\0),1);
! 	tridnt= vocab(DECR(t,r,i,d,e), 1);
! 	vase  = vocab(DECR(v,a,s,e,\0),1);
! 	emrald= vocab(DECR(e,m,e,r,a), 1);
! 	pyram = vocab(DECR(p,y,r,a,m), 1);
! 	pearl = vocab(DECR(p,e,a,r,l), 1);
! 	rug   = vocab(DECR(r,u,g,\0,\0),1);
! 	chain = vocab(DECR(c,h,a,i,n), 1);
! 
! 	back  = vocab(DECR(b,a,c,k,\0),0);
! 	look  = vocab(DECR(l,o,o,k,\0),0);
! 	cave  = vocab(DECR(c,a,v,e,\0),0);
! 	null  = vocab(DECR(n,u,l,l,\0),0);
! 	entrnc= vocab(DECR(e,n,t,r,a), 0);
! 	dprssn= vocab(DECR(d,e,p,r,e), 0);
! 	enter = vocab(DECR(e,n,t,e,r), 0);
! 
! 	pour  = vocab(DECR(p,o,u,r,\0), 2);
! 	say   = vocab(DECR(s,a,y,\0,\0),2);
! 	lock  = vocab(DECR(l,o,c,k,\0),2);
! 	throw = vocab(DECR(t,h,r,o,w), 2);
! 	find  = vocab(DECR(f,i,n,d,\0),2);
! 	invent= vocab(DECR(i,n,v,e,n), 2);
  
  	/* initialize dwarves */
  	chloc=114;
--- 108,174 ----
  	}
  
  	/* define mnemonics */
! 	keys = vocab(DECR('k','e','y','s','\0'), 1);
! 	lamp = vocab(DECR('l','a','m','p','\0'), 1);
! 	grate = vocab(DECR('g','r','a','t','e'), 1);
! 	cage  = vocab(DECR('c','a','g','e','\0'),1);
! 	rod   = vocab(DECR('r','o','d','\0','\0'),1);
  	rod2=rod+1;
! 	steps=vocab(DECR('s','t','e','p','s'),1);
! 	bird  = vocab(DECR('b','i','r','d','\0'),1);
! 	door  = vocab(DECR('d','o','o','r','\0'),1);
! 	pillow= vocab(DECR('p','i','l','l','o'), 1);
! 	snake = vocab(DECR('s','n','a','k','e'), 1);
! 	fissur= vocab(DECR('f','i','s','s','u'), 1);
! 	tablet= vocab(DECR('t','a','b','l','e'), 1);
! 	clam  = vocab(DECR('c','l','a','m','\0'),1);
! 	oyster= vocab(DECR('o','y','s','t','e'), 1);
! 	magzin= vocab(DECR('m','a','g','a','z'), 1);
! 	dwarf = vocab(DECR('d','w','a','r','f'), 1);
! 	knife = vocab(DECR('k','n','i','f','e'), 1);
! 	food  = vocab(DECR('f','o','o','d','\0'),1);
! 	bottle= vocab(DECR('b','o','t','t','l'), 1);
! 	water = vocab(DECR('w','a','t','e','r'), 1);
! 	oil   = vocab(DECR('o','i','l','\0','\0'),1);
! 	plant = vocab(DECR('p','l','a','n','t'), 1);
  	plant2=plant+1;
! 	axe   = vocab(DECR('a','x','e','\0','\0'),1);
! 	mirror= vocab(DECR('m','i','r','r','o'), 1);
! 	dragon= vocab(DECR('d','r','a','g','o'), 1);
! 	chasm = vocab(DECR('c','h','a','s','m'), 1);
! 	troll = vocab(DECR('t','r','o','l','l'), 1);
  	troll2=troll+1;
! 	bear  = vocab(DECR('b','e','a','r','\0'),1);
! 	messag= vocab(DECR('m','e','s','s','a'), 1);
! 	vend  = vocab(DECR('v','e','n','d','i'), 1);
! 	batter= vocab(DECR('b','a','t','t','e'), 1);
! 
! 	nugget= vocab(DECR('g','o','l','d','\0'),1);
! 	coins = vocab(DECR('c','o','i','n','s'), 1);
! 	chest = vocab(DECR('c','h','e','s','t'), 1);
! 	eggs  = vocab(DECR('e','g','g','s','\0'),1);
! 	tridnt= vocab(DECR('t','r','i','d','e'), 1);
! 	vase  = vocab(DECR('v','a','s','e','\0'),1);
! 	emrald= vocab(DECR('e','m','e','r','a'), 1);
! 	pyram = vocab(DECR('p','y','r','a','m'), 1);
! 	pearl = vocab(DECR('p','e','a','r','l'), 1);
! 	rug   = vocab(DECR('r','u','g','\0','\0'),1);
! 	chain = vocab(DECR('c','h','a','i','n'), 1);
! 
! 	back  = vocab(DECR('b','a','c','k','\0'),0);
! 	look  = vocab(DECR('l','o','o','k','\0'),0);
! 	cave  = vocab(DECR('c','a','v','e','\0'),0);
! 	null  = vocab(DECR('n','u','l','l','\0'),0);
! 	entrnc= vocab(DECR('e','n','t','r','a'), 0);
! 	dprssn= vocab(DECR('d','e','p','r','e'), 0);
! 	enter = vocab(DECR('e','n','t','e','r'), 0);
! 
! 	pour  = vocab(DECR('p','o','u','r','\0'), 2);
! 	say   = vocab(DECR('s','a','y','\0','\0'),2);
! 	lock  = vocab(DECR('l','o','c','k','\0'),2);
! 	throw = vocab(DECR('t','h','r','o','w'), 2);
! 	find  = vocab(DECR('f','i','n','d','\0'),2);
! 	invent= vocab(DECR('i','n','v','e','n'), 2);
  
  	/* initialize dwarves */
  	chloc=114;
***************
*** 202,207 ****
--- 202,208 ----
  
  
  
+ void
  trapdel()                               /* come here if he hits a del   */
  {	delhit++;			/* main checks, treats as QUIT  */
  	signal(SIGINT,trapdel);		/* catch subsequent DELs        */
Only in .: init.o
diff -rc ../../../src/games/adventure/io.c ./io.c
*** ../../../src/games/adventure/io.c	Mon Apr 24 07:21:37 1995
--- ./io.c	Sun Aug 10 15:13:28 1997
***************
*** 383,389 ****
  	}
  }
  
! #endif DEBUG
  
  rvoc()
  {       register char *s;               /* read the vocabulary          */
--- 383,389 ----
  	}
  }
  
! #endif /* DEBUG */
  
  rvoc()
  {       register char *s;               /* read the vocabulary          */
Only in .: io.o
diff -rc ../../../src/games/adventure/main.c ./main.c
*** ../../../src/games/adventure/main.c	Tue May 21 16:53:09 1996
--- ./main.c	Sat Aug  9 19:31:49 1997
***************
*** 66,72 ****
  	register int i;
  	int rval,ll;
  	struct text *kk;
! 	extern trapdel();
  
  	/* adventure doesn't need setuid-ness, so, just get rid of it */
  	if (setuid(getuid()) < 0)
--- 66,72 ----
  	register int i;
  	int rval,ll;
  	struct text *kk;
! 	extern void trapdel();
  
  	/* adventure doesn't need setuid-ness, so, just get rid of it */
  	if (setuid(getuid()) < 0)
Only in .: main.o
Only in .: save.o
Only in .: setup
Only in .: subr.o
Only in .: vocab.o
diff -rc ../../../src/games/adventure/wizard.c ./wizard.c
*** ../../../src/games/adventure/wizard.c	Mon Apr 24 07:21:41 1995
--- ./wizard.c	Sun Aug 10 15:06:19 1997
***************
*** 69,75 ****
  
  poof()
  {
! 	strcpy(magic, DECR(d,w,a,r,f));
  	latncy = 45;
  }
  
--- 69,75 ----
  
  poof()
  {
! 	strcpy(magic, DECR('d','w','a','r','f'));
  	latncy = 45;
  }
  
Only in .: wizard.o
>Audit-Trail:
>Unformatted: