Inform - Support - Patches

About Patches  

Compiler  
Library  

DM4 Errata  

Issue C62113

Malformed dictionary entries if alphabet table is changed
Submitted by: Kevin Bracey     Appeared in: Compiler 6.21 or before     Fixed in: Compiler 6.30
Problem

When inserting words into the dictionary, Inform automatically converts them to lower-case. Unfortunately, the way this is done assumes that A0 and A1 are the standard lower and upper case alphabets. If the alphabet table has been modified in a way that changes A0 or A1, dictionary entries will be mangled, as Inform will not allow any A1 letters into the dictionary.

The Zcharacter char directive will only modify A2, so the only way to provoke the bug is to request a complete replacement alphabet table using the Zcharacter string string string form. This would normally be done to improve text compression -- many later Inform games such as Shogun did this, moving some common upper-case letters into A0 and rare lower-case letters into A1.

Solution

The offending line is in text.c at line 877:

  if ((character_set_setting < 2) &&
      (k2>=26)&&(k2<2*26)) k2=k2-26; /* Upper down to lower case */

My suggested fix is to remove this statement, and to add lower case conversion higher up, as follows. This still isn't ideal, as it will only lower-case the ASCII set, but it's better than it was.

  --- text.c~  Wed Apr 28 21:17:59 1999
  +++ text.c   Wed Nov 21 13:30:32 2001
  @@ -851,6 +851,7 @@

           if (k==(int) '@')
           {   int unicode = text_to_unicode(dword+j);
  +            if ((unicode < 128) && isupper(unicode)) unicode = tolower(unicode);
               k = unicode_to_zscii(unicode);
               j += textual_form_length - 1;
               if ((k == 5) || (k >= 0x100))
  @@ -860,7 +861,10 @@
               }
               k2 = zscii_to_alphabet_grid[k];
           }
  -        else k2 = iso_to_alphabet_grid[k];
  +        else
  +        {   if (isupper(k)) k = tolower(k);
  +            k2 = iso_to_alphabet_grid[k];
  +        }

           if (k2 < 0)
           {   if ((k2 == -5) || (k2 <= -0x100))
  @@ -874,9 +878,7 @@
               }
           }
           else
  -        {   if ((character_set_setting < 2) &&
  -                (k2>=26)&&(k2<2*26)) k2=k2-26; /* Upper down to lower case */
  -            alphabet_used[k2] = 'Y';
  +        {   alphabet_used[k2] = 'Y';
               if ((k2/26)!=0)
                   wd[i++]=3+(k2/26);            /* Change alphabet for symbols */
               wd[i]=6+(k2%26);                  /* Write the Z character */


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.