History

Lua 5.1.3

Lua Team committed 18 years ago

Commit 6ff5b771 parent ebb42b73 files · +15 −18Browse files

Unified · Split

3 files
  1. etc/luavs.bat +1 −1
  2. src/lauxlib.c +5 −6
  3. src/ldblib.c +9 −11
etc/luavs.bat+1−1
@@ -1,7 +1,7 @@
11 @rem Script to build Lua under "Visual Studio .NET Command Prompt".
22 @rem Do not run from this directory; run it from the toplevel: etc\luavs.bat .
33 @rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src.
4−@rem David Manura <dm.lua@math2.org> and Mike Pall <mikelu-0801@mike.de>
4+@rem (contributed by David Manura and Mike Pall)
55
66 @setlocal
77 @set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE
src/lauxlib.c+5−6
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lauxlib.c,v 1.159.1.2 2008/01/17 14:04:41 roberto Exp $
2+** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
33 ** Auxiliary functions for building Lua libraries
44 ** See Copyright Notice in lua.h
55 */
@@ -535,7 +535,7 @@ static const char *getF (lua_State *L, void *ud, size_t *size) { · 529 unmodified lines
535535 return "\n";
536536 }
537537 if (feof(lf->f)) return NULL;
538− *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f);
538+ *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
539539 return (*size > 0) ? lf->buff : NULL;
540540 }
541541
@@ -570,9 +570,8 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { · 28 unmodified lines
570570 while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
571571 if (c == '\n') c = getc(lf.f);
572572 }
573− if (c == LUA_SIGNATURE[0] && lf.f != stdin) { /* binary file? */
574− fclose(lf.f);
575− lf.f = fopen(filename, "rb"); /* reopen in binary mode */
573+ if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
574+ lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
576575 if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
577576 /* skip eventual `#!...' */
578577 while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
@@ -581,7 +580,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { · 2 unmodified lines
581580 ungetc(c, lf.f);
582581 status = lua_load(L, getF, &lf, lua_tostring(L, -1));
583582 readstatus = ferror(lf.f);
584− if (lf.f != stdin) fclose(lf.f); /* close file (even in case of errors) */
583+ if (filename) fclose(lf.f); /* close file (even in case of errors) */
585584 if (readstatus) {
586585 lua_settop(L, fnameindex); /* ignore results from `lua_load' */
587586 return errfile(L, "read", fnameindex);
src/ldblib.c+9−11
@@ -1,5 +1,5 @@
11 /*
2−** $Id: ldblib.c,v 1.104.1.2 2008/01/18 16:39:45 roberto Exp $
2+** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
33 ** Interface from Lua to its debug API
44 ** See Copyright Notice in lua.h
55 */
@@ -268,12 +268,11 @@ static int db_sethook (lua_State *L) { · 262 unmodified lines
268268 count = luaL_optint(L, arg+3, 0);
269269 func = hookf; mask = makemask(smask, count);
270270 }
271− gethooktable(L1);
272− lua_pushlightuserdata(L1, L1);
271+ gethooktable(L);
272+ lua_pushlightuserdata(L, L1);
273273 lua_pushvalue(L, arg+1);
274− lua_xmove(L, L1, 1);
275− lua_rawset(L1, -3); /* set new hook */
276− lua_pop(L1, 1); /* remove hook table */
274+ lua_rawset(L, -3); /* set new hook */
275+ lua_pop(L, 1); /* remove hook table */
277276 lua_sethook(L1, func, mask, count); /* set hooks */
278277 return 0;
279278 }
@@ -288,11 +287,10 @@ static int db_gethook (lua_State *L) { · 8 unmodified lines
288287 if (hook != NULL && hook != hookf) /* external hook? */
289288 lua_pushliteral(L, "external hook");
290289 else {
291− gethooktable(L1);
292− lua_pushlightuserdata(L1, L1);
293− lua_rawget(L1, -2); /* get hook */
294− lua_remove(L1, -2); /* remove hook table */
295− lua_xmove(L1, L, 1);
290+ gethooktable(L);
291+ lua_pushlightuserdata(L, L1);
292+ lua_rawget(L, -2); /* get hook */
293+ lua_remove(L, -2); /* remove hook table */
296294 }
297295 lua_pushstring(L, unmakemask(mask, buff));
298296 lua_pushinteger(L, lua_gethookcount(L1));