Revision: 10711 http://pure-data.svn.sourceforge.net/pure-data/?rev=10711&view=rev Author: eighthave Date: 2009-02-02 03:27:22 +0000 (Mon, 02 Feb 2009)
Log Message: ----------- rebuilt procedure for finding the Wish.app on Mac OS X and made it use a Pd* glob for the embedded Wish so that the executable can have the exact same name as the app, as the Wish.app structure prefers
Modified Paths: -------------- branches/pd-devel/0.41.4/src/s_inter.c
Modified: branches/pd-devel/0.41.4/src/s_inter.c =================================================================== --- branches/pd-devel/0.41.4/src/s_inter.c 2009-02-02 00:49:58 UTC (rev 10710) +++ branches/pd-devel/0.41.4/src/s_inter.c 2009-02-02 03:27:22 UTC (rev 10711) @@ -47,6 +47,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <pthread.h> +#include <glob.h> #else #include <stdlib.h> #endif @@ -1023,59 +1024,44 @@ if (!sys_guicmd) { #ifdef __APPLE__ - char *homedir = getenv("HOME"), filename[250]; + int i; struct stat statbuf; - /* first look for Wish bundled with and renamed "Pd" */ - sprintf(filename, "%s/../../MacOS/Pd", guidir); - if (stat(filename, &statbuf) >= 0) - goto foundit; - if (!homedir || strlen(homedir) > 150) - goto nohomedir; - /* Look for Wish in user's Applications. Might or might - not be names "Wish Shell", and might or might not be - in "Utilities" subdir. */ - sprintf(filename, - "%s/Applications/Utilities/Wish shell.app/Contents/MacOS/Wish Shell", - homedir); - if (stat(filename, &statbuf) >= 0) - goto foundit; - sprintf(filename, - "%s/Applications/Utilities/Wish.app/Contents/MacOS/Wish", - homedir); - if (stat(filename, &statbuf) >= 0) - goto foundit; - sprintf(filename, - "%s/Applications/Wish shell.app/Contents/MacOS/Wish Shell", - homedir); - if (stat(filename, &statbuf) >= 0) - goto foundit; - sprintf(filename, - "%s/Applications/Wish.app/Contents/MacOS/Wish", - homedir); - if (stat(filename, &statbuf) >= 0) - goto foundit; - nohomedir: - /* Perform the same search among system applications. */ - strcpy(filename, - "/usr/bin/wish"); - if (stat(filename, &statbuf) >= 0) - goto foundit; - strcpy(filename, - "/Applications/Utilities/Wish Shell.app/Contents/MacOS/Wish Shell"); - if (stat(filename, &statbuf) >= 0) - goto foundit; - strcpy(filename, - "/Applications/Utilities/Wish.app/Contents/MacOS/Wish"); - if (stat(filename, &statbuf) >= 0) - goto foundit; - strcpy(filename, - "/Applications/Wish Shell.app/Contents/MacOS/Wish Shell"); - if (stat(filename, &statbuf) >= 0) - goto foundit; - strcpy(filename, - "/Applications/Wish.app/Contents/MacOS/Wish"); - foundit: - sprintf(cmdbuf, ""%s" %s/pd.tk %d\n", filename, guidir, portno); + glob_t glob_buffer; + char *homedir = getenv("HOME"); + char embed_glob[FILENAME_MAX]; + char embed_filename[FILENAME_MAX], home_filename[FILENAME_MAX]; + char *wish_paths[10] = { + "(did not find an embedded wish)", + "(did not find a home directory)", + "/Applications/Utilities/Wish.app/Contents/MacOS/Wish", + "/Applications/Utilities/Wish Shell.app/Contents/MacOS/Wish Shell", + "/Applications/Wish.app/Contents/MacOS/Wish", + "/Applications/Wish Shell.app/Contents/MacOS/Wish Shell", + "/usr/local/bin/wish", + "/sw/bin/wish", + "/opt/bin/wish", + "/usr/bin/wish" + }; + /* this glob is needed so the Wish executable can have the same + * filename as the Pd.app, i.e. 'Pd-0.42-3.app' should have a Wish + * executable called 'Pd-0.42-3.app/Contents/MacOS/Pd-0.42-3' */ + sprintf(embed_glob, "%s/../../MacOS/Pd*", guidir); + glob_buffer.gl_matchc = 1; /* we only need one match */ + glob(embed_glob, GLOB_LIMIT, NULL, &glob_buffer); + if (glob_buffer.gl_pathc > 0) { + strcpy(embed_filename, glob_buffer.gl_pathv[0]); + wish_paths[0] = embed_filename; + } + sprintf(home_filename, + "%s/Applications/Wish.app/Contents/MacOS/Wish",homedir); + wish_paths[1] = home_filename; + for(i=0;i<10;i++) { + if (sys_verbose) + fprintf(stderr, "Trying Wish at "%s"\n", wish_paths[i]); + if (stat(wish_paths[i], &statbuf) >= 0) + break; + } + sprintf(cmdbuf,""%s" %s/pd.tk %d\n",wish_paths[i],guidir,portno); #else sprintf(cmdbuf, "TCL_LIBRARY="%s/tcl/library" TK_LIBRARY="%s/tk/library" \ @@ -1099,6 +1085,7 @@ { seteuid(getuid()); /* lose setuid priveliges */ #ifndef __APPLE__ +// TODO this seems unneeded on any platform hans@eds.org /* the wish process in Unix will make a wish shell and read/write standard in and out unless we close the file descriptors. Somehow this doesn't make the MAC OSX
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.