aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-06-10 16:36:24 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-06-10 16:36:24 -0300
commit3211a9648a0f48c5541b45234b42e532727aa7d7 (patch)
treef13814f91f6ae4fee4917cb267dded6818d55bdb
parent0baa915343cbf7fd1f310ea640a0d72ec626273b (diff)
downloadlua-3211a9648a0f48c5541b45234b42e532727aa7d7.tar.gz
lua-3211a9648a0f48c5541b45234b42e532727aa7d7.tar.bz2
lua-3211a9648a0f48c5541b45234b42e532727aa7d7.zip
"lua_dofile" returns different error codes if it could not open the file
-rw-r--r--opcode.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/opcode.c b/opcode.c
index 237be758..106ab291 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 3.68 1996/04/25 14:10:00 roberto Exp roberto $"; 6char *rcs_opcode="$Id: opcode.c,v 3.69 1996/05/28 21:07:32 roberto Exp roberto $";
7 7
8#include <setjmp.h> 8#include <setjmp.h>
9#include <stdio.h> 9#include <stdio.h>
@@ -539,7 +539,7 @@ int lua_call (char *funcname)
539 539
540/* 540/*
541** Open file, generate opcode and execute global statement. Return 0 on 541** Open file, generate opcode and execute global statement. Return 0 on
542** success or 1 on error. 542** success or non 0 on error.
543*/ 543*/
544int lua_dofile (char *filename) 544int lua_dofile (char *filename)
545{ 545{
@@ -547,7 +547,7 @@ int lua_dofile (char *filename)
547 int c; 547 int c;
548 FILE *f = lua_openfile(filename); 548 FILE *f = lua_openfile(filename);
549 if (f == NULL) 549 if (f == NULL)
550 return 1; 550 return 2;
551 c = fgetc(f); 551 c = fgetc(f);
552 ungetc(c, f); 552 ungetc(c, f);
553 status = (c == ID_CHUNK) ? luaI_undump(f) : do_protectedmain(); 553 status = (c == ID_CHUNK) ? luaI_undump(f) : do_protectedmain();
@@ -557,12 +557,14 @@ int lua_dofile (char *filename)
557 557
558/* 558/*
559** Generate opcode stored on string and execute global statement. Return 0 on 559** Generate opcode stored on string and execute global statement. Return 0 on
560** success or 1 on error. 560** success or non 0 on error.
561*/ 561*/
562int lua_dostring (char *string) 562int lua_dostring (char *str)
563{ 563{
564 int status; 564 int status;
565 lua_openstring(string); 565 if (str == NULL)
566 return 1;
567 lua_openstring(str);
566 status = do_protectedmain(); 568 status = do_protectedmain();
567 lua_closestring(); 569 lua_closestring();
568 return status; 570 return status;