From 7c5786479c1d617ec7c133f2c2b955726436267a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 3 May 2019 10:18:44 -0300 Subject: A few more improvements in 'luaO_pushvfstring' - 'L' added to the 'BuffFS' structure - '%c' does not handle control characters (it is not its business. This now is done by the lexer, who is the one in charge of that kind of errors.) - avoid the direct use of 'l_sprintf' in the Lua kernel --- llex.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llex.c') diff --git a/llex.c b/llex.c index bb81cec4..226127f6 100644 --- a/llex.c +++ b/llex.c @@ -82,7 +82,10 @@ void luaX_init (lua_State *L) { const char *luaX_token2str (LexState *ls, int token) { if (token < FIRST_RESERVED) { /* single-byte symbols? */ lua_assert(token == cast_uchar(token)); - return luaO_pushfstring(ls->L, "'%c'", token); + if (lisprint(token)) + return luaO_pushfstring(ls->L, "'%c'", token); + else /* control character */ + return luaO_pushfstring(ls->L, "'<\\%d>'", token); } else { const char *s = luaX_tokens[token - FIRST_RESERVED]; -- cgit v1.2.3-55-g6feb