mirror of
https://github.com/lua/lua
synced 2024-12-24 19:36:50 +03:00
format for file source is independent of "ldo".
This commit is contained in:
parent
2679461637
commit
f2d35bdc78
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.14 1999/02/25 19:13:56 roberto Exp roberto $
|
** $Id: lauxlib.c,v 1.15 1999/03/04 21:17:26 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -126,3 +126,10 @@ void luaL_chunkid (char *out, char *source, int len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void luaL_filesource (char *out, char *filename, int len) {
|
||||||
|
if (filename == NULL)
|
||||||
|
strcpy(out, "@(stdin)");
|
||||||
|
else
|
||||||
|
sprintf(out, "@%.*s", len-2, filename); /* -2 for '@' and '\0' */
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.h,v 1.10 1998/12/28 13:44:54 roberto Exp roberto $
|
** $Id: lauxlib.h,v 1.11 1999/03/04 21:17:26 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -47,5 +47,7 @@ void luaL_oldbuffer (int old);
|
|||||||
char *luaL_buffer (void);
|
char *luaL_buffer (void);
|
||||||
int luaL_findstring (char *name, char *list[]);
|
int luaL_findstring (char *name, char *list[]);
|
||||||
void luaL_chunkid (char *out, char *source, int len);
|
void luaL_chunkid (char *out, char *source, int len);
|
||||||
|
void luaL_filesource (char *out, char *filename, int len);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
11
ldo.c
11
ldo.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.37 1999/03/04 21:17:26 roberto Exp roberto $
|
** $Id: ldo.c,v 1.38 1999/03/05 20:45:01 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -362,20 +362,17 @@ int lua_dofile (char *filename) {
|
|||||||
int status;
|
int status;
|
||||||
int c;
|
int c;
|
||||||
int bin;
|
int bin;
|
||||||
char name[MAXFILENAME+2]; /* +2 for '@' and '\0' */
|
char source[MAXFILENAME];
|
||||||
FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
|
FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return 2;
|
return 2;
|
||||||
if (filename == NULL)
|
|
||||||
strcpy(name, "@(stdin)");
|
|
||||||
else
|
|
||||||
sprintf(name, "@%.*s", MAXFILENAME, filename);
|
|
||||||
c = fgetc(f);
|
c = fgetc(f);
|
||||||
ungetc(c, f);
|
ungetc(c, f);
|
||||||
bin = (c == ID_CHUNK);
|
bin = (c == ID_CHUNK);
|
||||||
if (bin)
|
if (bin)
|
||||||
f = freopen(filename, "rb", f); /* set binary mode */
|
f = freopen(filename, "rb", f); /* set binary mode */
|
||||||
luaZ_Fopen(&z, f, name);
|
luaL_filesource(source, filename, MAXFILENAME);
|
||||||
|
luaZ_Fopen(&z, f, source);
|
||||||
status = do_main(&z, bin);
|
status = do_main(&z, bin);
|
||||||
if (f != stdin)
|
if (f != stdin)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
Loading…
Reference in New Issue
Block a user