aboutsummaryrefslogtreecommitdiff
path: root/llex.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-05-03 10:18:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-05-03 10:18:44 -0300
commit7c5786479c1d617ec7c133f2c2b955726436267a (patch)
tree614cbcd89903fdbb06208a0c17196264da6a4166 /llex.c
parentb14609032cf328dea48b0803f3e585e223283b3d (diff)
downloadlua-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.c5
1 files changed, 4 insertions, 1 deletions
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) {
82const char *luaX_token2str (LexState *ls, int token) { 82const 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];