summaryrefslogtreecommitdiffstats
path: root/Mac/Python/macglue.c
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1995-02-24 22:53:16 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1995-02-24 22:53:16 (GMT)
commit76efd8e7a193d5e17f0f607ec5a2756636f9a9a5 (patch)
treefbd1495cc56a17715fbf6e8d175bcc7503c6330c /Mac/Python/macglue.c
parent397c3fb4d7b0e3bca7471e2f3e166b59d769880f (diff)
downloadcpython-76efd8e7a193d5e17f0f607ec5a2756636f9a9a5.zip
cpython-76efd8e7a193d5e17f0f607ec5a2756636f9a9a5.tar.gz
cpython-76efd8e7a193d5e17f0f607ec5a2756636f9a9a5.tar.bz2
MAde a few things more orthogonal and did some cleanups:
- Applications now have their (minimal) main prrogram in macapplication.c and the rest of the init code in macglue.c. - A new define, USE_MAC_APPLET_SUPPORT, independent of USE_MAC_SHARED_LIB - chdir to script directory now done in PyMac_InitApplication.
Diffstat (limited to 'Mac/Python/macglue.c')
-rw-r--r--Mac/Python/macglue.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c
index cab94ce..7135f33 100644
--- a/Mac/Python/macglue.c
+++ b/Mac/Python/macglue.c
@@ -117,7 +117,6 @@ static int in_foreground;
int PyMac_DoYieldEnabled = 1; /* Don't do eventloop when false */
-
/* Convert C to Pascal string. Returns pointer to static buffer. */
unsigned char *
Pstring(char *str)
@@ -787,26 +786,7 @@ PyMac_BuildEventRecord(EventRecord *e)
}
-#ifndef USE_MAC_SHARED_LIBRARY
-
-/* For normal application */
-void
-main()
-{
- int argc;
- char **argv;
-
-#ifdef __MWERKS__
- SIOUXSettings.asktosaveonclose = 0;
- SIOUXSettings.showstatusline = 0;
- SIOUXSettings.tabspaces = 4;
-#endif
- argc = PyMac_GetArgv(&argv);
- Py_Main(argc, argv);
-}
-
-#else /* USE_MAC_SHARED_LIBRARY */
-
+#ifdef USE_MAC_APPLET_SUPPORT
/* Applet support */
/* Run a compiled Python Python script from 'PYC ' resource __main__ */
@@ -850,9 +830,7 @@ PyMac_InitApplet()
char **argv;
int err;
-#ifdef USE_MAC_SHARED_LIBRARY
PyMac_AddLibResources();
-#endif
#ifdef __MWERKS__
SIOUXSettings.asktosaveonclose = 0;
SIOUXSettings.showstatusline = 0;
@@ -873,4 +851,34 @@ PyMac_InitApplet()
/* XXX Should we bother to Py_Exit(sts)? */
}
-#endif /* USE_MAC_SHARED_LIBRARY */
+#endif /* USE_MAC_APPLET_SUPPORT */
+
+/* For normal application */
+void
+PyMac_InitApplication()
+{
+ int argc;
+ char **argv;
+
+#ifdef USE_MAC_SHARED_LIBRARY
+ PyMac_AddLibResources();
+#endif
+#ifdef __MWERKS__
+ SIOUXSettings.asktosaveonclose = 0;
+ SIOUXSettings.showstatusline = 0;
+ SIOUXSettings.tabspaces = 4;
+#endif
+ argc = PyMac_GetArgv(&argv);
+ if ( argc > 1 ) {
+ /* We're running a script. Attempt to change current directory */
+ char curwd[256], *endp;
+
+ strcpy(curwd, argv[1]);
+ endp = strrchr(curwd, ':');
+ if ( endp && endp > curwd ) {
+ *endp = '\0';
+ chdir(curwd);
+ }
+ }
+ Py_Main(argc, argv);
+}