Revision: 10712 http://pure-data.svn.sourceforge.net/pure-data/?rev=10712&view=rev Author: eighthave Date: 2009-02-02 03:42:03 +0000 (Mon, 02 Feb 2009)
Log Message: ----------- included Pd* and wish_path patch from pd-devel so that Tcl/Tk 8.5 will work
Modified Paths: -------------- branches/pd-extended/0.41/pd/src/s_inter.c
Modified: branches/pd-extended/0.41/pd/src/s_inter.c =================================================================== --- branches/pd-extended/0.41/pd/src/s_inter.c 2009-02-02 03:27:22 UTC (rev 10711) +++ branches/pd-extended/0.41/pd/src/s_inter.c 2009-02-02 03:42:03 UTC (rev 10712) @@ -58,6 +58,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <pthread.h> +#include <glob.h> #else #include <stdlib.h> #endif @@ -1034,59 +1035,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" \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.