lua-users home
lua-l archive

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


It was thus said that the Great Philipp Kraus once stated:
> 
> In my main I do something like
> 
> CInterpreter x("function abcd() print(‚test') end“)
> CInterpreter y(x.m_binaryscript) <- This line creates the truncated chunk error
> 
> IMHO luaL_loadstring adds the compiled script on the stack top, my Lua
> dump function adds the full data into a std::string, because on a
> std::string the chunk is ended with \0 (I have tested the call with change
> the std::string to std::vector<char> but I get equal errors). The
> lua_pcall runs the script, which is on the stack top, so I don’t see my
> mistake at the moment why the chunk with should be stored in the
> std::string is incomplete.
> 
> Can anybody help me to create a correct dumping process?

  One question, not knowing C++, but what happens when you call
(p_target)->append() with a string with embedded NUL bytes (and not just a
NUL character ('\0') at the end)?  From your problem, it seems like append()
will stop appending when it sees p_size non-NUL characters, or at the first
NUL character.

  -spc (lua_dump() produces binary data ... )