summaryrefslogtreecommitdiff
path: root/drumgizmo/drumgizmoc.cc
diff options
context:
space:
mode:
authorDimitri Karamazov <deserter666@danwin1210.me>2020-11-22 20:03:04 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2020-11-22 20:03:04 +0100
commit5cc2e000c7e9424edfd7643db495e17bc148ecc7 (patch)
treece5a550ea6e262b3eac6ba788e8752e789883a32 /drumgizmo/drumgizmoc.cc
parent23138bf682d5f3ab2baff99874af0924250981dd (diff)
Fall back to using glob when wordexp is not available.v0.9.19
Diffstat (limited to 'drumgizmo/drumgizmoc.cc')
-rw-r--r--drumgizmo/drumgizmoc.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc
index 4853641..159c533 100644
--- a/drumgizmo/drumgizmoc.cc
+++ b/drumgizmo/drumgizmoc.cc
@@ -34,7 +34,11 @@
#include <sstream>
#include <chrono>
#include <thread>
+#ifdef HAVE_WORDEXP
#include <wordexp.h>
+#else
+#include <glob.h>
+#endif
#include <hugin.hpp>
@@ -146,19 +150,31 @@ std::vector<ParmToken> parseParameters(std::string &parms)
std::string parm;
std::string val;
bool inval = false;
+#ifdef HAVE_WORDEXP
wordexp_t exp_result;
+#else
+ glob_t g;
+#endif
for(size_t i = 0; i < parms.size(); ++i)
{
if(parms[i] == ',')
{
+ #ifdef HAVE_WORDEXP
int error = wordexp(val.data(), &exp_result, 0);
+ #else
+ int error = glob(val.data(), 0, NULL, &g);
+ #endif
if(error)
{
std::cerr << "Wrong argument: ";
std::cerr << parm << " = " << val << std::endl;
exit(1);
}
+ #ifdef HAVE_WORDEXP
result.push_back({parm, exp_result.we_wordv[0]});
+ #else
+ result.push_back({parm, g.gl_pathv[0]});
+ #endif
parm = "";
val = "";
inval = false;
@@ -182,14 +198,22 @@ std::vector<ParmToken> parseParameters(std::string &parms)
}
if(parm != "")
{
+ #ifdef HAVE_WORDEXP
int error = wordexp(val.data(), &exp_result, 0);
+ #else
+ int error = glob(val.data(), 0, NULL, &g);
+ #endif
if(error)
{
std::cerr << "Wrong argument: ";
std::cerr << parm << " = " << val << std::endl;
exit(1);
}
+ #ifdef HAVE_WORDEXP
result.push_back({parm, exp_result.we_wordv[0]});
+ #else
+ result.push_back({parm, g.gl_pathv[0]});
+ #endif
}
return result;
}