mirror of
https://github.com/neovim/neovim.git
synced 2026-09-04 13:20:34 +00:00
Problem: LPeg is hosted on a single unreliable external hoster, forcing is to mirror it in neovim/deps, which adds maintenance friction. Also, we have already vendored the Lua `re.lua` module. Solution: Vendor all of LPeg v1.1.0; as development is not very active anymore, this should not add much overhead (and allow us to simplify in particular the Zig build scripts). Note: LPeg defines a `luaL_newlib` macro for Lua 5.1, which conflicts with LuaJIT's extension. This requires inlining the macro defined in `lptypes.h` and used in `lptree.c`; see README.md for the patch.
1.2 KiB
1.2 KiB
LPeg - Parsing Expression Grammars For Lua
For more information, see Lpeg.
Vendored @ v1.1.0 with patch to prevent conflict with LuaJIT extensions:
diff --git a/src/lpeg/lptree.c b/src/lpeg/lptree.c
index 475b0c36bf..94a3171d5a 100644
--- a/src/lpeg/lptree.c
+++ b/src/lpeg/lptree.c
@@ -1388,7 +1388,7 @@ int luaopen_lpeg (lua_State *L) {
lua_pushnumber(L, MAXBACK); /* initialize maximum backtracking */
lua_setfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX);
luaL_setfuncs(L, metareg, 0);
- luaL_newlib(L, pattreg);
+ luaL_register(L, "lpeg", pattreg); // Nvim: inline conflicting luaL_newlib macro
lua_pushvalue(L, -1);
lua_setfield(L, -3, "__index");
lua_pushliteral(L, "LPeg " VERSION);
diff --git a/src/lpeg/lptypes.h b/src/lpeg/lptypes.h
index 3f860b973f..98974e1b88 100644
--- a/src/lpeg/lptypes.h
+++ b/src/lpeg/lptypes.h
@@ -35,7 +35,7 @@
#define lua_rawlen lua_objlen
#define luaL_setfuncs(L,f,n) luaL_register(L,NULL,f)
-#define luaL_newlib(L,f) luaL_register(L,"lpeg",f)
+// #define luaL_newlib(L,f) luaL_register(L,"lpeg",f) // Nvim: conflicts with LuaJIT
typedef size_t lua_Unsigned;