[comp.os.minix] another adventure bug

paula@bcsaic.UUCP (Paul Allen) (06/07/90)

Wow!  Minix has finally arrived!  We've now got ADVENTURE!

I haven't compiled it under Minix yet, but I've run across a
couple bugs while using it as a 'benchmark' on my Sun.  :-)

First, as Chris van Wuellen has pointed out, there are three
calls to tolower() that assume the argument is upper case.  On
my Sun, this got a segmentation violation immediatly after
telling it I didn't need instructions.  The fix is obvious.

Second, I got a segmentation violation any time I gave the
command "y2".  (Since this is the only way I know to get out
of the rock pile, this is a serious problem!)  Using dbx,
I discovered that "y2" is at the end of the wc[] array and
some code in database.c was trying to reference the array
element after "y2".  Here's my diff:

*** database.c.original	Wed Jun  6 17:45:59 1990
--- database.c	Wed Jun  6 17:48:41 1990
***************
*** 165,173 ****
    int v1, v2;
  
    if ((v1 = binary(word, wc, MAXWC)) >= 0) {
! 	if (strcmp(word, wc[v1 - 1].aword) == 0)
  		v2 = v1 - 1;
! 	else if (strcmp(word, wc[v1 + 1].aword) == 0)
  		v2 = v1 + 1;
  	else
  		v2 = v1;
--- 165,173 ----
    int v1, v2;
  
    if ((v1 = binary(word, wc, MAXWC)) >= 0) {
! 	if (v1 > 0 && strcmp(word, wc[v1 - 1].aword) == 0)
  		v2 = v1 - 1;
! 	else if (v1 < (MAXWC-1) && strcmp(word, wc[v1 + 1].aword) == 0)
  		v2 = v1 + 1;
  	else
  		v2 = v1;

This is a pretty simple-minded fix, but it appears to do the trick
and doesn't cause any other strange effects that I can see.  Note
that MAXWC is equal to the largest legal subscript in wc[] plus one.

I have yet to encounter the other bug in database.c that Christoph
reported.  I suppose it'll be obvious when I go looking for it.

Now, where's my map of the Pirate's maze?  (Har, Har!)

Paul Allen
-- 
------------------------------------------------------------------------
Paul L. Allen                       | pallen@atc.boeing.com
Boeing Advanced Technology Center   | ...!uw-beaver!bcsaic!pallen