About a bug in Frotz (that's "Frotz", and not "iFrotz")

27 views
Skip to first unread message

Peter Pears

unread,
Feb 10, 2014, 7:19:28 PM2/10/14
to ifrotz-...@googlegroups.com
FYI, a bug report seems to have cropped up in the actual Frotz core code. Here's the link:

http://www.intfiction.org/forum/viewtopic.php?f=33&t=11513

Here's what it says.

********************


This is for all of you Frotz porters. A couple days I was informed of a bug in Frotz's core code by David Fillmore. This seems to be the best place to get in touch with you.

According to the Z-Machine specification:
"In Version 6, a width field may optionally be given: if this is non-zero, text will then be justified as if it were in the window with that number (if width is positive) or a box -width pixels wide (if negative). Then the table will contain not ordinary text but formatted text: see print_form."

Frotz, on the other hand, tries to get the width of a window of number -width if the value is <= 0, but passes the width value through directly if it is positive. This results in the interpreter crashing with an "Illegal window" error if the width value is less than -7.

Sample Inform6 code tickling this bug:

Code:
Switches v6;
Array formatted table 50;
[ main x;
  @output_stream 3 formatted (-30);  ! Frotz treats this as a window number and crashes.
  print "ooh, hello there^boy^how are you";
  @output_stream (-3);
  @print_form formatted;
  @read_char 1 -> x;
];


The culprit is in redirect.c in the memory_open() function. The offending code reads thus:

Code:
        if (buffering && (short) xsize <= 0)
            xsize = get_max_width ((zword) (- (short) xsize));


The fix is to replace those two lines with this:

Code:
	else {
	    if ((short) xsize >= 0)
		xsize = get_max_width (xsize);
	    else
		xsize = -xsize;
	}


Complete details are available at https://github.com/DavidGriffith/frotz/issues/1

_________________
David Griffith


Peter Pears

unread,
Feb 10, 2014, 7:21:19 PM2/10/14
to ifrotz-...@googlegroups.com
Mind you, if this is version 6, as I understand it, it should affect very little actual games.

Then again, as I've discovered, iFrotz DOES run some v6 games, like Arthur (given a few caveats and limitations).

Anyway, I hope it's useful. Cheers.

Reply all
Reply to author
Forward
0 new messages