Permalink
Browse files

update the native executable to work correctly on mac os x

git-svn-id: http://svn.codehaus.org/groovy/trunk/groovy/groovy-core@2220 a5544e8c-8a19-0410-ba12-f9af4593a198
  • Loading branch information...
1 parent a6bdbff commit d35026714e5fb40a9b3e5862be27727573225264 @spullara spullara committed May 24, 2005
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/native/base.c
View
@@ -12,28 +12,35 @@
#ifdef UNIX
#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
#endif
#ifdef LINUX
#include <unistd.h>
#include <linux/limits.h>
+#include <malloc.h>
#endif
#ifdef MACOSX
#include <mach-o/dyld.h>
-#include <sys/syslimits.h>
+#include <sys/param.h>
#endif
int main(int argc, char* argv[]) {
// Get the location of the executable -- platform specific
#ifdef UNIX
- char jarexe[PATH_MAX];
+ char *jarexe = malloc((MAXPATHLEN+2)*sizeof(char));
#endif
#ifdef MACOSX
- unsigned long length;
- _NSGetExecutablePath(jarexe, &length);
+ uint32_t length = MAXPATHLEN + 2;
+ while (_NSGetExecutablePath((char*)jarexe, &length) == -1) {
+ free(jarexe);
+ jarexe = malloc((length)*sizeof(char));
+ }
#endif
#ifdef LINUX
@@ -65,6 +72,7 @@ int main(int argc, char* argv[]) {
// Execute java
#ifdef UNIX
+ free(jarexe);
execvp("java", argv2);
#endif

0 comments on commit d350267

Please sign in to comment.