[prev in list] [next in list] [prev in thread] [next in thread]
List: lua-l
Subject: Re: Take into account __tostring whet printing _PROMPT
From: Luiz Henrique de Figueiredo <lhf () tecgraf ! puc-rio ! br>
Date: 2020-10-22 16:10:32
Message-ID: CAD55k3p0GbJ6RROCi9GRsmXjSd2tpZhpiKG-y5b2A3p_4fAn0Q () mail ! gmail ! com
[Download RAW message or body]
> Why doesn't interactive Lua takes into account the __tostring metamethod
> of the non-string _PROMPT global when it prints the prompt,
Replace get_prompt in lua.c by the code below and rebuild.
It seems to work, but it hasn't been thoroughly tested.
The original code uses lua_tostring, which does not honor the
__tostring metamethod; luaL_tolstring does.
static const char *get_prompt (lua_State *L, int firstline) {
const char *p;
if (lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2") == LUA_TNIL)
p = (firstline ? LUA_PROMPT : LUA_PROMPT2);
else {
p = luaL_tolstring(L, -1, NULL);
lua_remove(L, -2); /* remove original value */
}
return p;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic