lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 02.06.2011 18:57, schrieb Roberto Ierusalimschy:
I changed that isdigit() back to isalnum() in the second loop, but
added a check that ls->current is>  0.  That works as well.  I still
don't know where that -1, 0xff comes from, but at least stuff works
for now.

The -1 comes from Lua itself. It is EOZ, the mark for end of input.
Lua assumes that is*(-1) should be false. The ISO standard says that
these functions should accept EOF:

   The header<ctype.h>  declares several functions useful for classifying
   and mapping characters.) In all cases the argument is an int, the
   value of which shall be representable as an unsigned char or shall equal
   the value of the macro EOF.

But actually the standard does not say that EOF should be -1 (it only
says that EOF should be a negative integer), nor that EOF could not be a
digit ;)

What does the standard say is*() should return if the argument is EOF? Is that specified at all?

On Windows Moobile, EOF seems to be -1. I'd say it should not return true for isalnum(EOF).

My fix in read_numeral() works, but are there other potential locations where this could be a problem?