Attention Frotz porters: bug in core

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:

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:

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

The fix is to replace those two lines with this:

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

I use FROTZ interpreter under LUBUNTU in French with LXTerminal 0.1.11. I can’t use the repositories version of FROTZ, because it’s 2.43-4 and i have big problems with display and the entry of accented characters.
I download and compil the last version (FROTZ V2.44pre curses interface.) https://github.com/DavidGriffith/frotz It’s better, but it does not work well, with my system, either.Include "parser.h"; Include "verblib.h"; [ BeforeParsing at; print "------------------------^"; print "buffer: "; for (at = WORDSIZE : at < WORDSIZE + GetKeyBufLength() : at++) print (char) buffer->at; print "^------------------------^"; ]; Object room "Test Room" with description "Description Room", has light; Object fenetre "fenêtre" room with name 'fenetre' 'fenêtre', description "Une grande et lumineuse fenêtre", has openable static; [ Initialise; location = room; ]; Include "grammar.h";[spoiler]Release 1 / Serial number 140809 / Inform v6.33 Library 6/12-beta1 S

Test Room
Description Room

You can see a fen�tre here.

open fenêtre


buffer: open fen�?tre

You can’t see any such thing.

open fenetre


buffer: open fenetre

You open the fen�tre.

[/spoiler]It is certainly necessary to change the encoding of my terminal window, UTF-8 to ISO 8859-1 or ISO 8859-15 ? Under LXTerminal 0.1.11, i do not know how to do it. We can’t use UTF-8 encoding of the terminal window with FROTZ to display and entry accented characters ?

it seems frotz doesn’t handle well accented letters if you can’t change the encoding of your terminal (to iso8859, instead of utf8 which is now deservedly by default).

You can use this tip, it works under lxterminal:

luit -encoding iso-8859-1 frotz -d yourgame.z8

(the -d switch for frotz is only for removing the blue background)

luit -encoding iso-8859-1 frotz -d fenetre.z5 Merci, ça fonctionne avec luit -encoding.
It works.