summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lapi.c7
-rw-r--r--src/lauxlib.h4
-rw-r--r--src/lbitlib.c5
-rw-r--r--src/lcode.c8
-rw-r--r--src/ldebug.c12
-rw-r--r--src/ldo.c10
-rw-r--r--src/loadlib.c42
-rw-r--r--src/ltablib.c4
-rw-r--r--src/ltm.c10
-rw-r--r--src/ltm.h6
-rw-r--r--src/lua.h8
-rw-r--r--src/luaconf.h10
12 files changed, 78 insertions, 48 deletions
diff --git a/src/lapi.c b/src/lapi.c
index b822a725..56c0c1e9 100644
--- a/src/lapi.c
+++ b/src/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 2.109 2010/01/08 15:16:56 roberto Exp $
+** $Id: lapi.c,v 2.111 2010/01/13 16:18:25 roberto Exp $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -255,7 +255,7 @@ LUA_API int lua_type (lua_State *L, int idx) {
LUA_API const char *lua_typename (lua_State *L, int t) {
UNUSED(L);
- return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
+ return typename(t);
}
@@ -300,7 +300,8 @@ LUA_API void lua_arith (lua_State *L, int op) {
luaO_arith(op, nvalue(L->top - 2), nvalue(L->top - 1)));
}
else
- luaV_arith(L, L->top - 2, L->top - 2, L->top - 1, op - LUA_OPADD + TM_ADD);
+ luaV_arith(L, L->top - 2, L->top - 2, L->top - 1,
+ cast(TMS, op - LUA_OPADD + TM_ADD));
L->top--;
lua_unlock(L);
}
diff --git a/src/lauxlib.h b/src/lauxlib.h
index d0143481..b8f2e2e5 100644
--- a/src/lauxlib.h
+++ b/src/lauxlib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.h,v 1.98 2010/01/06 15:14:15 roberto Exp $
+** $Id: lauxlib.h,v 1.99 2010/01/11 16:00:45 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -29,8 +29,6 @@ typedef struct luaL_Reg {
LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver);
#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM)
-LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
- const luaL_Reg *l, int nup);
LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
const luaL_Reg *l);
LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
diff --git a/src/lbitlib.c b/src/lbitlib.c
index 5b6a6aae..1d5a2642 100644
--- a/src/lbitlib.c
+++ b/src/lbitlib.c
@@ -1,9 +1,12 @@
/*
-** $Id: lbitlib.c,v 1.2 2009/11/24 12:05:44 roberto Exp $
+** $Id: lbitlib.c,v 1.3 2010/01/12 19:40:02 roberto Exp $
** Standard library for bitwise operations
** See Copyright Notice in lua.h
*/
+#define lbitlib_c
+#define LUA_LIB
+
#include "lua.h"
#include "lauxlib.h"
diff --git a/src/lcode.c b/src/lcode.c
index 4f10e095..c55ebd54 100644
--- a/src/lcode.c
+++ b/src/lcode.c
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 2.42 2009/09/23 20:33:05 roberto Exp $
+** $Id: lcode.c,v 2.43 2010/01/11 17:38:30 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -830,15 +830,15 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
}
case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
case OPR_MOD: case OPR_POW: {
- codearith(fs, op - OPR_ADD + OP_ADD, e1, e2);
+ codearith(fs, cast(OpCode, op - OPR_ADD + OP_ADD), e1, e2);
break;
}
case OPR_EQ: case OPR_LT: case OPR_LE: {
- codecomp(fs, op - OPR_EQ + OP_EQ, 1, e1, e2);
+ codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2);
break;
}
case OPR_NE: case OPR_GT: case OPR_GE: {
- codecomp(fs, op - OPR_NE + OP_EQ, 0, e1, e2);
+ codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2);
break;
}
default: lua_assert(0);
diff --git a/src/ldebug.c b/src/ldebug.c
index 1c18d701..2544a5dd 100644
--- a/src/ldebug.c
+++ b/src/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 2.61 2010/01/06 14:42:35 roberto Exp $
+** $Id: ldebug.c,v 2.63 2010/01/13 16:18:25 roberto Exp $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -363,7 +363,7 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int reg,
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
- TMS tm = 0;
+ TMS tm;
Instruction i;
if ((ci->callstatus & CIST_TAIL) || !isLua(ci->previous))
return NULL; /* calling function is not Lua (or is unknown) */
@@ -416,7 +416,7 @@ static int isinstack (CallInfo *ci, const TValue *o) {
void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
CallInfo *ci = L->ci;
const char *name = NULL;
- const char *t = luaT_typenames[ttype(o)];
+ const char *t = typename(ttype(o));
const char *kind = (isLua(ci) && isinstack(ci, o)) ?
getobjname(L, ci, cast_int(o - ci->u.l.base), &name) :
NULL;
@@ -444,9 +444,9 @@ void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
- const char *t1 = luaT_typenames[ttype(p1)];
- const char *t2 = luaT_typenames[ttype(p2)];
- if (t1[2] == t2[2])
+ const char *t1 = typename(ttype(p1));
+ const char *t2 = typename(ttype(p2));
+ if (t1 == t2)
luaG_runerror(L, "attempt to compare two %s values", t1);
else
luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
diff --git a/src/ldo.c b/src/ldo.c
index 555113d3..4890ce21 100644
--- a/src/ldo.c
+++ b/src/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 2.79 2009/12/22 15:32:50 roberto Exp $
+** $Id: ldo.c,v 2.80 2010/01/13 16:17:32 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -554,8 +554,12 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) {
luai_userstateyield(L, nresults);
lua_lock(L);
api_checknelems(L, nresults);
- if (L->nny > 0)
- luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
+ if (L->nny > 0) {
+ if (L != G(L)->mainthread)
+ luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
+ else
+ luaG_runerror(L, "attempt to yield from outside a coroutine");
+ }
L->status = LUA_YIELD;
if (isLua(ci)) { /* inside a hook? */
api_check(L, k == NULL, "hooks cannot continue after yielding");
diff --git a/src/loadlib.c b/src/loadlib.c
index 8b2d6911..90c785dc 100644
--- a/src/loadlib.c
+++ b/src/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.73 2010/01/06 14:35:17 roberto Exp $
+** $Id: loadlib.c,v 1.80 2010/01/13 16:30:27 roberto Exp $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -129,9 +129,18 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
** =======================================================================
*/
+#include <windows.h>
#undef setprogdir
+/*
+** optional flags for LoadLibraryEx
+*/
+#if !defined(LUA_LLE_FLAGS)
+#define LUA_LLE_FLAGS 0
+#endif
+
+
static void setprogdir (lua_State *L) {
char buff[MAX_PATH + 1];
char *lb;
@@ -158,12 +167,12 @@ static void pusherror (lua_State *L) {
}
static void ll_unloadlib (void *lib) {
- FreeLibrary((HINSTANCE)lib);
+ FreeLibrary((HMODULE)lib);
}
static void *ll_load (lua_State *L, const char *path, int seeglb) {
- HINSTANCE lib = LoadLibrary(path);
+ HMODULE lib = LoadLibraryEx(path, NULL, LUA_LLE_FLAGS);
(void)(seeglb); /* symbols are 'global' by default? */
if (lib == NULL) pusherror(L);
return lib;
@@ -171,7 +180,7 @@ static void *ll_load (lua_State *L, const char *path, int seeglb) {
static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
- lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym);
+ lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym);
if (f == NULL) pusherror(L);
return f;
}
@@ -344,7 +353,9 @@ static int ll_loadfunc (lua_State *L, const char *path, const char *sym) {
lua_CFunction f = ll_sym(L, *reg, sym);
if (f == NULL)
return ERRFUNC; /* unable to find function */
- lua_pushcfunction(L, f); /* else return function */
+ lua_pushcfunction(L, f); /* else create new function... */
+ lua_pushglobaltable(L); /* ... and set the standard global table... */
+ lua_setfenv(L, -2); /* ... as its environment */
return 0; /* no errors */
}
}
@@ -394,6 +405,7 @@ static const char *pushnexttemplate (lua_State *L, const char *path) {
static const char *searchpath (lua_State *L, const char *name,
const char *path) {
+ name = luaL_gsub(L, name, ".", LUA_DIRSEP);
lua_pushliteral(L, ""); /* error accumulator */
while ((path = pushnexttemplate(L, path)) != NULL) {
const char *filename = luaL_gsub(L, lua_tostring(L, -1),
@@ -423,7 +435,6 @@ static int ll_searchpath (lua_State *L) {
static const char *findfile (lua_State *L, const char *name,
const char *pname) {
const char *path;
- name = luaL_gsub(L, name, ".", LUA_DIRSEP);
lua_getfield(L, LUA_ENVIRONINDEX, pname);
path = lua_tostring(L, -1);
if (path == NULL)
@@ -449,13 +460,20 @@ static int loader_Lua (lua_State *L) {
}
-static int loadfunc(lua_State *L, const char *filename, const char *modname) {
+static int loadfunc (lua_State *L, const char *filename, const char *modname) {
const char *funcname;
- const char *mark = strchr(modname, *LUA_IGMARK);
- if (mark) modname = mark + 1;
- funcname = luaL_gsub(L, modname, ".", LUA_OFSEP);
- funcname = lua_pushfstring(L, POF"%s", funcname);
- lua_remove(L, -2); /* remove 'gsub' result */
+ const char *mark;
+ modname = luaL_gsub(L, modname, ".", LUA_OFSEP);
+ mark = strchr(modname, *LUA_IGMARK);
+ if (mark) {
+ int stat;
+ funcname = lua_pushlstring(L, modname, mark - modname);
+ funcname = lua_pushfstring(L, POF"%s", funcname);
+ stat = ll_loadfunc(L, filename, funcname);
+ if (stat != ERRFUNC) return stat;
+ modname = mark + 1; /* else go ahead and try old-style name */
+ }
+ funcname = lua_pushfstring(L, POF"%s", modname);
return ll_loadfunc(L, filename, funcname);
}
diff --git a/src/ltablib.c b/src/ltablib.c
index b2360807..6ad6b8e0 100644
--- a/src/ltablib.c
+++ b/src/ltablib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltablib.c,v 1.53 2009/12/28 16:30:31 roberto Exp $
+** $Id: ltablib.c,v 1.54 2010/01/13 19:59:10 roberto Exp $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@@ -178,6 +178,8 @@ static int pack (lua_State *L) {
for (; top >= 1; top--) /* assign elements */
lua_rawseti(L, LUA_ENVIRONINDEX, top);
lua_pushvalue(L, LUA_ENVIRONINDEX); /* return new table */
+ /* remove new table from environment to allow its later collection */
+ lua_copy(L, LUA_REGISTRYINDEX, LUA_ENVIRONINDEX);
return 1;
}
diff --git a/src/ltm.c b/src/ltm.c
index cf675652..3a9e73ca 100644
--- a/src/ltm.c
+++ b/src/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 2.10 2009/11/19 19:06:52 roberto Exp $
+** $Id: ltm.c,v 2.11 2010/01/13 16:18:25 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -19,10 +19,12 @@
#include "ltm.h"
+static const char udatatypename[] = "userdata";
-LUAI_DDEF const char *const luaT_typenames[] = {
- "nil", "boolean", "userdata", "number",
- "string", "table", "function", "userdata", "thread",
+LUAI_DDEF const char *const luaT_typenames_[] = {
+ "no value",
+ "nil", "boolean", udatatypename, "number",
+ "string", "table", "function", udatatypename, "thread",
"proto", "upval"
};
diff --git a/src/ltm.h b/src/ltm.h
index ba935d49..732aa12d 100644
--- a/src/ltm.h
+++ b/src/ltm.h
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.h,v 2.8 2009/11/19 19:06:52 roberto Exp $
+** $Id: ltm.h,v 2.9 2010/01/13 16:18:25 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -43,7 +43,9 @@ typedef enum {
#define fasttm(l,et,e) gfasttm(G(l), et, e)
-LUAI_DDEC const char *const luaT_typenames[];
+#define typename(x) luaT_typenames_[(x) + 1]
+
+LUAI_DDEC const char *const luaT_typenames_[];
LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
diff --git a/src/lua.h b/src/lua.h
index b86ac6cf..f79df970 100644
--- a/src/lua.h
+++ b/src/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.260 2010/01/06 15:08:00 roberto Exp $
+** $Id: lua.h,v 1.261 2010/01/11 17:15:11 roberto Exp $
** Lua - A Scripting Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
@@ -17,9 +17,9 @@
#define LUA_VERSION "Lua 5.2"
-#define LUA_RELEASE "Lua 5.2.0 (work1)"
+#define LUA_RELEASE "Lua 5.2.0 (work2)"
#define LUA_VERSION_NUM 502
-#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2008 Lua.org, PUC-Rio"
+#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2010 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
@@ -395,7 +395,7 @@ struct lua_Debug {
/******************************************************************************
-* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
+* Copyright (C) 1994-2010 Lua.org, PUC-Rio. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
diff --git a/src/luaconf.h b/src/luaconf.h
index 9cd0beb2..b16e9991 100644
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -1,5 +1,5 @@
/*
-** $Id: luaconf.h,v 1.127 2010/01/06 15:15:04 roberto Exp $
+** $Id: luaconf.h,v 1.130 2010/01/11 17:15:30 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -34,7 +34,6 @@
#endif
#if defined(LUA_WIN)
-#include <windows.h>
#define LUA_DL_DLL
#endif
@@ -92,8 +91,8 @@
#else
#define LUA_ROOT "/usr/local/"
-#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
+#define LUA_LDIR LUA_ROOT "share/lua/5.2/"
+#define LUA_CDIR LUA_ROOT "lib/lua/5.2/"
#define LUA_PATH_DEFAULT \
LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua"
@@ -440,8 +439,9 @@ LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
/* On a Microsoft compiler, use assembler */
#if defined(_MSC_VER)
-#define lua_number2int(i,d) __asm fld d __asm fistp i
+#define lua_number2int(i,d) {__asm fld d __asm fistp i}
#define lua_number2integer(i,n) lua_number2int(i, n)
+#define lua_number2uint(i,n) lua_number2int(i, n)
#else
/* the next trick should work on any Pentium, but sometimes clashes