summaryrefslogtreecommitdiff
path: root/luaext/userconfig.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-04-16 15:13:25 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-04-16 15:37:52 +0300
commitd48e6c8380ebd1f8d4d4f2c80237dc1488da4721 (patch)
tree004158090fc80b15a620f2c960b0e029cad25835 /luaext/userconfig.c
parent23f6917b10b6579f39199e4cf831bb13fc596824 (diff)
downloadlibrpm-tizen-d48e6c8380ebd1f8d4d4f2c80237dc1488da4721.tar.gz
librpm-tizen-d48e6c8380ebd1f8d4d4f2c80237dc1488da4721.tar.bz2
librpm-tizen-d48e6c8380ebd1f8d4d4f2c80237dc1488da4721.zip
Start phasing out internal copy of Lua
- don't build internal copy of Lua - move 3rd party extensions (posix and rexlib) to toplevel luaext/ directory, built by default (unless --without-lua specified) - auto*foo checks for external Lua - minimal tweaks to lposix.c and rpmlua.c to get them build with Lua 5.1
Diffstat (limited to 'luaext/userconfig.c')
-rw-r--r--luaext/userconfig.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/luaext/userconfig.c b/luaext/userconfig.c
new file mode 100644
index 000000000..014e32536
--- /dev/null
+++ b/luaext/userconfig.c
@@ -0,0 +1,57 @@
+
+#include "config.h"
+
+#include "lposix.h"
+#include "lrexlib.h"
+
+#define LUA_EXTRALIBS \
+ {"posix", luaopen_posix}, \
+ {"rex", luaopen_rex}, \
+ {"luapath", luapath},
+
+#if 0
+
+#define lua_readline myreadline
+#define lua_saveline mysaveline
+
+#include <ctype.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+
+static int myreadline (lua_State *L, const char *prompt) {
+ char *s=readline(prompt);
+ if (s==NULL)
+ return 0;
+ else {
+ lua_pushstring(L,s);
+ lua_pushliteral(L,"\n");
+ lua_concat(L,2);
+ free(s);
+ return 1;
+ }
+}
+
+static void mysaveline (lua_State *L, const char *s) {
+ const char *p;
+ for (p=s; isspace(*p); p++);
+ if (*p!=0) {
+ size_t n=strlen(s)-1;
+ if (s[n]!='\n')
+ add_history(s);
+ else {
+ lua_pushlstring(L,s,n);
+ s=lua_tostring(L,-1);
+ add_history(s);
+ lua_remove(L,-1);
+ }
+ }
+}
+#endif
+
+static int luapath(lua_State *L)
+{
+ lua_pushstring(L, "LUA_PATH");
+ lua_pushstring(L, RPMCONFIGDIR "/lua/?.lua;?.lua");
+ lua_rawset(L, LUA_GLOBALSINDEX);
+ return 0;
+}