Procházet zdrojové kódy

Fixed Mac OS X wordexp problem

Thomas Buck před 10 roky
rodič
revize
3da9d32798
1 změnil soubory, kde provedl 12 přidání a 2 odebrání
  1. 12
    2
      src/utils/strings.cpp

+ 12
- 2
src/utils/strings.cpp Zobrazit soubor

@@ -70,8 +70,18 @@ char *fullPath(const char *path, char end) {
70 70
 
71 71
     if (path[0] == '~') {
72 72
 #if defined(unix) || defined(__APPLE__)
73
+#ifdef __APPLE__
74
+        // Workaround for Mac OS X. See:
75
+        // http://stackoverflow.com/questions/20534788/why-does-wordexp-fail-with-wrde-syntax-on-os-x
76
+        signal(SIGCHLD, SIG_DFL);
77
+#endif
73 78
         // Expand string into segments
74
-        if (wordexp(path, &word, 0) != 0) {
79
+        int res = wordexp(path, &word, 0);
80
+#ifdef __APPLE__
81
+        signal(SIGCHLD, SIG_IGN);
82
+#endif
83
+        if (res != 0) {
84
+            printf("fullPath> wordexp() failed: %d\n", res);
75 85
             return NULL;
76 86
         }
77 87
 
@@ -106,7 +116,7 @@ char *fullPath(const char *path, char end) {
106 116
     }
107 117
 
108 118
     // Make sure ends in "end" char
109
-    if (end && (dir[lenPath - 1] != end)) {
119
+    if ((lenPath > 0) && (end != 0) && (dir[lenPath - 1] != end)) {
110 120
         dir[lenPath] = end;
111 121
         dir[lenPath + 1] = 0;
112 122
     } else {

Loading…
Zrušit
Uložit