Refactor internal string formatting.

This commit is contained in:
Mike Pall
2013-05-12 23:52:09 +02:00
parent 7d5acc2918
commit 19a9206caf
14 changed files with 149 additions and 126 deletions

View File

@@ -25,6 +25,7 @@
#include "lj_parse.h"
#include "lj_char.h"
#include "lj_strscan.h"
#include "lj_strfmt.h"
/* Lua lexer token names. */
static const char *const tokennames[] = {
@@ -444,9 +445,9 @@ const char *lj_lex_token2str(LexState *ls, LexToken tok)
if (tok > TK_OFS)
return tokennames[tok-TK_OFS-1];
else if (!lj_char_iscntrl(tok))
return lj_str_pushf(ls->L, "%c", tok);
return lj_strfmt_pushf(ls->L, "%c", tok);
else
return lj_str_pushf(ls->L, "char(%d)", tok);
return lj_strfmt_pushf(ls->L, "char(%d)", tok);
}
/* Lexer error. */