patch-src_celutil_unixdirectory_cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. $OpenBSD: patch-src_celutil_unixdirectory_cpp,v 1.3 2012/08/19 22:30:37 ajacoutot Exp $
  2. --- src/celutil/unixdirectory.cpp.orig Mon Jun 22 17:44:24 2009
  3. +++ src/celutil/unixdirectory.cpp Mon Jul 20 11:55:18 2009
  4. @@ -7,11 +7,19 @@
  5. // as published by the Free Software Foundation; either version 2
  6. // of the License, or (at your option) any later version.
  7. +#if defined(__OpenBSD__)
  8. +#define NO_WORDEXP
  9. +#endif
  10. +
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #include <unistd.h>
  14. #include <dirent.h>
  15. +#ifdef NO_WORDEXP
  16. +#include <glob.h>
  17. +#else
  18. #include <wordexp.h>
  19. +#endif
  20. #include "directory.h"
  21. using namespace std;
  22. @@ -107,6 +115,19 @@ bool IsDirectory(const std::string& filename)
  23. std::string WordExp(const std::string& filename)
  24. {
  25. +#ifdef NO_WORDEXP
  26. + glob_t g;
  27. + std::string expanded;
  28. + glob(filename.c_str(), GLOB_NOSORT | GLOB_TILDE, NULL, &g);
  29. + if (g.gl_matchc != 1) {
  30. + globfree(&g);
  31. + return filename;
  32. + } else {
  33. + expanded = g.gl_pathv[0];
  34. + globfree(&g);
  35. + return expanded;
  36. + }
  37. +#else
  38. #ifndef WORDEXP_PROBLEM
  39. wordexp_t result;
  40. std::string expanded;
  41. @@ -133,4 +154,5 @@ std::string WordExp(const std::string& filename)
  42. std::string expanded = filename;
  43. #endif
  44. return expanded;
  45. +#endif
  46. }