lua-users home
lua-l archive

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


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

It does not say anything specific for EOF, but given that is* both
accept EOF and "return nonzero (true) if and only if the value of the
argument c conforms to that in the description of the function", you
either assume that EOF is a digit/letter or that their lib has a bug.


> 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?

Yes. Other loops in the lexer assume that is*(-1) is false to stop.
For instance:

          do {
            save_and_next(ls);
          } while (isalnum(ls->current) || ls->current == '_');


              do {
                c = 10*c + (ls->current-'0');
                next(ls);
              } while (++i<3 && isdigit(ls->current));

Maybe other parts of Lua assume that 0 is not a number nor a letter, too
(to stop loops over strings).

-- Roberto