diff options
-rw-r--r-- | Mac/Compat/macstat.c | 57 | ||||
-rw-r--r-- | Mac/Compat/macstat.h | 25 | ||||
-rw-r--r-- | Mac/Modules/macmodule.c | 8 | ||||
-rw-r--r-- | Mac/Python/macmain.c | 3 | ||||
-rw-r--r-- | Mac/README | 46 | ||||
-rw-r--r-- | Mac/Relnotes-1.2 | 46 |
6 files changed, 132 insertions, 53 deletions
diff --git a/Mac/Compat/macstat.c b/Mac/Compat/macstat.c new file mode 100644 index 0000000..e645050 --- /dev/null +++ b/Mac/Compat/macstat.c @@ -0,0 +1,57 @@ +/* Minimal 'stat' emulation: tells directories from files and + gives length and mtime. + Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). +*/ + +#include "stat.h" +#include "macdefs.h" + +/* Bits in ioFlAttrib: */ +#define LOCKBIT (1<<0) /* File locked */ +#define DIRBIT (1<<4) /* It's a directory */ + +int +stat(path, buf) + char *path; + struct stat *buf; +{ + union { + DirInfo d; + FileParam f; + HFileInfo hf; + } pb; + char name[256]; + short err; + + pb.d.ioNamePtr= (unsigned char *)c2pstr(strcpy(name, path)); + pb.d.ioVRefNum= 0; + pb.d.ioFDirIndex= 0; + pb.d.ioDrDirID= 0; + pb.f.ioFVersNum= 0; /* Fix found by Timo! See Tech Note 102 */ + if (hfsrunning()) + err= PBGetCatInfo((CInfoPBPtr)&pb, FALSE); + else + err= PBGetFInfo((ParmBlkPtr)&pb, FALSE); + if (err != noErr) { + errno = ENOENT; + return -1; + } + if (pb.d.ioFlAttrib & LOCKBIT) + buf->st_mode= 0444; + else + buf->st_mode= 0666; + if (pb.d.ioFlAttrib & DIRBIT) { + buf->st_mode |= 0111 | S_IFDIR; + buf->st_size= pb.d.ioDrNmFls; + buf->st_rsize= 0; + } + else { + buf->st_mode |= S_IFREG; + if (pb.f.ioFlFndrInfo.fdType == 'APPL') + buf->st_mode |= 0111; + buf->st_size= pb.f.ioFlLgLen; + buf->st_rsize= pb.f.ioFlRLgLen; + } + buf->st_mtime= pb.f.ioFlMdDat - TIMEDIFF; + return 0; +} diff --git a/Mac/Compat/macstat.h b/Mac/Compat/macstat.h new file mode 100644 index 0000000..c14116a --- /dev/null +++ b/Mac/Compat/macstat.h @@ -0,0 +1,25 @@ +/* Include file belonging to stat emulator. + Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). */ + +struct stat { + unsigned short st_mode; + unsigned long st_size; + unsigned long st_rsize; /* Resource size -- nonstandard */ + unsigned long st_mtime; +}; + +#ifdef UNIX_COMPAT +#define S_IFMT 0170000L +#define S_IFDIR 0040000L +#define S_IFREG 0100000L +#define S_IREAD 0400 +#define S_IWRITE 0200 +#define S_IEXEC 0100 +#else +#define S_IFMT 0xFFFF +#define S_IFDIR 0x0000 +#define S_IFREG 0x0003 +#define S_IREAD 0400 +#define S_IWRITE 0200 +#define S_IEXEC 0100 +#endif diff --git a/Mac/Modules/macmodule.c b/Mac/Modules/macmodule.c index 13d208c..ff06acd 100644 --- a/Mac/Modules/macmodule.c +++ b/Mac/Modules/macmodule.c @@ -170,6 +170,8 @@ mac_dup(self, args) return newintobject((long)fd); } +#endif /* MPW */ + static object * mac_fdopen(self, args) object *self; @@ -189,8 +191,6 @@ mac_fdopen(self, args) return newopenfileobject(fp, "(fdopen)", mode, fclose); } -#endif /* MPW */ - static object * mac_getbootvol(self, args) object *self; @@ -369,7 +369,7 @@ mac_stat(self, args) return mac_error(); return mkvalue("(llllllllll)", (long)st.st_mode, - (long)st.st_ito, /* XXX st_ino -- typo in THINK C <stat.h>? */ + (long)st.st_ino, (long)st.st_dev, (long)st.st_nlink, (long)st.st_uid, @@ -427,8 +427,8 @@ static struct methodlist mac_methods[] = { {"close", mac_close}, #ifdef MPW {"dup", mac_dup}, - {"fdopen", mac_fdopen}, #endif + {"fdopen", mac_fdopen}, {"getbootvol", mac_getbootvol}, /* non-standard */ {"getcwd", mac_getcwd}, {"listdir", mac_listdir}, diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c index 3885d88..1ea02ad 100644 --- a/Mac/Python/macmain.c +++ b/Mac/Python/macmain.c @@ -28,9 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "config.h" #endif -/* Comment this out if you're not interested in STDWIN */ -#define USE_STDWIN - #ifdef THINK_C #define CONSOLE_IO #endif @@ -5,10 +5,8 @@ Python can be built on the Mac using either THINK C 6.0 or MPW 3.2. In the past it has been compiled with earlier versions of these compilers, but no guarantees are made that the source is still compatible with those versions. Likewise, new compiler versions may -effectively change the language accepted (or the library!) and thus -cause problems. - -[[MPW version and procedure must still be checked]] +effectively change the language accepted (or the library provided!) +and thus cause problems. 1. Using Think C 6.0 @@ -102,21 +100,14 @@ arbitrarily because of the 32000 bytes restriction. macmodule.c in the Mac subdirectory, so it should already have been added in a previous step.) Note that for most modules, the source file is called <name>module.c, but for a few long - module names it is just <module>.c. + module names it is just <module>.c. Don't add stdwinmodule.c + yet, The following THINK C libraries must be added: from Standard Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each library in a separate segment. Also see my earlier remark on 4-byte ints. -1.3 Living without STDWIN -------------------------- - -Although STDWIN is really neat on the Mac, it's easier to begin -building Python without it, so you can concentrate on the Python -build. To this end, you have to comment out the lines defining the -symbol USE_STDWIN in macmain.c and config.c. - 1.4 Adding STDWIN ----------------- @@ -127,9 +118,10 @@ the same general source setup (in a sister directory of the toplevel Python directory). Put all sources in the same segment. To stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c. -The two projects can now be added as libraries to the Python project, -and the two lines commented out to live without STDWIN should be -reinstated. +The two projects can now be added as libraries to the Python project. +You must also add stdwinmodule.c and add "#define USE_STDWIN" to the +Prefix in the compiler options dialog (this only affects macmain.c and +config.c). Note that stdwinmodule.c contains an #include statement that references "stdwin.h" by relative path name -- if the stdwin toplevel @@ -147,13 +139,21 @@ copies resources into the application file from a file <projectname>.rsrc. -2. Using MPW -============ - -See the subdirectory MPW. I haven't tried this recently. You're -supposed to merge the directory tree found here with the UNIX source -tree. I think this is intended for use with MPW 3.2. The dynload -stuff in not recommended. +2. Using MPW 3.2 +================ + +The subdirectory MPW contains a README.MPW file, a buildall script and +several Makefiles (in respective subdirectories), kindly contributed +by Richard Walker of Island Software. Move these files to the +corresponding locations relative to the Python root directory, and run +the buildall script. The README.MPW file contains more instructions +and caveats (I've added some remarks of my own at the end). I haven't +tried building STDWIN with MPW recently (there is MPW specific code +all over the STDWIN source but it is for a much older version of the +compiler and library). The MPW and THINK C ports share all source +files, including config.c and config.h -- all differentiation is done +based on #ifdef THINK_C or #ifdef MPW (#ifdef macintosh is used for +code that should be seen by all Mac compilers). --Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl> diff --git a/Mac/Relnotes-1.2 b/Mac/Relnotes-1.2 index 578ac2b..0550a7c 100644 --- a/Mac/Relnotes-1.2 +++ b/Mac/Relnotes-1.2 @@ -5,10 +5,8 @@ Python can be built on the Mac using either THINK C 6.0 or MPW 3.2. In the past it has been compiled with earlier versions of these compilers, but no guarantees are made that the source is still compatible with those versions. Likewise, new compiler versions may -effectively change the language accepted (or the library!) and thus -cause problems. - -[[MPW version and procedure must still be checked]] +effectively change the language accepted (or the library provided!) +and thus cause problems. 1. Using Think C 6.0 @@ -102,21 +100,14 @@ arbitrarily because of the 32000 bytes restriction. macmodule.c in the Mac subdirectory, so it should already have been added in a previous step.) Note that for most modules, the source file is called <name>module.c, but for a few long - module names it is just <module>.c. + module names it is just <module>.c. Don't add stdwinmodule.c + yet, The following THINK C libraries must be added: from Standard Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each library in a separate segment. Also see my earlier remark on 4-byte ints. -1.3 Living without STDWIN -------------------------- - -Although STDWIN is really neat on the Mac, it's easier to begin -building Python without it, so you can concentrate on the Python -build. To this end, you have to comment out the lines defining the -symbol USE_STDWIN in macmain.c and config.c. - 1.4 Adding STDWIN ----------------- @@ -127,9 +118,10 @@ the same general source setup (in a sister directory of the toplevel Python directory). Put all sources in the same segment. To stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c. -The two projects can now be added as libraries to the Python project, -and the two lines commented out to live without STDWIN should be -reinstated. +The two projects can now be added as libraries to the Python project. +You must also add stdwinmodule.c and add "#define USE_STDWIN" to the +Prefix in the compiler options dialog (this only affects macmain.c and +config.c). Note that stdwinmodule.c contains an #include statement that references "stdwin.h" by relative path name -- if the stdwin toplevel @@ -147,13 +139,21 @@ copies resources into the application file from a file <projectname>.rsrc. -2. Using MPW -============ - -See the subdirectory MPW. I haven't tried this recently. You're -supposed to merge the directory tree found here with the UNIX source -tree. I think this is intended for use with MPW 3.2. The dynload -stuff in not recommended. +2. Using MPW 3.2 +================ + +The subdirectory MPW contains a README.MPW file, a buildall script and +several Makefiles (in respective subdirectories), kindly contributed +by Richard Walker of Island Software. Move these files to the +corresponding locations relative to the Python root directory, and run +the buildall script. The README.MPW file contains more instructions +and caveats (I've added some remarks of my own at the end). I haven't +tried building STDWIN with MPW recently (there is MPW specific code +all over the STDWIN source but it is for a much older version of the +compiler and library). The MPW and THINK C ports share all source +files, including config.c and config.h -- all differentiation is done +based on #ifdef THINK_C or #ifdef MPW (#ifdef macintosh is used for +code that should be seen by all Mac compilers). --Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl> |