diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-10-10 19:23:04 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-10-10 19:23:04 -0300 |
commit | 56d45378796b881b638671655164a16bb8ad8a57 (patch) | |
tree | 45c72650efbf33f5e7f22697e26af29a3e469541 /lobject.c | |
parent | 18014ef2fdffc6b7a1418ce3accecb273acc4b6d (diff) | |
download | lua-56d45378796b881b638671655164a16bb8ad8a57.tar.gz lua-56d45378796b881b638671655164a16bb8ad8a57.tar.bz2 lua-56d45378796b881b638671655164a16bb8ad8a57.zip |
'$c' in 'lua_pushfstring' prints non-printable characters with
their codes
Diffstat (limited to 'lobject.c')
-rw-r--r-- | lobject.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 2.90 2014/10/01 11:52:33 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.91 2014/10/04 22:57:10 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -377,7 +377,10 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | |||
377 | } | 377 | } |
378 | case 'c': { | 378 | case 'c': { |
379 | char buff = cast(char, va_arg(argp, int)); | 379 | char buff = cast(char, va_arg(argp, int)); |
380 | pushstr(L, &buff, 1); | 380 | if (lisprint(cast_uchar(buff))) |
381 | pushstr(L, &buff, 1); | ||
382 | else /* non-printable character; print its code */ | ||
383 | luaO_pushfstring(L, "<\\%d>", cast_uchar(buff)); | ||
381 | break; | 384 | break; |
382 | } | 385 | } |
383 | case 'd': { | 386 | case 'd': { |