Source

macports / aqua / emacs-app / files / patch-src_emacs.c.diff

--- src/emacs.c.orig	2011-01-09 02:45:14.000000000 +0900
+++ src/emacs.c	2011-09-09 23:13:44.000000000 +0900
@@ -23,6 +23,8 @@
 #include <signal.h>
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include <sys/types.h>
 #include <sys/file.h>
@@ -839,6 +841,25 @@
 #ifdef DARWIN_OS
   if (!initialized)
     unexec_init_emacs_zone ();
+
+  /* Imaxima won't work properly if PATH does not contain the
+     MacPorts directory. The following code is a workaround to
+     avoid this problem. */
+  {
+    char *oldpath = getenv("PATH");
+    if (!oldpath) {oldpath = "";}
+    size_t oldpathsize = strlen(oldpath) + 1;
+    if (!strstr(oldpath, "__PREFIX__/bin")) {
+      char *newpath;
+      size_t newpathsize = oldpathsize + strlen("__PREFIX__/bin:");
+      if ((newpath = (char *)malloc(newpathsize)) != NULL) {
+        strlcpy(newpath, "__PREFIX__/bin:", newpathsize);
+        strlcat(newpath, oldpath, newpathsize);
+        setenv("PATH", newpath, 1);
+        free(newpath);
+      }
+    }
+  }
 #endif
 
   sort_args (argc, argv);