summaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-03-10 11:19:41 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-03-10 11:19:41 -0300
commitf2d35bdc7831dce6b1e9fcd639510bdc91488bc2 (patch)
tree6d0f085cf894f31605e52ad0ce2a1e11cea190f3 /ldo.c
parent26794616374fee54532d0030ae006abb77dfb7ba (diff)
downloadlua-f2d35bdc7831dce6b1e9fcd639510bdc91488bc2.tar.gz
lua-f2d35bdc7831dce6b1e9fcd639510bdc91488bc2.tar.bz2
lua-f2d35bdc7831dce6b1e9fcd639510bdc91488bc2.zip
format for file source is independent of "ldo".
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/ldo.c b/ldo.c
index 951348b9..c79b3beb 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.37 1999/03/04 21:17:26 roberto Exp roberto $ 2** $Id: ldo.c,v 1.38 1999/03/05 20:45:01 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -362,20 +362,17 @@ int lua_dofile (char *filename) {
362 int status; 362 int status;
363 int c; 363 int c;
364 int bin; 364 int bin;
365 char name[MAXFILENAME+2]; /* +2 for '@' and '\0' */ 365 char source[MAXFILENAME];
366 FILE *f = (filename == NULL) ? stdin : fopen(filename, "r"); 366 FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
367 if (f == NULL) 367 if (f == NULL)
368 return 2; 368 return 2;
369 if (filename == NULL)
370 strcpy(name, "@(stdin)");
371 else
372 sprintf(name, "@%.*s", MAXFILENAME, filename);
373 c = fgetc(f); 369 c = fgetc(f);
374 ungetc(c, f); 370 ungetc(c, f);
375 bin = (c == ID_CHUNK); 371 bin = (c == ID_CHUNK);
376 if (bin) 372 if (bin)
377 f = freopen(filename, "rb", f); /* set binary mode */ 373 f = freopen(filename, "rb", f); /* set binary mode */
378 luaZ_Fopen(&z, f, name); 374 luaL_filesource(source, filename, MAXFILENAME);
375 luaZ_Fopen(&z, f, source);
379 status = do_main(&z, bin); 376 status = do_main(&z, bin);
380 if (f != stdin) 377 if (f != stdin)
381 fclose(f); 378 fclose(f);