Kaydet (Commit) b697173b authored tarafından Jack Jansen's avatar Jack Jansen

- Added Guido's fixes

- Removed CW4 ifdefs
- Rationalized ifdefs for dup, fdopen
üst 8eca2c2c
...@@ -44,6 +44,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -44,6 +44,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#endif #endif
#ifdef USE_GUSI #ifdef USE_GUSI
#include <GUSI.h>
#include <sys/types.h> #include <sys/types.h>
#include <stat.h> #include <stat.h>
#define macstat stat #define macstat stat
...@@ -52,15 +53,21 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -52,15 +53,21 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#endif #endif
#ifdef __MWERKS__ #ifdef __MWERKS__
/* For CodeWarrior 4 also define CW4 */
#include <unix.h> #include <unix.h>
#else #else
#include <fcntl.h> #include <fcntl.h>
#endif #endif
/* Optional routines, for some compiler/runtime combinations */
#if defined(__MWERKS__) && defined(__powerc) #if defined(__MWERKS__) && defined(__powerc)
#define MALLOC_DEBUG #define MALLOC_DEBUG
#endif #endif
#if defined(USE_GUSI) || !defined(__MWERKS__)
#define WEHAVE_FDOPEN
#endif
#if defined(MPW) || defined(USE_GUSI)
#define WEHAVE_DUP
#endif
#include "macdefs.h" #include "macdefs.h"
#ifdef USE_GUSI #ifdef USE_GUSI
...@@ -75,27 +82,26 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -75,27 +82,26 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Prototypes for Unix simulation on Mac */ /* Prototypes for Unix simulation on Mac */
#ifndef USE_GUSI
int chdir PROTO((const char *path)); int chdir PROTO((const char *path));
char *getbootvol PROTO((void));
char *getwd PROTO((char *));
#ifdef USE_GUSI
int mkdir PROTO((const char *path));
DIR * opendir PROTO((const char *));
int closedir PROTO((DIR *));
#else
int mkdir PROTO((const char *path, int mode)); int mkdir PROTO((const char *path, int mode));
DIR * opendir PROTO((char *)); DIR * opendir PROTO((char *));
void closedir PROTO((DIR *)); void closedir PROTO((DIR *));
#endif
struct dirent * readdir PROTO((DIR *)); struct dirent * readdir PROTO((DIR *));
int rmdir PROTO((const char *path)); int rmdir PROTO((const char *path));
int sync PROTO((void)); int sync PROTO((void));
#if defined(THINK_C) || defined(__SC__) || defined(USE_GUSI)
#if defined(THINK_C) || defined(__SC__)
int unlink PROTO((char *)); int unlink PROTO((char *));
#else #else
int unlink PROTO((const char *)); int unlink PROTO((const char *));
#endif #endif
#endif /* USE_GUSI */
char *getwd PROTO((char *));
char *getbootvol PROTO((void));
static object *MacError; /* Exception mac.error */ static object *MacError; /* Exception mac.error */
...@@ -173,7 +179,6 @@ mac_chdir(self, args) ...@@ -173,7 +179,6 @@ mac_chdir(self, args)
return mac_1str(args, chdir); return mac_1str(args, chdir);
} }
#ifndef CW4
static object * static object *
mac_close(self, args) mac_close(self, args)
object *self; object *self;
...@@ -185,14 +190,16 @@ mac_close(self, args) ...@@ -185,14 +190,16 @@ mac_close(self, args)
BGN_SAVE BGN_SAVE
res = close(fd); res = close(fd);
END_SAVE END_SAVE
#ifndef USE_GUSI
/* GUSI gives surious errors here? */
if (res < 0) if (res < 0)
return mac_error(); return mac_error();
#endif
INCREF(None); INCREF(None);
return None; return None;
} }
#endif /* !__MWERKS__ */
#ifdef MPW #ifdef WEHAVE_DUP
static object * static object *
mac_dup(self, args) mac_dup(self, args)
...@@ -210,9 +217,9 @@ mac_dup(self, args) ...@@ -210,9 +217,9 @@ mac_dup(self, args)
return newintobject((long)fd); return newintobject((long)fd);
} }
#endif /* MPW */ #endif
#ifndef __MWERKS__ #ifdef WEHAVE_FDOPEN
static object * static object *
mac_fdopen(self, args) mac_fdopen(self, args)
object *self; object *self;
...@@ -259,7 +266,11 @@ mac_getcwd(self, args) ...@@ -259,7 +266,11 @@ mac_getcwd(self, args)
if (!getnoarg(args)) if (!getnoarg(args))
return NULL; return NULL;
BGN_SAVE BGN_SAVE
#ifdef USE_GUSI
res = getcwd(path, sizeof path);
#else
res = getwd(path); res = getwd(path);
#endif
END_SAVE END_SAVE
if (res == NULL) { if (res == NULL) {
err_setstr(MacError, path); err_setstr(MacError, path);
...@@ -310,7 +321,6 @@ mac_listdir(self, args) ...@@ -310,7 +321,6 @@ mac_listdir(self, args)
return d; return d;
} }
#ifndef CW4
static object * static object *
mac_lseek(self, args) mac_lseek(self, args)
object *self; object *self;
...@@ -329,31 +339,15 @@ mac_lseek(self, args) ...@@ -329,31 +339,15 @@ mac_lseek(self, args)
return mac_error(); return mac_error();
return newintobject(res); return newintobject(res);
} }
#endif /* !CW4 */
#ifdef USE_GUSI
/* GUSI mkdir doesn't accept the (dummy) mode. Grrr. */
int _gusi_mkdir(name, mode)
char *name;
int mode;
{
return mkdir(name);
}
#endif /* USE_GUSI */
static object * static object *
mac_mkdir(self, args) mac_mkdir(self, args)
object *self; object *self;
object *args; object *args;
{ {
#ifdef USE_GUSI
return mac_strint(args, _gusi_mkdir);
#else
return mac_strint(args, mkdir); return mac_strint(args, mkdir);
#endif
} }
#ifndef CW4
static object * static object *
mac_open(self, args) mac_open(self, args)
object *self; object *self;
...@@ -394,7 +388,6 @@ mac_read(self, args) ...@@ -394,7 +388,6 @@ mac_read(self, args)
resizestring(&buffer, size); resizestring(&buffer, size);
return buffer; return buffer;
} }
#endif /* !__MWERKS */
static object * static object *
mac_rename(self, args) mac_rename(self, args)
...@@ -510,7 +503,6 @@ mac_unlink(self, args) ...@@ -510,7 +503,6 @@ mac_unlink(self, args)
return mac_1str(args, (int (*)(const char *))unlink); return mac_1str(args, (int (*)(const char *))unlink);
} }
#ifndef CW4
static object * static object *
mac_write(self, args) mac_write(self, args)
object *self; object *self;
...@@ -527,7 +519,6 @@ mac_write(self, args) ...@@ -527,7 +519,6 @@ mac_write(self, args)
return mac_error(); return mac_error();
return newintobject((long)size); return newintobject((long)size);
} }
#endif /* !__MWERKS__ */
#ifdef MALLOC_DEBUG #ifdef MALLOC_DEBUG
static object * static object *
...@@ -543,35 +534,27 @@ mac_mstats(self, args) ...@@ -543,35 +534,27 @@ mac_mstats(self, args)
static struct methodlist mac_methods[] = { static struct methodlist mac_methods[] = {
{"chdir", mac_chdir}, {"chdir", mac_chdir},
#ifndef CW4
{"close", mac_close}, {"close", mac_close},
#endif #ifdef WEHAVE_DUP
#ifdef MPW
{"dup", mac_dup}, {"dup", mac_dup},
#endif #endif
#ifndef __MWERKS__ #ifdef WEHAVE_FDOPEN
{"fdopen", mac_fdopen}, {"fdopen", mac_fdopen},
#endif #endif
{"getbootvol", mac_getbootvol}, /* non-standard */ {"getbootvol", mac_getbootvol}, /* non-standard */
{"getcwd", mac_getcwd}, {"getcwd", mac_getcwd},
{"listdir", mac_listdir, 0}, {"listdir", mac_listdir, 0},
#ifndef CW4
{"lseek", mac_lseek}, {"lseek", mac_lseek},
#endif
{"mkdir", mac_mkdir}, {"mkdir", mac_mkdir},
#ifndef CW4
{"open", mac_open}, {"open", mac_open},
{"read", mac_read}, {"read", mac_read},
#endif
{"rename", mac_rename}, {"rename", mac_rename},
{"rmdir", mac_rmdir}, {"rmdir", mac_rmdir},
{"stat", mac_stat}, {"stat", mac_stat},
{"xstat", mac_xstat}, {"xstat", mac_xstat},
{"sync", mac_sync}, {"sync", mac_sync},
{"unlink", mac_unlink}, {"unlink", mac_unlink},
#ifndef CW4
{"write", mac_write}, {"write", mac_write},
#endif
#ifdef MALLOC_DEBUG #ifdef MALLOC_DEBUG
{"mstats", mac_mstats}, {"mstats", mac_mstats},
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment