[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua code formatters and beautifiers
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 13 Jun 2017 21:42:34 -0300
This patch in llex.c no longer drops characters in comments:
$ diff llex.c,orig llex.c
448d447
< luaZ_resetbuffer(ls->buff); /* 'skip_sep' may dirty the buffer */
450c449
< read_long_string(ls, NULL, sep); /* skip long comment */
---
> read_long_string(ls, seminfo, sep); /* skip long comment */
452c451
< break;
---
> return 'C';
457,458c456,459
< next(ls); /* skip until end of line (or end of file) */
< break;
---
> save_and_next(ls); /* skip until end of line (or end of file) */
> seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
> luaZ_bufflen(ls->buff));
> return 'c';
As before, the patched code returns 'C' for a long comment and 'c' for a short
comment, with the contents of the comment in seminfo->ts.
Again, adding support for this in ltokenp is just adding two lines in proxy.c:
switch (t)
{
case 'C':
case 'c':
case TK_STRING:
case TK_NAME:
lua_pushstring(L,getstr(seminfo->ts));
break;
...
All feedback welcome.