lua-users home
lua-l archive

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


Hello,

I'm not sure if this has been covered already but I've found a bug in Lua 4.0's lexer, dealing with line-endings under mac. If the file is saved with mac-endings ('\r') comments does not work, but after modifying llex.c::luaX_lex alittle, this works.

My changes:

case ' ': case '\t':
next(LS);
continue;

case '\r':
inclinenumber(LS);
		
if (LS->current == '\n')
	next(LS); // Don't count lines twice on Windows.
continue;

case '-':
next(LS);
if (LS->current != '-') return '-';
do { next(LS); } while (LS->current != '\n'
&& LS->current != '\r' // End comment on mac's as well, but increases linecount twice on windows?
	&& LS->current != EOZ);
continue;

Cheers,

--
Nils Svangård - http://www.svangard.net - ICQ: 1332261