Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e783444

Browse files
committed
Intermediate version of changes after porting to MPW 3.2
1 parent f0171a1 commit e783444

6 files changed

Lines changed: 132 additions & 53 deletions

File tree

Mac/Compat/macstat.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* Minimal 'stat' emulation: tells directories from files and
2+
gives length and mtime.
3+
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987).
4+
*/
5+
6+
#include "stat.h"
7+
#include "macdefs.h"
8+
9+
/* Bits in ioFlAttrib: */
10+
#define LOCKBIT (1<<0) /* File locked */
11+
#define DIRBIT (1<<4) /* It's a directory */
12+
13+
int
14+
stat(path, buf)
15+
char *path;
16+
struct stat *buf;
17+
{
18+
union {
19+
DirInfo d;
20+
FileParam f;
21+
HFileInfo hf;
22+
} pb;
23+
char name[256];
24+
short err;
25+
26+
pb.d.ioNamePtr= (unsigned char *)c2pstr(strcpy(name, path));
27+
pb.d.ioVRefNum= 0;
28+
pb.d.ioFDirIndex= 0;
29+
pb.d.ioDrDirID= 0;
30+
pb.f.ioFVersNum= 0; /* Fix found by Timo! See Tech Note 102 */
31+
if (hfsrunning())
32+
err= PBGetCatInfo((CInfoPBPtr)&pb, FALSE);
33+
else
34+
err= PBGetFInfo((ParmBlkPtr)&pb, FALSE);
35+
if (err != noErr) {
36+
errno = ENOENT;
37+
return -1;
38+
}
39+
if (pb.d.ioFlAttrib & LOCKBIT)
40+
buf->st_mode= 0444;
41+
else
42+
buf->st_mode= 0666;
43+
if (pb.d.ioFlAttrib & DIRBIT) {
44+
buf->st_mode |= 0111 | S_IFDIR;
45+
buf->st_size= pb.d.ioDrNmFls;
46+
buf->st_rsize= 0;
47+
}
48+
else {
49+
buf->st_mode |= S_IFREG;
50+
if (pb.f.ioFlFndrInfo.fdType == 'APPL')
51+
buf->st_mode |= 0111;
52+
buf->st_size= pb.f.ioFlLgLen;
53+
buf->st_rsize= pb.f.ioFlRLgLen;
54+
}
55+
buf->st_mtime= pb.f.ioFlMdDat - TIMEDIFF;
56+
return 0;
57+
}

Mac/Compat/macstat.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* Include file belonging to stat emulator.
2+
Public domain by Guido van Rossum, CWI, Amsterdam (July 1987). */
3+
4+
struct stat {
5+
unsigned short st_mode;
6+
unsigned long st_size;
7+
unsigned long st_rsize; /* Resource size -- nonstandard */
8+
unsigned long st_mtime;
9+
};
10+
11+
#ifdef UNIX_COMPAT
12+
#define S_IFMT 0170000L
13+
#define S_IFDIR 0040000L
14+
#define S_IFREG 0100000L
15+
#define S_IREAD 0400
16+
#define S_IWRITE 0200
17+
#define S_IEXEC 0100
18+
#else
19+
#define S_IFMT 0xFFFF
20+
#define S_IFDIR 0x0000
21+
#define S_IFREG 0x0003
22+
#define S_IREAD 0400
23+
#define S_IWRITE 0200
24+
#define S_IEXEC 0100
25+
#endif

Mac/Modules/macmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ mac_dup(self, args)
170170
return newintobject((long)fd);
171171
}
172172

173+
#endif /* MPW */
174+
173175
static object *
174176
mac_fdopen(self, args)
175177
object *self;
@@ -189,8 +191,6 @@ mac_fdopen(self, args)
189191
return newopenfileobject(fp, "(fdopen)", mode, fclose);
190192
}
191193

192-
#endif /* MPW */
193-
194194
static object *
195195
mac_getbootvol(self, args)
196196
object *self;
@@ -369,7 +369,7 @@ mac_stat(self, args)
369369
return mac_error();
370370
return mkvalue("(llllllllll)",
371371
(long)st.st_mode,
372-
(long)st.st_ito, /* XXX st_ino -- typo in THINK C <stat.h>? */
372+
(long)st.st_ino,
373373
(long)st.st_dev,
374374
(long)st.st_nlink,
375375
(long)st.st_uid,
@@ -427,8 +427,8 @@ static struct methodlist mac_methods[] = {
427427
{"close", mac_close},
428428
#ifdef MPW
429429
{"dup", mac_dup},
430-
{"fdopen", mac_fdopen},
431430
#endif
431+
{"fdopen", mac_fdopen},
432432
{"getbootvol", mac_getbootvol}, /* non-standard */
433433
{"getcwd", mac_getcwd},
434434
{"listdir", mac_listdir},

Mac/Python/macmain.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2828
#include "config.h"
2929
#endif
3030

31-
/* Comment this out if you're not interested in STDWIN */
32-
#define USE_STDWIN
33-
3431
#ifdef THINK_C
3532
#define CONSOLE_IO
3633
#endif

Mac/README

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ Python can be built on the Mac using either THINK C 6.0 or MPW 3.2.
55
In the past it has been compiled with earlier versions of these
66
compilers, but no guarantees are made that the source is still
77
compatible with those versions. Likewise, new compiler versions may
8-
effectively change the language accepted (or the library!) and thus
9-
cause problems.
10-
11-
[[MPW version and procedure must still be checked]]
8+
effectively change the language accepted (or the library provided!)
9+
and thus cause problems.
1210

1311

1412
1. Using Think C 6.0
@@ -102,21 +100,14 @@ arbitrarily because of the 32000 bytes restriction.
102100
macmodule.c in the Mac subdirectory, so it should already have
103101
been added in a previous step.) Note that for most modules,
104102
the source file is called <name>module.c, but for a few long
105-
module names it is just <module>.c.
103+
module names it is just <module>.c. Don't add stdwinmodule.c
104+
yet,
106105

107106
The following THINK C libraries must be added: from Standard
108107
Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each
109108
library in a separate segment. Also see my earlier remark on 4-byte
110109
ints.
111110

112-
1.3 Living without STDWIN
113-
-------------------------
114-
115-
Although STDWIN is really neat on the Mac, it's easier to begin
116-
building Python without it, so you can concentrate on the Python
117-
build. To this end, you have to comment out the lines defining the
118-
symbol USE_STDWIN in macmain.c and config.c.
119-
120111
1.4 Adding STDWIN
121112
-----------------
122113

@@ -127,9 +118,10 @@ the same general source setup (in a sister directory of the toplevel
127118
Python directory). Put all sources in the same segment. To
128119
stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c.
129120

130-
The two projects can now be added as libraries to the Python project,
131-
and the two lines commented out to live without STDWIN should be
132-
reinstated.
121+
The two projects can now be added as libraries to the Python project.
122+
You must also add stdwinmodule.c and add "#define USE_STDWIN" to the
123+
Prefix in the compiler options dialog (this only affects macmain.c and
124+
config.c).
133125

134126
Note that stdwinmodule.c contains an #include statement that
135127
references "stdwin.h" by relative path name -- if the stdwin toplevel
@@ -147,13 +139,21 @@ copies resources into the application file from a file
147139
<projectname>.rsrc.
148140

149141

150-
2. Using MPW
151-
============
152-
153-
See the subdirectory MPW. I haven't tried this recently. You're
154-
supposed to merge the directory tree found here with the UNIX source
155-
tree. I think this is intended for use with MPW 3.2. The dynload
156-
stuff in not recommended.
142+
2. Using MPW 3.2
143+
================
144+
145+
The subdirectory MPW contains a README.MPW file, a buildall script and
146+
several Makefiles (in respective subdirectories), kindly contributed
147+
by Richard Walker of Island Software. Move these files to the
148+
corresponding locations relative to the Python root directory, and run
149+
the buildall script. The README.MPW file contains more instructions
150+
and caveats (I've added some remarks of my own at the end). I haven't
151+
tried building STDWIN with MPW recently (there is MPW specific code
152+
all over the STDWIN source but it is for a much older version of the
153+
compiler and library). The MPW and THINK C ports share all source
154+
files, including config.c and config.h -- all differentiation is done
155+
based on #ifdef THINK_C or #ifdef MPW (#ifdef macintosh is used for
156+
code that should be seen by all Mac compilers).
157157

158158

159159
--Guido van Rossum, CWI, Amsterdam <[email protected]>

Mac/Relnotes-1.2

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ Python can be built on the Mac using either THINK C 6.0 or MPW 3.2.
55
In the past it has been compiled with earlier versions of these
66
compilers, but no guarantees are made that the source is still
77
compatible with those versions. Likewise, new compiler versions may
8-
effectively change the language accepted (or the library!) and thus
9-
cause problems.
10-
11-
[[MPW version and procedure must still be checked]]
8+
effectively change the language accepted (or the library provided!)
9+
and thus cause problems.
1210

1311

1412
1. Using Think C 6.0
@@ -102,21 +100,14 @@ arbitrarily because of the 32000 bytes restriction.
102100
macmodule.c in the Mac subdirectory, so it should already have
103101
been added in a previous step.) Note that for most modules,
104102
the source file is called <name>module.c, but for a few long
105-
module names it is just <module>.c.
103+
module names it is just <module>.c. Don't add stdwinmodule.c
104+
yet,
106105

107106
The following THINK C libraries must be added: from Standard
108107
Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each
109108
library in a separate segment. Also see my earlier remark on 4-byte
110109
ints.
111110

112-
1.3 Living without STDWIN
113-
-------------------------
114-
115-
Although STDWIN is really neat on the Mac, it's easier to begin
116-
building Python without it, so you can concentrate on the Python
117-
build. To this end, you have to comment out the lines defining the
118-
symbol USE_STDWIN in macmain.c and config.c.
119-
120111
1.4 Adding STDWIN
121112
-----------------
122113

@@ -127,9 +118,10 @@ the same general source setup (in a sister directory of the toplevel
127118
Python directory). Put all sources in the same segment. To
128119
stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c.
129120

130-
The two projects can now be added as libraries to the Python project,
131-
and the two lines commented out to live without STDWIN should be
132-
reinstated.
121+
The two projects can now be added as libraries to the Python project.
122+
You must also add stdwinmodule.c and add "#define USE_STDWIN" to the
123+
Prefix in the compiler options dialog (this only affects macmain.c and
124+
config.c).
133125

134126
Note that stdwinmodule.c contains an #include statement that
135127
references "stdwin.h" by relative path name -- if the stdwin toplevel
@@ -147,13 +139,21 @@ copies resources into the application file from a file
147139
<projectname>.rsrc.
148140

149141

150-
2. Using MPW
151-
============
152-
153-
See the subdirectory MPW. I haven't tried this recently. You're
154-
supposed to merge the directory tree found here with the UNIX source
155-
tree. I think this is intended for use with MPW 3.2. The dynload
156-
stuff in not recommended.
142+
2. Using MPW 3.2
143+
================
144+
145+
The subdirectory MPW contains a README.MPW file, a buildall script and
146+
several Makefiles (in respective subdirectories), kindly contributed
147+
by Richard Walker of Island Software. Move these files to the
148+
corresponding locations relative to the Python root directory, and run
149+
the buildall script. The README.MPW file contains more instructions
150+
and caveats (I've added some remarks of my own at the end). I haven't
151+
tried building STDWIN with MPW recently (there is MPW specific code
152+
all over the STDWIN source but it is for a much older version of the
153+
compiler and library). The MPW and THINK C ports share all source
154+
files, including config.c and config.h -- all differentiation is done
155+
based on #ifdef THINK_C or #ifdef MPW (#ifdef macintosh is used for
156+
code that should be seen by all Mac compilers).
157157

158158

159159
--Guido van Rossum, CWI, Amsterdam <[email protected]>

0 commit comments

Comments
 (0)