From ff7f7694548a210cd41458538ebd4bd7bb817ddf Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 10 Nov 1994 18:41:37 -0200 Subject: [PATCH] small changes in error recovery --- table.c | 55 +++++++++++++------------------------------------------ tree.c | 4 ++-- 2 files changed, 15 insertions(+), 44 deletions(-) diff --git a/table.c b/table.c index 374fb316..7487321e 100644 --- a/table.c +++ b/table.c @@ -3,7 +3,7 @@ ** Module to control static tables */ -char *rcs_table="$Id: table.c,v 2.13 1994/11/08 20:07:54 roberto Exp $"; +char *rcs_table="$Id: table.c,v 2.14 1994/11/09 18:11:47 roberto Exp roberto $"; #include #include @@ -50,10 +50,7 @@ static void lua_initsymbol (void) lua_maxsymbol = BUFFER_BLOCK; lua_table = (Symbol *) calloc(lua_maxsymbol, sizeof(Symbol)); if (lua_table == NULL) - { - lua_error ("symbol table: not enough memory"); - return; - } + lua_error ("symbol table: not enough memory"); n = lua_findsymbol("next"); s_tag(n) = LUA_T_CFUNCTION; s_fvalue(n) = lua_next; n = lua_findsymbol("nextvar"); @@ -98,27 +95,16 @@ int lua_findsymbol (char *s) if (lua_table == NULL) lua_initsymbol(); n = lua_varcreate(s); - if (n == NULL) - { - lua_error ("create symbol: not enough memory"); - return -1; - } if (indexstring(n) == UNMARKED_STRING) { if (lua_ntable == lua_maxsymbol) { lua_maxsymbol *= 2; if (lua_maxsymbol > MAX_WORD) - { - lua_error("symbol table overflow"); - return -1; - } + lua_error("symbol table overflow"); lua_table = (Symbol *)realloc(lua_table, lua_maxsymbol*sizeof(Symbol)); if (lua_table == NULL) - { - lua_error ("symbol table: not enough memory"); - return -1; - } + lua_error ("symbol table: not enough memory"); } indexstring(n) = lua_ntable; s_tag(lua_ntable) = LUA_T_NIL; @@ -139,27 +125,16 @@ int lua_findconstant (char *s) if (lua_constant == NULL) lua_initconstant(); n = lua_constcreate(s); - if (n == NULL) - { - lua_error ("create constant: not enough memory"); - return -1; - } if (indexstring(n) == UNMARKED_STRING) { if (lua_nconstant == lua_maxconstant) { lua_maxconstant *= 2; if (lua_maxconstant > MAX_WORD) - { - lua_error("constant table overflow"); - return -1; - } + lua_error("constant table overflow"); lua_constant = (char**)realloc(lua_constant,lua_maxconstant*sizeof(char*)); if (lua_constant == NULL) - { - lua_error ("constant table: not enough memory"); - return -1; - } + lua_error ("constant table: not enough memory"); } indexstring(n) = lua_nconstant; lua_constant[lua_nconstant] = n; @@ -267,22 +242,18 @@ void lua_nextvar (void) char *varname, *next; lua_Object o = lua_getparam(1); if (o == 0) - { lua_error ("too few arguments to function `nextvar'"); return; } + lua_error ("too few arguments to function `nextvar'"); if (lua_getparam(2) != NULL) - { lua_error ("too many arguments to function `nextvar'"); return; } + lua_error ("too many arguments to function `nextvar'"); if (lua_isnil(o)) - { - varname = NULL; - } + varname = NULL; else if (!lua_isstring(o)) - { - lua_error ("incorrect argument to function `nextvar'"); - return; + { + lua_error ("incorrect argument to function `nextvar'"); + return; /* to avoid warnings */ } else - { - varname = lua_getstring(o); - } + varname = lua_getstring(o); next = lua_varnext(varname); if (next == NULL) { diff --git a/tree.c b/tree.c index 89e875d3..ae5a19de 100644 --- a/tree.c +++ b/tree.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_tree="$Id: tree.c,v 1.1 1994/07/19 21:24:17 celes Exp $"; +char *rcs_tree="$Id: tree.c,v 1.2 1994/10/18 17:36:11 celes Exp roberto $"; #include @@ -38,7 +38,7 @@ static char *tree_create (TreeNode **node, char *str, int *created) { *node = (TreeNode *) malloc (sizeof(TreeNode)+strlen(str)); if (*node == NULL) - lua_error ("memoria insuficiente\n"); + lua_error("not enough memory"); (*node)->left = (*node)->right = NULL; strcpy((*node)->str, str); (*node)->index = UNMARKED_STRING;