summaryrefslogtreecommitdiff
path: root/lang/lua53/files/patch-src_lua.c
diff options
context:
space:
mode:
authorDavid Naylor <dbn@FreeBSD.org>2018-08-18 07:41:00 +0000
committerDavid Naylor <dbn@FreeBSD.org>2018-08-18 07:41:00 +0000
commit726b26ae8bedf0c7cb55678785bbb29c018f5323 (patch)
tree6e47f7d25d6f848bbaf94d7d9b3b893623252a3c /lang/lua53/files/patch-src_lua.c
parentscience/py-spglib: Update 1.10.3.65 -> 1.10.4.1 (diff)
lang/lua53: update to 5.3.5 (final release for 5.3)
- Cleanup of variables - Use the 'bsd' target for build stage - Add options to to select interactive command line editing - Add options to control debug options - Add option for HTML documentation - No change log provided upstream Submitted by: Russel Haley (russ.haley@gmail.com) Andrew Gierth (andrew_tao173.riddles.org.uk) Differential Revision: https://reviews.freebsd.org/D13690
Notes
Notes: svn path=/head/; revision=477483
Diffstat (limited to 'lang/lua53/files/patch-src_lua.c')
-rw-r--r--lang/lua53/files/patch-src_lua.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/lang/lua53/files/patch-src_lua.c b/lang/lua53/files/patch-src_lua.c
new file mode 100644
index 000000000000..8d9b33f9c30c
--- /dev/null
+++ b/lang/lua53/files/patch-src_lua.c
@@ -0,0 +1,78 @@
+--- src/lua.c.orig 2017-04-19 17:29:57 UTC
++++ src/lua.c
+@@ -77,16 +77,66 @@
+ */
+ #if !defined(lua_readline) /* { */
+
+-#if defined(LUA_USE_READLINE) /* { */
++#if defined(LUA_USE_READLINE_DL)/* { */
++
++#include <dlfcn.h>
++
++#ifndef LUA_READLINE_LIBPATH
++#define LUA_READLINE_LIBPATH "/usr/local/lib/libedit.so"
++#endif
++
++typedef char *readline_functype(const char *);
++typedef int add_history_functype(const char *);
++
++static readline_functype *lua_readline_p = NULL;
++static add_history_functype *lua_saveline_p = NULL;
++
++static void lua_initreadline(lua_State *L)
++{
++ void *editlib = NULL;
++ union dl_func_hack {
++ void *ptr;
++ readline_functype *rlfunc;
++ add_history_functype *ahfunc;
++ char **rlnamevar;
++ int *icompvar;
++ } u;
++ (void) L;
++ if ((editlib = dlopen(LUA_READLINE_LIBPATH, RTLD_LAZY | RTLD_LOCAL))) {
++ u.ptr = dlsym(editlib, "readline");
++ lua_readline_p = u.rlfunc;
++ u.ptr = dlsym(editlib, "add_history");
++ lua_saveline_p = u.ahfunc;
++ if ((u.ptr = dlsym(editlib, "rl_readline_name")))
++ *u.rlnamevar = "lua";
++ if ((u.ptr = dlsym(editlib, "rl_inhibit_completion")))
++ *u.icompvar = 1;
++ }
++}
++
++#define lua_readline(L,b,p) \
++ ((void)L, \
++ (lua_readline_p) \
++ ? (((b)=lua_readline_p(p)) != NULL) \
++ : (fputs(p, stdout), fflush(stdout), fgets(b, LUA_MAXINPUT, stdin) != NULL))
++#define lua_saveline(L,line) \
++ do { (void)L; if (lua_saveline_p) lua_saveline_p(line); } while(0)
++#define lua_freeline(L,b) \
++ do { (void)L; if (lua_readline_p) free(b); } while(0)
++
++#elif defined(LUA_USE_READLINE) /* { */
+
+ #include <readline/readline.h>
+ #include <readline/history.h>
++#define lua_initreadline(L) \
++ ((void)L, rl_readline_name="lua", rl_inhibit_completion=1)
+ #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
+ #define lua_saveline(L,line) ((void)L, add_history(line))
+ #define lua_freeline(L,b) ((void)L, free(b))
+
+ #else /* }{ */
+
++#define lua_initreadline(L) ((void) L)
+ #define lua_readline(L,b,p) \
+ ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
+ fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
+@@ -406,6 +456,7 @@ static void doREPL (lua_State *L) {
+ int status;
+ const char *oldprogname = progname;
+ progname = NULL; /* no 'progname' on errors in interactive mode */
++ lua_initreadline(L);
+ while ((status = loadline(L)) != -1) {
+ if (status == LUA_OK)
+ status = docall(L, 0, LUA_MULTRET);