vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 6fcd54e2f0a80f576b57afdbdc727b2df317ee2c
parent 1413ae284f0bf5a551b4f2551178fc215f91c580
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 18 Nov 2016 21:35:52 -0800

Allow building lpeg into vis

If lpeg is built statically, this allows for a completely static vis
binary that still supports syntax highlighting.

Diffstat:
MMakefile | 2++
Mvis-lua.c | 9+++++++++
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -16,6 +16,7 @@ MANPREFIX ?= ${PREFIX}/man VERSION = $(shell git describe --always 2>/dev/null || echo "0.2") CONFIG_LUA ?= 1 +CONFIG_BUILTIN_LPEG ?= 0 CONFIG_ACL ?= 0 CONFIG_SELINUX ?= 0 @@ -28,6 +29,7 @@ CFLAGS_VIS = $(CFLAGS_AUTO) $(CFLAGS_TERMKEY) $(CFLAGS_CURSES) $(CFLAGS_ACL) \ CFLAGS_VIS += -DVIS_PATH=\"${SHAREPREFIX}/vis\" CFLAGS_VIS += -DCONFIG_LUA=${CONFIG_LUA} +CFLAGS_VIS += -DCONFIG_BUILTIN_LPEG=${CONFIG_BUILTIN_LPEG} CFLAGS_VIS += -DCONFIG_SELINUX=${CONFIG_SELINUX} CFLAGS_VIS += -DCONFIG_ACL=${CONFIG_ACL} CFLAGS_VIS += ${CFLAGS_DEBUG} diff --git a/vis-lua.c b/vis-lua.c @@ -1889,6 +1889,15 @@ void vis_lua_init(Vis *vis) { vis->lua = L; luaL_openlibs(L); +#if CONFIG_BUILTIN_LPEG + extern int luaopen_lpeg(lua_State *L); + lua_getglobal(L, "package"); + lua_getfield(L, -1, "preload"); + lua_pushcfunction(L, luaopen_lpeg); + lua_setfield(L, -2, "lpeg"); + lua_pop(L, 2); +#endif + /* remove any relative paths from lua's default package.path */ vis_lua_path_strip(vis);