mirror of
https://github.com/lua/lua
synced 2024-11-22 21:01:26 +03:00
small changes in error recovery
This commit is contained in:
parent
8a0521fa52
commit
ff7f769454
55
table.c
55
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 <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -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)
|
||||
{
|
||||
|
4
tree.c
4
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 <stdlib.h>
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user