mirror of https://github.com/rusefi/lua.git
'$c' in 'lua_pushfstring' prints non-printable characters with
their codes
This commit is contained in:
parent
18014ef2fd
commit
56d4537879
7
llex.c
7
llex.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 2.80 2014/07/18 13:36:14 roberto Exp roberto $
|
** $Id: llex.c,v 2.81 2014/10/01 11:52:33 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -78,9 +78,8 @@ void luaX_init (lua_State *L) {
|
||||||
|
|
||||||
const char *luaX_token2str (LexState *ls, int token) {
|
const char *luaX_token2str (LexState *ls, int token) {
|
||||||
if (token < FIRST_RESERVED) { /* single-byte symbols? */
|
if (token < FIRST_RESERVED) { /* single-byte symbols? */
|
||||||
lua_assert(token == cast(unsigned char, token));
|
lua_assert(token == cast_uchar(token));
|
||||||
return (lisprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) :
|
return luaO_pushfstring(ls->L, LUA_QL("%c"), token);
|
||||||
luaO_pushfstring(ls->L, "char(%d)", token);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const char *s = luaX_tokens[token - FIRST_RESERVED];
|
const char *s = luaX_tokens[token - FIRST_RESERVED];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lobject.c,v 2.90 2014/10/01 11:52:33 roberto Exp roberto $
|
** $Id: lobject.c,v 2.91 2014/10/04 22:57:10 roberto Exp roberto $
|
||||||
** Some generic functions over Lua objects
|
** Some generic functions over Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -377,7 +377,10 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
|
||||||
}
|
}
|
||||||
case 'c': {
|
case 'c': {
|
||||||
char buff = cast(char, va_arg(argp, int));
|
char buff = cast(char, va_arg(argp, int));
|
||||||
|
if (lisprint(cast_uchar(buff)))
|
||||||
pushstr(L, &buff, 1);
|
pushstr(L, &buff, 1);
|
||||||
|
else /* non-printable character; print its code */
|
||||||
|
luaO_pushfstring(L, "<\\%d>", cast_uchar(buff));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'd': {
|
case 'd': {
|
||||||
|
|
Loading…
Reference in New Issue