$NetBSD: patch-am,v 1.3 2013/10/27 21:21:26 dholland Exp $

- dragonfly doesn't have wordexp.h
- use glob.h instead of wordexp.h when not using wordexp.h

--- src/celutil/unixdirectory.cpp.orig	2011-06-05 16:11:15.000000000 +0000
+++ src/celutil/unixdirectory.cpp
@@ -11,20 +11,30 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <dirent.h>
-#include <wordexp.h>
-#include "directory.h"
-
-using namespace std;
 
+#if defined(__DragonFly__)
+#define NO_WORDEXP
+#endif
 
 #ifdef TARGET_OS_MAC
 #ifdef QT_CORE_LIB
 // Crash on Mac OS X / Qt4 version when calling wordfree.
 // This seems to happen only with Leopard.
-#define WORDEXP_PROBLEM
+#define NO_WORDEXP
+#endif
 #endif
+
+#ifdef NO_WORDEXP
+#include <glob.h>
+#else
+#include <wordexp.h>
 #endif
 
+#include "directory.h"
+
+using namespace std;
+
+
 class UnixDirectory : public Directory
 {
 public:
@@ -107,7 +117,7 @@ bool IsDirectory(const std::string& file
 
 std::string WordExp(const std::string& filename) 
 {
-#ifndef WORDEXP_PROBLEM   
+#ifndef NO_WORDEXP
     wordexp_t result;
     std::string expanded;
 
@@ -130,7 +140,17 @@ std::string WordExp(const std::string& f
     expanded = result.we_wordv[0];
     wordfree(&result);
 #else
-    std::string expanded = filename;
+    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;
+    }
 #endif
     return expanded;
 }
