[sosi2osm] 18/30: Make location of lua library relative to executable location
Ruben Undheim
rubund-guest at moszumanska.debian.org
Sat Oct 4 13:07:56 UTC 2014
This is an automated email from the git hooks/post-receive script.
rubund-guest pushed a commit to branch upstream
in repository sosi2osm.
commit 601c247778e56136059bd696e698fe563f857c63
Author: Knut Karevoll <gnonthgol at gmail.com>
Date: Fri Oct 11 23:48:24 2013 +0200
Make location of lua library relative to executable location
---
sosi2osm.cpp | 3 +++
sosi2osm.h | 1 +
tag.cpp | 16 +++++++++++++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/sosi2osm.cpp b/sosi2osm.cpp
index bdc23be..0b563d1 100644
--- a/sosi2osm.cpp
+++ b/sosi2osm.cpp
@@ -3,6 +3,8 @@
#include "sosi2osm.h"
+char* execname;
+
void usage() {
printf("Usage: sosi2osm [sosi file] [lua file]\n");
}
@@ -62,6 +64,7 @@ int main(int argc, char** args) {
return 1;
}
+ execname = args[0];
char* input_filename = args[1];
loadLua(args[2]);
diff --git a/sosi2osm.h b/sosi2osm.h
index 2a09619..a23bbcf 100644
--- a/sosi2osm.h
+++ b/sosi2osm.h
@@ -17,6 +17,7 @@ long getSOSIRefsSize();
// Tag
+extern char* execname;
void setEncoding(char* encoding);
void loadLua(char* filename);
void outputTags();
diff --git a/tag.cpp b/tag.cpp
index 74af559..9f22308 100644
--- a/tag.cpp
+++ b/tag.cpp
@@ -2,6 +2,7 @@
#include <string.h>
#include <stdlib.h>
+#include <libgen.h>
#include <iconv.h>
#include <lua.h>
#include <lualib.h>
@@ -34,14 +35,23 @@ lua_State *state;
void loadLua(char* filename) {
state = luaL_newstate();
luaL_openlibs(state);
- int r = luaL_loadfile(state, filename);
+
+ char library_filename[256];
+ snprintf(library_filename, 256, "%s/lua/sosi2osm.lua", dirname(execname));
+
+ int r = luaL_loadfile(state, library_filename);
+ if (r) {
+ fprintf(stderr, "Failed to load lua library file %s\n", library_filename);
+ exit(1);
+ }
+ lua_call(state, 0, 0);
+
+ r = luaL_loadfile(state, filename);
if (r) {
fprintf(stderr, "Failed to load lua file %s\n", filename);
exit(1);
}
- luaL_loadfile(state, "lua/sosi2osm.lua");
- lua_call(state, 0, 0);
lua_setglobal(state, "getTagsFromInfoTable");
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/sosi2osm.git
More information about the Pkg-grass-devel
mailing list