summaryrefslogtreecommitdiffstats
path: root/Mac/Modules
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1994-12-14 13:45:11 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1994-12-14 13:45:11 (GMT)
commitc5b26f4a05f6cfcc3fbf474d70af57d42f7a1439 (patch)
treef0c3ca85ea710c271b9b6baf46efd6b4296a9f50 /Mac/Modules
parentfea75336aac7de44abad089f91023c938b2559d6 (diff)
downloadcpython-c5b26f4a05f6cfcc3fbf474d70af57d42f7a1439.zip
cpython-c5b26f4a05f6cfcc3fbf474d70af57d42f7a1439.tar.gz
cpython-c5b26f4a05f6cfcc3fbf474d70af57d42f7a1439.tar.bz2
- PYTHONPATH is now \n-separated, so you can have directories with
spaces in the name. - If you run python with a script the working directory is now the directory where the script lives (was: directory where python application lives). sys.path will include current dir, application dir and Lib, etc. relative to application dir. This is more like unix python does things and more useful besides (since you can easily import files living in the same directory as the importer). - Added the macconsole, ctb, macspeech, macdnr and mactcp modules. - For MW compiler, put 68K/PPC indication in version string.
Diffstat (limited to 'Mac/Modules')
-rw-r--r--Mac/Modules/config.c77
1 files changed, 75 insertions, 2 deletions
diff --git a/Mac/Modules/config.c b/Mac/Modules/config.c
index b1c6e2c..3823f33 100644
--- a/Mac/Modules/config.c
+++ b/Mac/Modules/config.c
@@ -91,6 +91,13 @@ getversion()
{
static char version[80];
sprintf(version, VERSION, PATCHLEVEL, DATE);
+#ifdef __MWERKS__
+#ifdef __powerc
+ strcat(version, " [MW PPC compiler]");
+#else
+ strcat(version, " [MW 68K compiler]");
+#endif
+#endif
return version;
}
@@ -113,7 +120,8 @@ getcopyright()
#ifndef PYTHONPATH
#ifdef macintosh
-#define PYTHONPATH ": :Lib :Lib:stdwin :Lib:test :Lib:mac"
+/* Mod by Jack: \n is now separator. */
+#define PYTHONPATH ":\n:Lib\n:Lib:stdwin\n:Lib:test\n:Lib:mac"
#endif /* macintosh */
#endif /* !PYTHONPATH */
@@ -133,7 +141,58 @@ char *
getpythonpath()
{
#ifdef macintosh
- return PYTHONPATH;
+ /* Modified by Jack to do something a bit more sensible:
+ ** - Prepend the current directory (which is presumably where python lives)
+ ** - Add :
+ ** - Chdir to where the source file (if any) lives
+ */
+ static char *pythonpath;
+ extern char *fileargument;
+ char curwd[256];
+ char *p, *endp;
+ int newlen;
+
+ if ( pythonpath ) return pythonpath;
+ if (getwd(curwd) < 0 ) {
+ return PYTHONPATH;
+ }
+ p = PYTHONPATH;
+ endp = p;
+ pythonpath = malloc(2);
+ if ( pythonpath == NULL ) return PYTHONPATH;
+ strcpy(pythonpath, ":");
+ while (*endp) {
+ endp = strchr(p, '\n');
+ if ( endp == NULL )
+ endp = p + strlen(p);
+ newlen = strlen(pythonpath) + 1 + strlen(curwd) + (endp-p);
+ pythonpath = realloc(pythonpath, newlen+1);
+ if ( pythonpath == NULL ) return PYTHONPATH;
+ strcat(pythonpath, "\n");
+ if ( *p == ':' ) {
+ p++;
+ strcat(pythonpath, curwd);
+ strncat(pythonpath, p, (endp-p));
+ newlen--; /* Ok, ok, we've allocated one byte too much */
+ } else {
+ /* We've allocated too much in this case */
+ newlen -= strlen(curwd);
+ pythonpath = realloc(pythonpath, newlen+1);
+ if ( pythonpath == NULL ) return PYTHONPATH;
+ strncat(pythonpath, p, (endp-p));
+ }
+ pythonpath[newlen] = '\0';
+ p = endp + 1;
+ }
+ if ( fileargument ) {
+ strcpy(curwd, fileargument);
+ endp = strrchr(curwd, ':');
+ if ( endp && endp > curwd ) {
+ *endp = '\0';
+ chdir(curwd);
+ }
+ }
+ return pythonpath;
#else /* !macintosh */
char *path = getenv("PYTHONPATH");
char *defpath = PYTHONPATH;
@@ -202,6 +261,13 @@ extern void initnew();
extern void initdl();
extern void initsyslog();
extern void initgestalt();
+#ifdef THINK
+extern void initmacconsole();
+#endif
+extern void initctb();
+extern void initmacspeech();
+extern void initmacdnr();
+extern void initmactcp();
/* -- ADDMODULE MARKER 1 -- */
@@ -231,7 +297,14 @@ struct {
{"rotor", initrotor},
{"new", initnew},
{"gestalt", initgestalt},
+#ifdef THINK
+ {"macconsole", initmacconsole},
+#endif
+ {"ctb", initctb},
+ {"macspeech", initmacspeech},
{"imgformat", initimgformat},
+ {"macdnr", initmacdnr},
+ {"mactcp", initmactcp},
/* -- ADDMODULE MARKER 2 -- */