DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
199 stars 32 forks source link

Function zchar_weight assigns wrong weight to a space #264

Closed heasm66 closed 5 months ago

heasm66 commented 5 months ago

A space (z-char 0) has a weight of 1 according to Z-Machine Standards Document, §3.5.1. The current function returns another value (probably 2). This makes applying the abbreviations a little off.

Suggestion to change the function to something like:

/* Helper routine to compute the weight, in units, of a character handled by the Z-Machine */
static int zchar_weight(int c)
{
    if (c == 32) return 1;
    int lookup = iso_to_alphabet_grid[c];
    if (lookup < 0) return 4;
    if (lookup < 26) return 1;
    return 2;
}

This should be relative pain free because it's only called from one place.

erkyrath commented 5 months ago

iso_to_alphabet_grid[32] is -32, so it returns 4. That's clearly wrong.

This should be relative pain free because it's only called from one place.

That one place is called from all over the place, so that doesn't help. :)

But your change seems like the right answer. I'll have to see how it affects -e compiles, though.

(I note that every other place that iso_to_alphabet_grid[] is consulted, there's a special-case check for space first.)