lua-users home
lua-l archive

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


> >Lua 4.1 (beta)  Copyright (C) 1994-2001 TeCGraf, PUC-Rio
> >> a = {"what", "ever"}
> >> for i = 1, getn(a) do
> >>> print(a[i])
> >error: `do' expected;
> >  last token read: `doprint' at line 1 in stdin
>
> As far as I could determine, this only happens when you build lua.c with
> -DUSE_READLINE, that is, to use GNU readline.
>
> I missed the following sentence in realine's man page:
>
>  The line returned has the final newline removed, so only  the  text  of
>  the line remains.
>
> I assumed readline kept the \n at the end of the string. Sorry about that.
> I'll correct the code.  For the time being, here is a quick fix (tested):
>
> In load_string add
>
> #ifdef USE_READLINE
>     lua_pushstring(L, "\n");
> #endif

Heh, I was going to report that too---I found that in the backport of
readline, but I couldn't decide whose bug it really was.

So what this means is that

a = [[b
]]

has two characters in it, regardless of whether it's typed at the command
line or read from a file.

Is it a good idea to support "\\\n" such that

a = [[b\
]]

has only one character in it?

Jay