lua-users home
lua-l archive

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


Hello Luiz,

Thursday, February 16, 2006, 5:19:44 PM, you wrote:


>>       In lua 5.1 , I found we can use luac -s to strip debug
>>       information . But why the source file name is still in the
>>       binary block ?

LHdF> Lua needs a filename for error messages. We could replace the original
LHdF> filename by "?" or something like that, but filenames do not take much
LHdF> space anyway in precompiled chunks (they appear once only).
LHdF> Do you *need* to remove filenames?
LHdF> --lhf

Some simple modules never throw error messages or I don't care the
error messages. These modules are really small, and the string of filename with
path is longer than module's bytecodes.

Since I strip the debug information, usually I don't care the error
messages.

Another reason is, I want to publish some modules in bytecodes sometimes, and I don't
want to the pathname string exsits in the module block for some reason.

So I think let us have some way the strip this string would be better.

I read the lundump.c and saw
----------
Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
{
 LoadState S;
 if (*name=='@' || *name=='=')
  S.name=name+1;
 else if (*name==LUA_SIGNATURE[0])
  S.name="binary string";
 else
  S.name=name;
 S.L=L;
 S.Z=Z;
 S.b=buff;
 LoadHeader(&S);
 return LoadFunction(&S,NULL);
}
---------
the name can be the "\0", doesn't it?

-- 
Best regards,
 cloudwu                            mailto:cloudwu@163.com
            http://www.codingnow.com

[富贵而骄, 自遗其咎]