lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:
I've been playing around with prefixing the scripts I load with startup code. This I've been doing with lua_load() and chunks. I've come across the problem that if I want to flag a specific error in the code that the user wrote I want to be able to tell them in which line number in /their/ code this error occurred on.

Is the only way to do this to scan the characters for \r?\n before they reach lua_load()?

Unfortunately, I cannot see a better way. Just be careful to translate \r and
\n to a space, instead of deleting them...

Also, if this is the case, is there some means of solving this when loading a pre-compiled lua chunk?


How so? Text and pre-compiled chunks cannot be mixed. The code that loads
pre-compiled chunks stops as soon as it loads the chunk; it loads only one
chunk. Unless you're pretty intimate with the format of pre-compiled chunks,
there's not much you can change. And even if you are, changing something will
require code equivalent to loading the pre-compiled chunk...

Thanks! After a bit of thinking of the ramifications of all this I started looking at what functionality I needed to prefix. At the moment it appears that everything can be done with C code. It's mostly just table accesses, etc.

And hopefully once it's all done I'll be able to support both textual and precompiled chunks, yay :)

Thanks again,
- Mab