#4 Workaround for "environ" on MacOS X

open
nobody
None
5
2008-06-28
2008-06-28
No

On MacOS X, the global variable ::environ is not available by default.

The attached patch implements a workaround.

diff -u -r qgit-1.5.8.org/src/myprocess.cpp qgit-1.5.8.my/src/myprocess.cpp
--- qgit-1.5.8.org/src/myprocess.cpp 2007-12-21 20:14:04.000000000 +0100
+++ qgit-1.5.8.my/src/myprocess.cpp 2008-06-28 16:20:47.000000000 +0200
@@ -14,6 +14,11 @@
#include "domain.h"
#include "myprocess.h"

+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#endif
+
MyProcess::MyProcess(QObject *go, Git* g, const QString& wd, bool err) : QProcess(g) {

guiObject = go;
@@ -120,7 +125,7 @@
/* global 'environ' is an array of pointers to the
* environment strings, defined in <unistd.h>
*/
- char** envval = ::environ;
+ char** envval = environ;
for ( ; *envval; envval++)
*env << QString(*envval);
}

Discussion

  • Patch file

     
    Attachments