aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-03 19:48:36 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1994-11-03 19:48:36 -0200
commit852d9a859733ebf7322474c05244105e4f2748a2 (patch)
treed199091d514625e262cfd8dac109cbfbe31fc457
parent6b18cc9a170c1e3fbfcfe98cb771375ce164d6bf (diff)
downloadlua-852d9a859733ebf7322474c05244105e4f2748a2.tar.gz
lua-852d9a859733ebf7322474c05244105e4f2748a2.tar.bz2
lua-852d9a859733ebf7322474c05244105e4f2748a2.zip
function 'lua_addfile' returns an error message
-rw-r--r--table.c18
-rw-r--r--table.h4
2 files changed, 8 insertions, 14 deletions
diff --git a/table.c b/table.c
index 96728d95..26149d1a 100644
--- a/table.c
+++ b/table.c
@@ -3,7 +3,7 @@
3** Module to control static tables 3** Module to control static tables
4*/ 4*/
5 5
6char *rcs_table="$Id: table.c,v 2.7 1994/11/02 19:09:23 roberto Exp roberto $"; 6char *rcs_table="$Id: table.c,v 2.8 1994/11/02 20:29:09 roberto Exp roberto $";
7 7
8#include <stdlib.h> 8#include <stdlib.h>
9#include <string.h> 9#include <string.h>
@@ -233,21 +233,15 @@ char *lua_createstring (char *s)
233/* 233/*
234** Add a file name at file table, checking overflow. This function also set 234** Add a file name at file table, checking overflow. This function also set
235** the external variable "lua_filename" with the function filename set. 235** the external variable "lua_filename" with the function filename set.
236** Return 0 on success or 1 on error. 236** Return 0 on success or error message on error.
237*/ 237*/
238int lua_addfile (char *fn) 238char *lua_addfile (char *fn)
239{ 239{
240 if (lua_nfile >= MAXFILE-1) 240 if (lua_nfile >= MAXFILE-1)
241 { 241 return "too many files";
242 lua_error ("too many files");
243 return 1;
244 }
245 if ((lua_file[lua_nfile++] = strdup (fn)) == NULL) 242 if ((lua_file[lua_nfile++] = strdup (fn)) == NULL)
246 { 243 return "not enough memory";
247 lua_error ("not enough memory"); 244 return NULL;
248 return 1;
249 }
250 return 0;
251} 245}
252 246
253/* 247/*
diff --git a/table.h b/table.h
index 2ef50b0a..a885f201 100644
--- a/table.h
+++ b/table.h
@@ -1,7 +1,7 @@
1/* 1/*
2** Module to control static tables 2** Module to control static tables
3** TeCGraf - PUC-Rio 3** TeCGraf - PUC-Rio
4** $Id: table.h,v 2.2 1994/07/19 21:27:18 celes Exp $ 4** $Id: table.h,v 2.3 1994/10/17 19:03:23 celes Exp roberto $
5*/ 5*/
6 6
7#ifndef table_h 7#ifndef table_h
@@ -25,7 +25,7 @@ void lua_travsymbol (void (*fn)(Object *));
25void lua_markobject (Object *o); 25void lua_markobject (Object *o);
26void lua_pack (void); 26void lua_pack (void);
27char *lua_createstring (char *s); 27char *lua_createstring (char *s);
28int lua_addfile (char *fn); 28char *lua_addfile (char *fn);
29int lua_delfile (void); 29int lua_delfile (void);
30char *lua_filename (void); 30char *lua_filename (void);
31void lua_nextvar (void); 31void lua_nextvar (void);