From 39395e12118539d983fdefbbc50d3aac3f53ccad Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 16 Nov 2001 14:29:10 -0200 Subject: `luaX_syntaxerror' does not need to be public --- llex.c | 30 ++++++++++++++++++------------ llex.h | 3 +-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/llex.c b/llex.c index 4f5dbb3b..670da132 100644 --- a/llex.c +++ b/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 1.89 2001/07/22 00:59:36 roberto Exp $ +** $Id: llex.c,v 1.91 2001/08/31 19:46:07 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -58,7 +58,8 @@ void luaX_checklimit (LexState *ls, int val, int limit, const l_char *msg) { } -void luaX_syntaxerror (LexState *ls, const l_char *s, const l_char *token) { +static void luaX_syntaxerror (LexState *ls, const l_char *s, + const l_char *token) { l_char buff[MAXSRC]; luaO_chunkid(buff, getstr(ls->source), MAXSRC); luaO_verror(ls->L, @@ -67,16 +68,6 @@ void luaX_syntaxerror (LexState *ls, const l_char *s, const l_char *token) { } -void luaX_error (LexState *ls, const l_char *s, int token) { - l_char buff[TOKEN_LEN]; - luaX_token2str(token, buff); - if (buff[0] == l_c('\0')) - luaX_syntaxerror(ls, s, cast(l_char *, G(ls->L)->Mbuffer)); - else - luaX_syntaxerror(ls, s, buff); -} - - void luaX_token2str (int token, l_char *s) { if (token < FIRST_RESERVED) { lua_assert(token == (l_char)token); @@ -88,6 +79,21 @@ void luaX_token2str (int token, l_char *s) { } +static l_char *token2str_all (LexState *ls, int token, l_char *s) { + luaX_token2str(token, s); + if (s[0] == l_c('\0')) + return cast(l_char *, G(ls->L)->Mbuffer); + else + return s; +} + + +void luaX_error (LexState *ls, const l_char *s, int token) { + l_char buff[TOKEN_LEN]; + luaX_syntaxerror(ls, s, token2str_all(ls, token, buff)); +} + + static void luaX_invalidchar (LexState *ls, int c) { l_char buff[8]; sprintf(buff, l_s("0x%02X"), uchar(c)); diff --git a/llex.h b/llex.h index fbfe092d..69242cee 100644 --- a/llex.h +++ b/llex.h @@ -1,5 +1,5 @@ /* -** $Id: llex.h,v 1.37 2001/07/22 00:59:36 roberto Exp $ +** $Id: llex.h,v 1.38 2001/08/31 19:46:07 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -65,7 +65,6 @@ void luaX_init (lua_State *L); void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source); int luaX_lex (LexState *LS, SemInfo *seminfo); void luaX_checklimit (LexState *ls, int val, int limit, const l_char *msg); -void luaX_syntaxerror (LexState *ls, const l_char *s, const l_char *token); void luaX_error (LexState *ls, const l_char *s, int token); void luaX_token2str (int token, l_char *s); -- cgit v1.2.3-55-g6feb