Selaa lähdekoodia

Modify official LuaSQLite3, to register sqlite3 as a global table
Keep compatibility to the previous version
Apply the same fix as before (#139):
https://github.com/civetweb/civetweb/commit/358f43c0d26dec612a5d0a7e49140a6c01189d21

bel2125 7 vuotta sitten
vanhempi
commit
62362643ed
1 muutettua tiedostoa jossa 8 lisäystä ja 2 poistoa
  1. 8 2
      src/third_party/lsqlite3.c

+ 8 - 2
src/third_party/lsqlite3.c

@@ -2373,6 +2373,12 @@ static void create_meta(lua_State *L, const char *name, const luaL_Reg *lib) {
     lua_pop(L, 1);
 }
 
+static int luaopen_sqlitelib (lua_State *L) {
+    luaL_newlibtable(L, sqlitelib);
+    luaL_setfuncs(L, sqlitelib, 0);
+    return 1;
+}
+
 LUALIB_API int luaopen_lsqlite3(lua_State *L) {
     create_meta(L, sqlite_meta, dblib);
     create_meta(L, sqlite_vm_meta, vmlib);
@@ -2382,8 +2388,8 @@ LUALIB_API int luaopen_lsqlite3(lua_State *L) {
     luaL_getmetatable(L, sqlite_ctx_meta);
     sqlite_ctx_meta_ref = luaL_ref(L, LUA_REGISTRYINDEX);
 
-    /* register (local) sqlite metatable */
-    luaL_register(L, "sqlite3", sqlitelib);
+    /* register global sqlite3 library */
+    luaL_requiref(L, "sqlite3", luaopen_sqlitelib, 1);
 
     {
         int i = 0;