The Zcharacter directive can attempt to write values greater than 127
into the alphabet table, which is a two-dimensional array of char. If
char is signed, this means that when reading the value back you will
get a negative value. This value is then used as array index when
writing to other arrays. The test program I used looked like but the actual result of this is compiler-dependent. In fact, you may
not see any error at all. In my case, however, it produced a compiler
error because it had overwritten the table entry that told it that the
character '6' could be part of a numerical constant. I assume that changing the type of alphabet[3][27] from "char" to
"uchar" in chars.c and header.h will fix the problem. The suggested patch needs one slight addition -- it's not valid to pass an
"unsigned char *" pointer to a strcpy, so the little trio of strcpys that
initialise the alphabet table either needs casts or to be turned into
memcpys:
About Patches
Issue C62003
Zcharacter directive problems
Submitted by: Torbjörn Andersson
Appeared in: Compiler 6.20
Fixed in: Compiler 6.30
Problem
Zcharacter '@`e'; ! E-grave
[ Main;
print 36;
];
Solution
Update (by Kevin Bracey)
strcpy((char *) alphabet[0], "abcdefghijklmnopqrstuvwxyz");
or memcpy(alphabet[0], "abcdefghijklmnopqrstuvwxyz", 26);
Last updated 17 April 2013.
This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation.
Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Roger Firth.