summaryrefslogtreecommitdiff
path: root/misc/celestia/patches/patch-am
blob: f5894408d49c070ca2dda1ca7bb56c62726cd727 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
$NetBSD: patch-am,v 1.2 2012/07/03 17:40:36 joerg Exp $

--- src/celutil/unixdirectory.cpp.orig	2005-03-05 13:56:14.000000000 +0000
+++ src/celutil/unixdirectory.cpp
@@ -7,11 +7,19 @@
 // as published by the Free Software Foundation; either version 2
 // of the License, or (at your option) any later version.
 
+#if defined(__DragonFly__)
+#define NO_WORDEXP
+#endif
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <dirent.h>
+#ifdef NO_WORDEXP
+#include <glob.h>
+#else
 #include <wordexp.h>
+#endif
 #include "directory.h"
 
 using namespace std;
@@ -98,6 +106,19 @@ bool IsDirectory(const std::string& file
 }
 
 std::string WordExp(const std::string& filename) {
+#ifdef NO_WORDEXP
+    glob_t g;
+    std::string expanded;
+    glob(filename.c_str(), GLOB_NOSORT | GLOB_TILDE, NULL, &g);
+    if (g.gl_matchc != 1) {
+	globfree(&g);
+	return filename;
+    } else {
+	expanded = g.gl_pathv[0];
+	globfree(&g);
+	return expanded;
+    }
+#else
     wordexp_t result;
     std::string expanded;
 
@@ -121,4 +142,5 @@ std::string WordExp(const std::string& f
     wordfree(&result);
 
     return expanded;
+#endif
 }