[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to read thru a script file from C a line at a time.
- From: "Edward Mitchell" <emitchell@...>
- Date: Tue, 17 Oct 2006 21:38:36 -0400
"Jason Zhang" <jzhang@sunrisetelecom.com.cn> wrote in message
news:014901c6f22d$efcb0e30$a300000a@LAPTOPSRC...
> You can have a look at the lua.c.
>
I'm not sure where to look. I would expect a loop like:
while(templateFile) {
templateFile.getline(buff, BUFSIZ);
// ?? debug echo to the console
fprintf(stdout, "%s\n", buff);
// loop until there is a complete syntax element
while(!luaL_loadbuffer(L, buff, strlen(buff), "Line") {
templateFile.getline(buff, BUFSIZ);
}
// execute the complete chunk on the stack
int iError = lua_pcall(L, 0, 0, 0);
if(iError) {
...
break;
}
}
where I would keep on calling luaL_loadbuffer(...) until the syntax analyser
said that the last syntax element was complete. luaL_loadbuffer(...) seems
to only return
As far as I can see, there's nothing like this in lua.c. It seems that
lua_load(...) (or luaL_loadbuffer) should return an status code that implies
"Needs more input."