]> granicus.if.org Git - python/commitdiff
MacPython on MacOSX DP4 gets started in the wrong directory. The workaround (ifdeffed...
authorJack Jansen <jack.jansen@cwi.nl>
Tue, 18 Jul 2000 09:40:39 +0000 (09:40 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Tue, 18 Jul 2000 09:40:39 +0000 (09:40 +0000)
Mac/Python/macmain.c
Mac/mwerks/mwerks_carbon_config.h

index d40a70ef6fda18d3dc94a59842666eb2ca150bbb..20dd4cb0cea7e2559370b0f20c12d4ffd1de508b 100644 (file)
@@ -256,7 +256,22 @@ init_common(int *argcp, char ***argvp, int embedded)
        } else {
                /* Create argc/argv. Do it before we go into the options event loop. */
                *argcp = PyMac_GetArgv(argvp, options.noargs);
-               
+#ifdef USE_ARGV0_CHDIR
+               printf("argc=%d, argv[0]=%x=%s\n", *argcp, (*argvp)[0], (*argvp)[0]);
+               if (*argcp >= 1 && (*argvp)[0] && (*argvp)[0][0]) {
+                       /* Workaround for MacOS X, which currently (DP4) doesn't set
+                       ** the working folder correctly
+                       */
+                       char app_wd[256], *p;
+                       
+                       strncpy(app_wd, (*argvp)[0], 256);
+                       printf("Modifying dir, argv[0]=%s\n", (*argvp)[0]);
+                       p = strrchr(app_wd, ':');
+                       if ( p ) *p = 0;
+                       printf("app_wd=%s\n", app_wd);
+                       chdir(app_wd);
+               }
+#endif
                /* Do interactive option setting, if allowed and <option> depressed */
                PyMac_InteractiveOptions(&options, argcp, argvp);
        }
index e96de720886a77f1b9fdb9fbb8f177709db316ff..b39467e302b241d4a7655ccc3df4a6dde15c230e 100644 (file)
@@ -9,6 +9,7 @@
 #define TARGET_API_MAC_CARBON 1
 #define TARGET_API_MAC_CARBON_NOTYET 1 /* Things we should do eventually, but not now */
 
+#define USE_ARGV0_CHDIR                /* Workaround for OSXDP4: change dir to argv[0] dir */
 /* #define USE_GUSI2           /* Stdio implemented with GUSI 2 */
 /* # define USE_GUSI1  /* Stdio implemented with GUSI 1 */
 #define USE_MSL                        /* Use Mw Standard Library (as opposed to Plaugher C libraries) */