Skip to content

Commit

Permalink
update the native executable to work correctly on mac os x
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.codehaus.org/groovy/trunk/groovy/groovy-core@2220 a5544e8c-8a19-0410-ba12-f9af4593a198
  • Loading branch information
spullara committed May 24, 2005
1 parent a6bdbff commit d350267
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/native/base.c
Expand Up @@ -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
Expand Down Expand Up @@ -65,6 +72,7 @@ int main(int argc, char* argv[]) {

// Execute java
#ifdef UNIX
free(jarexe);
execvp("java", argv2);
#endif

Expand Down

0 comments on commit d350267

Please sign in to comment.