diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-05-03 10:18:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-05-03 10:18:44 -0300 |
commit | 7c5786479c1d617ec7c133f2c2b955726436267a (patch) | |
tree | 614cbcd89903fdbb06208a0c17196264da6a4166 /llex.c | |
parent | b14609032cf328dea48b0803f3e585e223283b3d (diff) | |
download | lua-7c5786479c1d617ec7c133f2c2b955726436267a.tar.gz lua-7c5786479c1d617ec7c133f2c2b955726436267a.tar.bz2 lua-7c5786479c1d617ec7c133f2c2b955726436267a.zip |
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
Diffstat (limited to 'llex.c')
-rw-r--r-- | llex.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -82,7 +82,10 @@ void luaX_init (lua_State *L) { | |||
82 | const char *luaX_token2str (LexState *ls, int token) { | 82 | const char *luaX_token2str (LexState *ls, int token) { |
83 | if (token < FIRST_RESERVED) { /* single-byte symbols? */ | 83 | if (token < FIRST_RESERVED) { /* single-byte symbols? */ |
84 | lua_assert(token == cast_uchar(token)); | 84 | lua_assert(token == cast_uchar(token)); |
85 | return luaO_pushfstring(ls->L, "'%c'", token); | 85 | if (lisprint(token)) |
86 | return luaO_pushfstring(ls->L, "'%c'", token); | ||
87 | else /* control character */ | ||
88 | return luaO_pushfstring(ls->L, "'<\\%d>'", token); | ||
86 | } | 89 | } |
87 | else { | 90 | else { |
88 | const char *s = luaX_tokens[token - FIRST_RESERVED]; | 91 | const char *s = luaX_tokens[token - FIRST_RESERVED]; |