Commit 0b0db8e3 authored by Guido van Rossum's avatar Guido van Rossum

Added separate main program for the Mac: macmain.c

stdwinmodule.c: wsetfont can now return an error
Makefile: add CL_USE and CL_LIB*S; config.c: move CL part around
New things in imgfile; also in Makefile.
longobject.c: fix comparison of negative long ints...  [REAL BUG!]
marshal.c: add dumps() and loads() to read/write strings
timemodule.c: make sure there's always a floatsleep()
posixmodule.c: rationalize struct returned by times()
Makefile: add test target, disable imgfile by default
thread.c: Improved coexistance with dl module (sjoerd)
stdwinmodule.c: Change include stdwin.h if macintosh
rotormodule.c: added missing last argument to RTR_?_region calls
confic.c: merged with configmac.c, added 1993 to copyright message
fileobject.c: int compared to NULL in writestring(); change fopenRF ifdef
timemodule.c: simplify times() using mkvalue; include myselect.h
  earlier (for sequent).
posixmodule: for sequent, include unistd.h instead of explicit
  extern definitions and don't define rename()
Makefile: change misleading/wrong MD5 comments
parent 80530ce8
...@@ -25,15 +25,30 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -25,15 +25,30 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Configurable Python configuration file */ /* Configurable Python configuration file */
/* These modules are normally always included, but *may* be taken out */ /* These modules are normally always included, but *may* be taken out */
#define USE_GRP 1 /* Use together with pwd */
#define USE_MARSHAL 1 /* This is linked anyway */ #define USE_MARSHAL 1 /* This is linked anyway */
#define USE_MATH 1 #define USE_MATH 1
#define USE_PWD 1 /* Use together with grp */ #define USE_STRUCT 1
#define USE_STROP 1
#define USE_TIME 1
#ifdef macintosh
#define USE_AUDIOOP 1
#define USE_IMAGEOP 1
#define USE_MAC 1
#define USE_REGEX 1
#define USE_ROTOR 1
#define USE_STDWIN 1 /* You may turn this off */
#endif
#ifdef unix
#define USE_GRP 1 /* Use together with pwd */
#define USE_POSIX 1 #define USE_POSIX 1
#define USE_PWD 1 /* Use together with grp */
#define USE_SELECT 1 #define USE_SELECT 1
#define USE_SOCKET 1 #define USE_SOCKET 1
#define USE_STRUCT 1 #endif
#define USE_TIME 1
#include <stdio.h>
#include "PROTO.h" #include "PROTO.h"
#include "mymalloc.h" #include "mymalloc.h"
...@@ -45,18 +60,20 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -45,18 +60,20 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef __DATE__ #ifdef __DATE__
#define DATE __DATE__ #define DATE __DATE__
#else #else
#define DATE ">= 8 Jan 1993" #define DATE ">= 11 Jan 1993"
#endif #endif
#include <stdio.h>
#ifdef USE_STDWIN #ifdef USE_STDWIN
#include <stdwin.h> #ifdef macintosh
#endif #include ":::src:stdwin:H:stdwin.h"
#else /* !macintosh */
#include "stdwin.h"
#endif /* !macintosh */
#endif /* USE_STDWIN */
char version[80]; char version[80];
char *argv0; char *argv0; /* For dynamic loading in import.c */
/*ARGSUSED*/ /*ARGSUSED*/
void void
...@@ -69,13 +86,16 @@ initargs(p_argc, p_argv) ...@@ -69,13 +86,16 @@ initargs(p_argc, p_argv)
argv0 = **p_argv; argv0 = **p_argv;
#ifdef USE_STDWIN #ifdef USE_STDWIN
wargs(p_argc, p_argv); #ifdef THINK_C_3_0
wsetstdio(1);
#endif #endif
wargs(p_argc, p_argv);
#endif /* USE_STDWIN */
if (*p_argc < 2 && isatty(0) && isatty(1)) if (*p_argc < 2 && isatty(0) && isatty(1))
{ {
printf("Python %s.\n", version); printf("Python %s.\n", version);
printf( printf(
"Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam\n"); "Copyright 1990, 1991, 1992, 1993 Stichting Mathematisch Centrum, Amsterdam\n");
} }
} }
...@@ -96,14 +116,22 @@ donecalls() ...@@ -96,14 +116,22 @@ donecalls()
} }
#ifndef PYTHONPATH #ifndef PYTHONPATH
#ifdef macintosh
/* On the Mac, the search path is a space-separated list of directories */
#define PYTHONPATH ": :lib :demo"
#else /* !macintosh */
#define PYTHONPATH ".:/usr/local/lib/python" #define PYTHONPATH ".:/usr/local/lib/python"
#endif #endif /* !macintosh */
#endif /* !PYTHONPATH */
extern char *getenv(); extern char *getenv();
char * char *
getpythonpath() getpythonpath()
{ {
#ifdef macintosh
return PYTHONPATH;
#else /* !macintosh */
char *path = getenv("PYTHONPATH"); char *path = getenv("PYTHONPATH");
char *defpath = PYTHONPATH; char *defpath = PYTHONPATH;
char *buf; char *buf;
...@@ -119,6 +147,7 @@ getpythonpath() ...@@ -119,6 +147,7 @@ getpythonpath()
strcat(buf, ":"); strcat(buf, ":");
strcat(buf, defpath); strcat(buf, defpath);
return buf; return buf;
#endif /* !macintosh */
} }
...@@ -142,6 +171,9 @@ extern void initaudioop(); ...@@ -142,6 +171,9 @@ extern void initaudioop();
#ifdef USE_CD #ifdef USE_CD
extern void initcd(); extern void initcd();
#endif #endif
#ifdef USE_CL
extern void initcl();
#endif
#ifdef USE_DBM #ifdef USE_DBM
extern void initdbm(); extern void initdbm();
#endif #endif
...@@ -166,6 +198,9 @@ extern void initimgfile(); ...@@ -166,6 +198,9 @@ extern void initimgfile();
#ifdef USE_JPEG #ifdef USE_JPEG
extern void initjpeg(); extern void initjpeg();
#endif #endif
#ifdef USE_MAC
extern void initmac();
#endif
#ifdef USE_MARSHAL #ifdef USE_MARSHAL
extern void initmarshal(); extern void initmarshal();
#endif #endif
...@@ -217,9 +252,6 @@ extern void initthread(); ...@@ -217,9 +252,6 @@ extern void initthread();
#ifdef USE_SV #ifdef USE_SV
extern void initsv(); extern void initsv();
#endif #endif
#ifdef USE_CL
extern void initcl();
#endif
#ifdef USE_TIME #ifdef USE_TIME
extern void inittime(); extern void inittime();
#endif #endif
...@@ -259,6 +291,10 @@ struct { ...@@ -259,6 +291,10 @@ struct {
{"cd", initcd}, {"cd", initcd},
#endif #endif
#ifdef USE_CL
{"cl", initcl},
#endif
#ifdef USE_DBM #ifdef USE_DBM
{"dbm", initdbm}, {"dbm", initdbm},
#endif #endif
...@@ -291,6 +327,10 @@ struct { ...@@ -291,6 +327,10 @@ struct {
{"jpeg", initjpeg}, {"jpeg", initjpeg},
#endif #endif
#ifdef USE_MAC
{"mac", initmac},
#endif
#ifdef USE_MARSHAL #ifdef USE_MARSHAL
{"marshal", initmarshal}, {"marshal", initmarshal},
#endif #endif
...@@ -355,10 +395,6 @@ struct { ...@@ -355,10 +395,6 @@ struct {
{"sv", initsv}, {"sv", initsv},
#endif #endif
#ifdef USE_CL
{"cl", initcl},
#endif
#ifdef USE_THREAD #ifdef USE_THREAD
{"thread", initthread}, {"thread", initthread},
#endif #endif
......
...@@ -75,6 +75,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -75,6 +75,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h" #include "modsupport.h"
#include "ceval.h" #include "ceval.h"
#ifdef _SEQUENT_
#include <unistd.h>
#else /* _SEQUENT_ */
/* XXX Aren't these always declared in unistd.h? */ /* XXX Aren't these always declared in unistd.h? */
extern char *strerror PROTO((int)); extern char *strerror PROTO((int));
extern int chmod PROTO((const char *, mode_t)); extern int chmod PROTO((const char *, mode_t));
...@@ -87,6 +90,7 @@ extern int rmdir PROTO((const char *)); ...@@ -87,6 +90,7 @@ extern int rmdir PROTO((const char *));
extern int stat PROTO((const char *, struct stat *)); extern int stat PROTO((const char *, struct stat *));
extern int unlink PROTO((const char *)); extern int unlink PROTO((const char *));
extern int pclose PROTO((FILE *)); extern int pclose PROTO((FILE *));
#endif /* _SEQUENT_ */
#ifdef NO_LSTAT #ifdef NO_LSTAT
#define lstat stat #define lstat stat
#else #else
...@@ -375,7 +379,7 @@ posix_nice(self, args) ...@@ -375,7 +379,7 @@ posix_nice(self, args)
} }
#endif #endif
#ifdef i386 #if i386 && ! _SEQUENT_
int int
rename(from, to) rename(from, to)
char *from; char *from;
...@@ -388,7 +392,7 @@ rename(from, to) ...@@ -388,7 +392,7 @@ rename(from, to)
return status; return status;
return unlink(from); return unlink(from);
} }
#endif /* i386 */ #endif /* i386 && ! _SEQUENT_ */
static object * static object *
posix_rename(self, args) posix_rename(self, args)
...@@ -833,7 +837,6 @@ posix_times(self, args) ...@@ -833,7 +837,6 @@ posix_times(self, args)
{ {
struct tms t; struct tms t;
clock_t c; clock_t c;
object *tuple;
if (!getnoarg(args)) if (!getnoarg(args))
return NULL; return NULL;
errno = 0; errno = 0;
...@@ -842,18 +845,11 @@ posix_times(self, args) ...@@ -842,18 +845,11 @@ posix_times(self, args)
err_errno(PosixError); err_errno(PosixError);
return NULL; return NULL;
} }
tuple = newtupleobject(4); return mkvalue("dddd",
if (tuple == NULL) (double)t.tms_utime / HZ,
return NULL; (double)t.tms_stime / HZ,
settupleitem(tuple, 0, newfloatobject((double)t.tms_utime / HZ)); (double)t.tms_cutime / HZ,
settupleitem(tuple, 1, newfloatobject((double)t.tms_stime / HZ)); (double)t.tms_cstime / HZ);
settupleitem(tuple, 2, newfloatobject((double)t.tms_cutime / HZ));
settupleitem(tuple, 3, newfloatobject((double)t.tms_cstime / HZ));
if (err_occurred()) {
DECREF(tuple);
return NULL;
}
return tuple;
} }
#endif /* DO_TIMES */ #endif /* DO_TIMES */
......
...@@ -590,7 +590,7 @@ static void encrypt_region(r, region, len) ...@@ -590,7 +590,7 @@ static void encrypt_region(r, region, len)
unsigned char *region; unsigned char *region;
int len; int len;
{ {
RTR_e_region(r,region,len); RTR_e_region(r,region,len,TRUE);
} }
/*(defun decrypt-region (beg end key) /*(defun decrypt-region (beg end key)
...@@ -602,7 +602,7 @@ static void decrypt_region(r, region, len) ...@@ -602,7 +602,7 @@ static void decrypt_region(r, region, len)
unsigned char *region; unsigned char *region;
int len; int len;
{ {
RTR_d_region(r,region,len); RTR_d_region(r,region,len,TRUE);
} }
/* Rotor methods */ /* Rotor methods */
......
/*********************************************************** /***********************************************************
Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
Netherlands. Amsterdam, The Netherlands.
All Rights Reserved All Rights Reserved
...@@ -66,7 +66,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -66,7 +66,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h" #include "modsupport.h"
#include "ceval.h" #include "ceval.h"
#ifdef macintosh
#include ":::src:stdwin:H:stdwin.h"
#else /* !macintosh */
#include "stdwin.h" #include "stdwin.h"
#endif /* !macintosh */
#ifdef USE_THREAD #ifdef USE_THREAD
...@@ -585,8 +589,12 @@ drawing_setfont(self, args) ...@@ -585,8 +589,12 @@ drawing_setfont(self, args)
return NULL; return NULL;
} }
} }
if (font != NULL) if (font != NULL) {
wsetfont(font); if (!wsetfont(font)) {
err_setstr(StdwinError, "font not found");
return NULL;
}
}
if (size != 0) if (size != 0)
wsetsize(size); wsetsize(size);
switch (style) { switch (style) {
......
...@@ -35,6 +35,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -35,6 +35,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef BSD_TIME #ifdef BSD_TIME
#define HAVE_GETTIMEOFDAY #define HAVE_GETTIMEOFDAY
#include "myselect.h" /* Implies <sys/types.h>, <sys/time.h>, <sys/param.h> */
#endif #endif
#ifdef macintosh #ifdef macintosh
...@@ -70,6 +71,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -70,6 +71,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <time.h> #include <time.h>
#endif /* !unix */ #endif /* !unix */
/* XXX This is bogus -- times() is defined in posixmodule.c */
#ifdef DO_TIMES #ifdef DO_TIMES
#include <sys/times.h> #include <sys/times.h>
#include <sys/param.h> #include <sys/param.h>
...@@ -215,7 +217,6 @@ time_times(self, args) ...@@ -215,7 +217,6 @@ time_times(self, args)
{ {
struct tms t; struct tms t;
clock_t c; clock_t c;
object *tuple;
if (!getnoarg(args)) if (!getnoarg(args))
return NULL; return NULL;
errno = 0; errno = 0;
...@@ -224,18 +225,11 @@ time_times(self, args) ...@@ -224,18 +225,11 @@ time_times(self, args)
err_errno(IOError); err_errno(IOError);
return NULL; return NULL;
} }
tuple = newtupleobject(4); return mkvalue("dddd",
if (tuple == NULL) (double)t.tms_utime / HZ,
return NULL; (double)t.tms_stime / HZ,
settupleitem(tuple, 0, newfloatobject((double)t.tms_utime / HZ)); (double)t.tms_cutime / HZ,
settupleitem(tuple, 1, newfloatobject((double)t.tms_stime / HZ)); (double)t.tms_cstime / HZ);
settupleitem(tuple, 2, newfloatobject((double)t.tms_cutime / HZ));
settupleitem(tuple, 3, newfloatobject((double)t.tms_cstime / HZ));
if (err_occurred()) {
DECREF(tuple);
return NULL;
}
return tuple;
} }
#endif #endif
...@@ -285,7 +279,7 @@ floatsleep(secs) ...@@ -285,7 +279,7 @@ floatsleep(secs)
{ {
register long deadline; register long deadline;
deadline = MacTicks + long(secs * 60.0); deadline = MacTicks + (long)(secs * 60.0);
while (MacTicks < deadline) { while (MacTicks < deadline) {
if (intrcheck()) if (intrcheck())
sleep_catcher(SIGINT); sleep_catcher(SIGINT);
...@@ -301,9 +295,9 @@ millitimer() ...@@ -301,9 +295,9 @@ millitimer()
#endif /* macintosh */ #endif /* macintosh */
#ifdef BSD_TIME #ifdef unix
#include "myselect.h" /* Implies <sys/types.h>, <sys/time.h>, <sys/param.h> */ #ifdef BSD_TIME
long long
millitimer() millitimer()
...@@ -329,7 +323,17 @@ floatsleep(secs) ...@@ -329,7 +323,17 @@ floatsleep(secs)
(void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t); (void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t);
} }
#endif /* BSD_TIME */ #else /* !BSD_TIME */
floatsleep(secs)
double secs;
{
sleep((int)secs);
}
#endif /* !BSD_TIME */
#endif /* unix */
#ifdef TURBO_C /* Maybe also for MS-DOS? */ #ifdef TURBO_C /* Maybe also for MS-DOS? */
...@@ -338,14 +342,13 @@ floatsleep(secs) ...@@ -338,14 +342,13 @@ floatsleep(secs)
#define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */ #define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */
#endif #endif
static
floatsleep(secs) floatsleep(secs)
double secs; double secs;
{ {
delay(long(secs/1000.0)); delay(long(secs/1000.0));
} }
static long long
millitimer() millitimer()
{ {
clock_t ticks; clock_t ticks;
......
...@@ -86,7 +86,7 @@ newfileobject(name, mode) ...@@ -86,7 +86,7 @@ newfileobject(name, mode)
f = (fileobject *) newopenfileobject((FILE *)NULL, name, mode, fclose); f = (fileobject *) newopenfileobject((FILE *)NULL, name, mode, fclose);
if (f == NULL) if (f == NULL)
return NULL; return NULL;
#ifdef THINK_C #ifdef USE_FOPENRF
if (*mode == '*') { if (*mode == '*') {
FILE *fopenRF(); FILE *fopenRF();
f->f_fp = fopenRF(name, mode+1); f->f_fp = fopenRF(name, mode+1);
...@@ -670,7 +670,7 @@ writestring(s, f) ...@@ -670,7 +670,7 @@ writestring(s, f)
err_clear(); err_clear();
} }
else { else {
if (writeobject(v, f, PRINT_RAW) != NULL) if (writeobject(v, f, PRINT_RAW) != 0)
err_clear(); err_clear();
DECREF(v); DECREF(v);
} }
......
...@@ -606,8 +606,11 @@ long_compare(a, b) ...@@ -606,8 +606,11 @@ long_compare(a, b)
; ;
if (i < 0) if (i < 0)
sign = 0; sign = 0;
else else {
sign = (int)a->ob_digit[i] - (int)b->ob_digit[i]; sign = (int)a->ob_digit[i] - (int)b->ob_digit[i];
if (a->ob_size < 0)
sign = -sign;
}
} }
return sign < 0 ? -1 : sign > 0 ? 1 : 0; return sign < 0 ? -1 : sign > 0 ? 1 : 0;
} }
......
This diff is collapsed.
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