Re: asciiconv()

From: Jeremy Elson (
Date: 03/04/95

> I double checked my changes to asciiconv in db.c.
> To test it, I used Furry's New thalos area for circle 3.0p6.
> I booted the mud using lowercase ascii, and
> the extra flags were glow, magic, !mage, !cleric, !thief.
> changing them to uppercase, I got different results when I rebooted.

Yes, so?  You're not supposed to get the same results with upper-case and
lower-case flags!

> >From my understanding of the function, you are calculating the
> flag, and the first if statement is basing it's end-result with the
> char 'a'.
> If *p is uppercase, wouldn't you have to add 32 to the *p to
> make it equivalent to a *p value if using lowercase?

I don't think you understand what the code does.

Here is the code:

    if (islower(*p))
      flags |= 1 << (*p - 'a');
    else if (isupper(*p))
      flags |= 1 << (26 + (*p - 'A'));

Now, I think you are (incorrectly) in interpreting this code as trying to
convert an upper-case flag to be the same value as a lower-case flag.
That's not what the code is doing.  If I wanted the world files to be able
to accept bother upper- and lower-case flags as equivalent, I would have

    flags |= 1 << (LOWER(*p) - 'a');

...and just made everything lower-case, and not messed around with testing
whether or not the flag is upper- or lower-case and adding an appropriate
offset.  That would be silly.

The purpose of the asciiflag_conv code is to allow flags a-z to represent
flags 1<<0 through 1<<25, and A-F represent 1<<26 through 1<<31.

> 32+... worked for me
> Just letting you guys know about something that I came across
> from reading the CHANGES file.

I assume you're referring to the comment:

2/24/95 JE      Fixed asciiflag_conv in db.c for uppercase flags (typo,
                'a' instead of 'A').

That's because I had originally written the code, incorrectly, in patchlevel 5:

    if (islower(*p))
      flags |= 1 << (*p - 'a');
    else if (isupper(*p))
      flags |= 1 << (26 + (*p - 'a'));

Note that in the isupper() case, I've written 'a' and not 'A' as it should be.


This archive was generated by hypermail 2b30 : 12/07/00 PST