summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Makefile.pre.in119
-rw-r--r--Modules/Setup.in111
-rw-r--r--Modules/almodule.c81
-rw-r--r--Modules/arraymodule.c145
-rw-r--r--Modules/audioop.c175
-rw-r--r--Modules/cdmodule.c64
-rw-r--r--Modules/cgen.py23
-rw-r--r--Modules/cgensupport.h4
-rw-r--r--Modules/clmodule.c8
-rw-r--r--Modules/config.c.in454
-rw-r--r--Modules/cstubs24
-rw-r--r--Modules/dbmmodule.c36
-rw-r--r--Modules/fcntlmodule.c2
-rw-r--r--Modules/flmodule.c272
-rw-r--r--Modules/fmmodule.c38
-rw-r--r--Modules/imageop.c16
-rw-r--r--Modules/imgfile.c2
-rwxr-xr-xModules/makesetup127
-rw-r--r--Modules/mathmodule.c16
-rw-r--r--Modules/md5.h3
-rw-r--r--Modules/md5c.c3
-rw-r--r--Modules/md5module.c148
-rw-r--r--Modules/mpzmodule.c40
-rw-r--r--Modules/nismodule.c23
-rw-r--r--Modules/parsermodule.c10
-rw-r--r--Modules/posixmodule.c424
-rw-r--r--Modules/pwdmodule.c100
-rw-r--r--Modules/regexmodule.c210
-rw-r--r--Modules/regexpr.c8
-rw-r--r--Modules/regexpr.h10
-rw-r--r--Modules/rgbimgmodule.c8
-rw-r--r--Modules/rotormodule.c44
-rw-r--r--Modules/selectmodule.c15
-rw-r--r--Modules/sgimodule.c2
-rw-r--r--Modules/signalmodule.c14
-rw-r--r--Modules/socketmodule.c115
-rw-r--r--Modules/stdwinmodule.c226
-rw-r--r--Modules/stropmodule.c115
-rw-r--r--Modules/structmodule.c2
-rw-r--r--Modules/sunaudiodev.c44
-rw-r--r--Modules/svmodule.c96
-rw-r--r--Modules/threadmodule.c78
-rw-r--r--Modules/timemodule.c405
-rw-r--r--Modules/version.c396
-rw-r--r--Modules/yuv.h24
-rw-r--r--Modules/yuvconvert.c24
46 files changed, 1958 insertions, 2346 deletions
diff --git a/Modules/Makefile.pre.in b/Modules/Makefile.pre.in
index e8e4a207b6..0b4fa5b531 100644
--- a/Modules/Makefile.pre.in
+++ b/Modules/Makefile.pre.in
@@ -1,39 +1,46 @@
-# NOTE: Makefile.in.in is converted into Makefile.in by running the
-# makesetup script in the current directory. Makefile.in is converted
-# into Makefile by the configure script in the toplevel directory.
-# Once Makefile exists, it can be brought up to date by running
-# "make Makefile".
+# META-NOTE: this note is different from the note in the other Makefiles!
+# NOTE: Makefile.pre.in is converted into Makefile.pre by the configure
+# script in the toplevel directory or by ../config.status.
+# Makefile.pre is converted into Makefile by running the makesetup
+# script in the source directory. Once Makefile exists, it can be
+# brought up to date by running "make Makefile". (The makesetup also
+# creates config.c from config.c.in in the source directory.)
-# === Variables set by ./makesetup ===
+# === Variables set by makesetup ===
MODOBJS= @MODOBJS@
MODLIBS= @MODLIBS@
-MODCPPS= @MODCPPS@
-# === Definitions added by ./makesetup ===
+# === Definitions added by makesetup ===
-# === Variables set by $(TOP)/configure ===
+# === Variables set by configure ===
srcdir= @srcdir@
VPATH= @srcdir@
CC= @CC@
RANLIB= @RANLIB@
+AR= @AR@
+
DEFS= @DEFS@
LIBS= @LIBS@
+LIBM= @LIBM@
+LIBC= @LIBC@
+
+# Install prefix, may be changed by configure
+prefix= /usr/local
# === Variables that are customizable by hand ===
-TOP= ..
-INCLDIR= $(TOP)/Include
-OPT= -g
-CFLAGS= $(OPT) -I$(INCLDIR) $(DEFS)
+INCLDIR= $(srcdir)/../Include
+OPT= -O
+CFLAGS= $(OPT) -I$(INCLDIR) -I.. $(DEFS)
-AR= ar
MKDEP= mkdep
SHELL= /bin/sh
+MAKESETUP= $(srcdir)/makesetup
# === Fixed definitions ===
@@ -46,46 +53,88 @@ MYLIBS= $(LIB) \
../Objects/libObjects.a \
../Parser/libParser.a
-SYSLIBS= $(MODLIBS) -lm
+SYSLIBS= $(LIBM) $(LIBC)
# === Rules ===
-all: $(LIB) $(TOP)/python
+all: $(LIB) ../python
$(LIB): $(OBJS)
$(AR) cr $(LIB) $(OBJS)
$(RANLIB) $(LIB)
-$(TOP)/python: config.o $(MYLIBS)
- $(CC) config.o $(MYLIBS) $(LIBS) $(SYSLIBS) -o python
- mv python $(TOP)/python
+../python: config.o $(MYLIBS)
+ $(CC) config.o $(MYLIBS) $(MODLIBS) $(LIBS) $(SYSLIBS) -o python
+ mv python ../python
-config.o: Makefile
+config.o: config.c Makefile
+ $(CC) $(CFLAGS) -DPYTHONPATH=\"$(PYTHONPATH)\" -c config.c
clean:
-rm -f *.o python core *~ [@,#]* *.old *.orig *.rej
clobber: clean
- -rm -f *.a tags TAGS
-
-Makefile: Makefile.in $(TOP)/config.status
- CONFIG_FILES=Makefile CONFIG_HEADERS= \
- $(SHELL) $(TOP)/config.status
+ -rm -f *.a tags TAGS config.c glmodule.c Makefile.pre
-config.c Makefile.in: Makefile.in.in config.c.in Setup makesetup
- $(SHELL) ./makesetup Setup
+config.c Makefile: Makefile.pre config.c.in $(MAKESETUP) Setup
+ $(SHELL) $(MAKESETUP) Setup
-depend:
- $(MKDEP) $(CFLAGS) \
- `echo $(OBJS) | tr ' ' '\012' | sed 's/\.o/.c/'`
-
-.PRECIOUS: Makefile.in Makefile config.c
+Setup:
+ cp $(srcdir)/Setup.in Setup
-glmodule.c: cgen.py cstubs
- python cgen.py <cstubs >glmodule.c
+Makefile.pre: Makefile.pre.in ../config.status
+ (cd ..; CONFIG_FILES=Modules/Makefile.pre CONFIG_HEADERS= \
+ $(SHELL) config.status)
-# === Rules added by ./makesetup ===
+depend:
+ $(MKDEP) $(CFLAGS) `echo $(OBJS) | tr ' ' '\012' | \
+ sed 's|\(.*\)\.o|$(srcdir)/\1.c|'`
+
+.PRECIOUS: ../python
+
+glmodule.c: $(srcdir)/cgen.py $(srcdir)/cstubs
+ python $(srcdir)/cgen.py <$(srcdir)/cstubs >glmodule.c
+
+almodule.o: almodule.c
+arraymodule.o: arraymodule.c
+audioopmodule.o: audioopmodule.c
+cdmodule.o: cdmodule.c
+clmodule.o: clmodule.c
+dbmmodule.o: dbmmodule.c
+fcntlmodule.o: fcntlmodule.c
+flmodule.o: flmodule.c
+fmmodule.o: fmmodule.c
+glmodule.o: glmodule.c
+imageopmodule.o: imageopmodule.c
+imgfilemodule.o: imgfilemodule.c
+mathmodule.o: mathmodule.c
+md5c.o: md5c.c
+md5module.o: md5module.c
+mpzmodule.o: mpzmodule.c
+nismodule.o: nismodule.c
+parsermodule.o: parsermodule.c
+posixmodule.o: posixmodule.c
+pwdmodule.o: pwdmodule.c
+regexmodule.o: regexmodule.c
+regexpr.o: regexpr.c
+rgbimgmodule.o: rgbimgmodule.c
+rotormodule.o: rotormodule.c
+selectmodule.o: selectmodule.c
+sgimodule.o: sgimodule.c
+socketmodule.o: socketmodule.c
+stdwinmodule.o: stdwinmodule.c
+stropmodule.o: stropmodule.c
+structmodule.o: structmodule.c
+sunaudiodevmodule.o: sunaudiodevmodule.c
+svmodule.o: svmodule.c
+threadmodule.o: threadmodule.c
+timemodule.o: timemodule.c
+timingmodule.o: timingmodule.c
+xxmodule.o: xxmodule.c
+yuvconvert.o: yuvconvert.c
+
+# === Rules added by makesetup ===
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
diff --git a/Modules/Setup.in b/Modules/Setup.in
index 7dd40fdd38..f7b5bace3d 100644
--- a/Modules/Setup.in
+++ b/Modules/Setup.in
@@ -1,7 +1,16 @@
-# This file is used by the makesetup script to construct Makefile.in
-# and config.c, from Makefile.in.in (sic!) and config.c.in,
-# respectively.
-#
+# The file Setup is used by the makesetup script to construct the files
+# Makefile and config.c, from Makefile.pre and config.c.in,
+# respectively. The file Setup itself is initially copied from
+# Setup.in; once it exists it will not be overwritten, so you can edit
+# Setup to your heart's content. One possibility is to overwrite it
+# with a copy of Setup.sgi or Setup.sunos[45] before you start editing.
+# Note that Makefile.pre is created from Makefile.pre.in by the toplevel
+# configure script.
+
+# (VPATH notes: Setup and Makefile.pre are in the build directory, as
+# are Makefile and config.c; Setup.in and config.c.in are in the source
+# directory.)
+
# Each line in this file describes one or more optional modules.
# Comment out lines to suppress modules.
# Lines have the following structure:
@@ -19,7 +28,7 @@
# <name> = <value>
#
# which defines a Make variable definition inserted into Makefile.in
-#
+
# NOTE: As a standard policy, as many modules as can be supported by a
# platform should be present. The distribution comes with all modules
# enabled that are supported by most platforms and don't require you
@@ -28,6 +37,28 @@
# to use Setup.sgi instead of Setup).
+# Some special rules to define PYTHONPATH.
+# Edit the definitions below to indicate which options you are using.
+# Don't add any whitespace or comments!
+
+# Don't edit this (usually)
+DESTLIB=$(prefix)/lib/python
+
+# Standard enabled (tests are always available)
+TESTPATH=:$(DESTLIB)/test
+
+# Enable this for SGI systems
+#ARCHPATH=:$(DESTLIB)/sgi
+
+# Enable this for Sun systems
+#ARCHPATH=:$(DESTLIB)/sun4
+
+# Enable this if stdwin installed
+#STDWINPATH=:$(DESTLIB)/stdwin
+
+PYTHONPATH=.:$(DESTLIB)$(TESTPATH)$(ARCHPATH)$(STDWINPATH)
+
+
# Modules that should always be present (non UNIX dependent)
array arraymodule.o # array objects
@@ -41,18 +72,25 @@ time timemodule.o # time operations and variables
# Modules with some UNIX dependencies -- on by default.
-# Note that some UNIX versions still don't support all of these
-# so you may have to comment them out before the build completes.
+# (If you have a really backward UNIX, select and socket may not be
+# supported...)
-dbm dbmmodule.o # dbm(3) may require -ldbm or similar
fcntl fcntlmodule.o # fcntl(2) and ioctl(2)
-nis nismodule.o # Sun yellow pages -- not everywhere
-pwd grp pwdmodule.o # pwd(3) and grp(3)
+pwd pwdmodule.o # pwd(3)
+grp grpmodule.o # grp(3)
+crypt cryptmodule.o # crypt(3)
select selectmodule.o # select(2); not on ancient System V
socket socketmodule.o # socket(2); not on ancient System V
-# Multimedia modules -- off by default
+# Some more UNIX dependent modules -- off by default, since these
+# are not supported by all UNIX systems.
+
+#dbm dbmmodule.o # dbm(3) may require -lndbm or similar
+#nis nismodule.o # Sun yellow pages -- not everywhere
+
+
+# Multimedia modules -- on by default.
# These represent audio samples or images as strings
audioop audioopmodule.o # Operations on audio samples
@@ -69,7 +107,7 @@ rgbimg rgbimgmodule.o # Read SGI RGB image files (but coded portably)
# "-lX11_s".
#STDWIN=/ufs/guido/src/stdwin
-#ARCH=sgi
+#ARCH=???
#stdwin stdwinmodule.o -I$(STDWIN)/H $(STDWIN)/Build/$(ARCH)/x11/lib/lib.a -lX11
@@ -81,10 +119,12 @@ md5 md5module.o md5c.o
# The mpz module interfaces to the GNU Multiple Precision library.
-# You need to ftp the GNU MP library. This was last tested with a
-# somewhat modified (to get around bugs) version of GMP 1.2; it will
-# likely need some work for more recent versions. The GMP variable
-# must point to the GMP source directory.
+# You need to ftp the GNU MP library.
+# The GMP variable must point to the GMP source directory.
+# This was originally written and tested against GMP 1.2. I have
+# compiled it against GMP 1.3.2 (the latest I believe) and it seems to
+# work OK, but I haven't tested it thoroughly (lacking knowledge about
+# it).
#GMP=/ufs/guido/src/gmp
#mpz mpzmodule.o -I$(GMP) $(GMP)/libgmp.a
@@ -102,12 +142,13 @@ rotor rotormodule.o
# installed; you may be better off switching on only 'fm' and 'gl'
# (Font Manager and Graphics Library).
-#al almodule.o -laudio # audio
-#cd cdmodule.o -lcdaudio -lds #
-#cl clmodule.o -lcl
+# # ADD THESE FOR IRIX5:
+#al almodule.o -laudio
+#cd cdmodule.o -lcdaudio -lds # -lmediad
+#cl clmodule.o -lcl # -lawareaudio
#fm fmmodule.o -lfm_s -lgl_s
-#gl glmodule.o -lgl_s
-#imgfile imgfilemodule.o -limage -lgutil -lm
+#gl glmodule.o -lgl_s -lX11_s
+#imgfile imgfilemodule.o -limage -lgutil
#sgi sgimodule.o
#sv svmodule.o yuvconvert.o -lsvideo -lXext -lX11_s
@@ -134,6 +175,34 @@ rotor rotormodule.o
# thread threadmodule.o
+# GNN's timing module
+# timing timingmodule.o
+
+
+# Lance Ellinghouse's signal module
+# signal signalmodule.o
+
+
+# Tommy Burnette's 'new' module (creates new empty objects of certain kinds)
+# new newmodule.o
+
+
+# John Redford's sybase module
+# sybase sybasemodule.o
+
+
+# Generic (SunOS / SVR4) dynamic loading module
+# dl dlmodule.o
+
+
+# Jack Jansen's imgformat module
+# imgformat imgformatmodule.o
+
+
+# Lance Ellinghouse's syslog module
+# syslog syslogmodule.o
+
+
# Example -- included for reference only
# xx xxmodule.o
diff --git a/Modules/almodule.c b/Modules/almodule.c
index d731eff16e..2ab60d47c4 100644
--- a/Modules/almodule.c
+++ b/Modules/almodule.c
@@ -1,5 +1,5 @@
/**********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -24,7 +24,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* AL module -- interface to Mark Callow's Audio Library (AL). */
-#include "audio.h"
+#include <audio.h>
/* Check which version audio library we have: */
#ifdef AL_ERROR_NUMBER
@@ -50,7 +50,7 @@ typedef struct {
ALconfig ob_config;
} configobject;
-extern typeobject Configtype; /* Forward */
+staticforward typeobject Configtype;
#define is_configobject(v) ((v)->ob_type == &Configtype)
@@ -184,17 +184,17 @@ al_setfloatmax(self, args)
#endif /* AL_405 */
static struct methodlist config_methods[] = {
- {"getqueuesize", al_getqueuesize},
- {"setqueuesize", al_setqueuesize},
- {"getwidth", al_getwidth},
- {"setwidth", al_setwidth},
- {"getchannels", al_getchannels},
- {"setchannels", al_setchannels},
+ {"getqueuesize", (method)al_getqueuesize},
+ {"setqueuesize", (method)al_setqueuesize},
+ {"getwidth", (method)al_getwidth},
+ {"setwidth", (method)al_setwidth},
+ {"getchannels", (method)al_getchannels},
+ {"setchannels", (method)al_setchannels},
#ifdef AL_405
- {"getsampfmt", al_getsampfmt},
- {"setsampfmt", al_setsampfmt},
- {"getfloatmax", al_getfloatmax},
- {"setfloatmax", al_setfloatmax},
+ {"getsampfmt", (method)al_getsampfmt},
+ {"setsampfmt", (method)al_setsampfmt},
+ {"getfloatmax", (method)al_getfloatmax},
+ {"setfloatmax", (method)al_setfloatmax},
#endif /* AL_405 */
{NULL, NULL} /* sentinel */
};
@@ -215,16 +215,16 @@ config_getattr(self, name)
return findmethod(config_methods, (object *)self, name);
}
-typeobject Configtype = {
+static typeobject Configtype = {
OB_HEAD_INIT(&Typetype)
0, /*ob_size*/
"config", /*tp_name*/
sizeof(configobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- config_dealloc, /*tp_dealloc*/
+ (destructor)config_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- config_getattr, /*tp_getattr*/
+ (getattrfunc)config_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
@@ -250,7 +250,7 @@ typedef struct {
ALport ob_port;
} portobject;
-extern typeobject Porttype; /* Forward */
+staticforward typeobject Porttype;
#define is_portobject(v) ((v)->ob_type == &Porttype)
@@ -489,20 +489,19 @@ al_getstatus (self, args)
#endif /* AL_405 */
static struct methodlist port_methods[] = {
- {"closeport", al_closeport},
- {"close", al_closeport},
- {"getfd", al_getfd},
- {"fileno", al_getfd},
- {"getfilled", al_getfilled},
- {"getfillable", al_getfillable},
- {"readsamps", al_readsamps},
- {"writesamps", al_writesamps},
- {"setfillpoint", al_setfillpoint},
- {"getfillpoint", al_getfillpoint},
- {"setconfig", al_setconfig},
- {"getconfig", al_getconfig},
+ {"closeport", (method)al_closeport},
+ {"getfd", (method)al_getfd},
+ {"fileno", (method)al_getfd},
+ {"getfilled", (method)al_getfilled},
+ {"getfillable", (method)al_getfillable},
+ {"readsamps", (method)al_readsamps},
+ {"writesamps", (method)al_writesamps},
+ {"setfillpoint", (method)al_setfillpoint},
+ {"getfillpoint", (method)al_getfillpoint},
+ {"setconfig", (method)al_setconfig},
+ {"getconfig", (method)al_getconfig},
#ifdef AL_405
- {"getstatus", al_getstatus},
+ {"getstatus", (method)al_getstatus},
#endif /* AL_405 */
{NULL, NULL} /* sentinel */
};
@@ -524,16 +523,16 @@ port_getattr(p, name)
return findmethod(port_methods, (object *)p, name);
}
-typeobject Porttype = {
+static typeobject Porttype = {
OB_HEAD_INIT(&Typetype)
0, /*ob_size*/
"port", /*tp_name*/
sizeof(portobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- port_dealloc, /*tp_dealloc*/
+ (destructor)port_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- port_getattr, /*tp_getattr*/
+ (getattrfunc)port_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
@@ -736,14 +735,14 @@ al_getminmax(self, args)
}
static struct methodlist al_methods[] = {
- {"openport", al_openport},
- {"newconfig", al_newconfig},
- {"queryparams", al_queryparams},
- {"getparams", al_getparams},
- {"setparams", al_setparams},
- {"getname", al_getname},
- {"getdefault", al_getdefault},
- {"getminmax", al_getminmax},
+ {"openport", (method)al_openport},
+ {"newconfig", (method)al_newconfig},
+ {"queryparams", (method)al_queryparams},
+ {"getparams", (method)al_getparams},
+ {"setparams", (method)al_setparams},
+ {"getname", (method)al_getname},
+ {"getdefault", (method)al_getdefault},
+ {"getminmax", (method)al_getminmax},
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 925a52d2ef..4b89ad9153 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -30,22 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "allobjects.h"
#include "modsupport.h"
#include "ceval.h"
-
-#ifdef i860
-/* Cray APP doesn't have memmove */
-#define NEED_MEMMOVE
-extern char *memcpy();
-#endif
-
-#if defined(sun) && !defined(__STDC__)
-/* SunOS doesn't have memmove */
-#define NEED_MEMMOVE
-extern char *memcpy();
-#endif
-
-#ifdef NEED_MEMMOVE
-extern char *memmove();
-#endif
+#include <sys/types.h> /* For size_t */
struct arrayobject; /* Forward */
@@ -62,7 +47,7 @@ typedef struct arrayobject {
struct arraydescr *ob_descr;
} arrayobject;
-extern typeobject Arraytype;
+staticforward typeobject Arraytype;
#define is_arrayobject(op) ((op)->ob_type == &Arraytype)
@@ -252,7 +237,7 @@ newarrayobject(size, descr)
{
int i;
arrayobject *op;
- MALLARG nbytes;
+ size_t nbytes;
int itemsize;
if (size < 0) {
err_badcall();
@@ -962,22 +947,22 @@ array_tostring(self, args)
}
static struct methodlist array_methods[] = {
- {"append", array_append},
- {"byteswap", array_byteswap},
-/* {"count", array_count},*/
- {"fromfile", array_fromfile},
- {"fromlist", array_fromlist},
- {"fromstring", array_fromstring},
-/* {"index", array_index},*/
- {"insert", array_insert},
- {"read", array_fromfile},
-/* {"remove", array_remove},*/
- {"reverse", array_reverse},
-/* {"sort", array_sort},*/
- {"tofile", array_tofile},
- {"tolist", array_tolist},
- {"tostring", array_tostring},
- {"write", array_tofile},
+ {"append", (method)array_append},
+ {"byteswap", (method)array_byteswap},
+/* {"count", (method)array_count},*/
+ {"fromfile", (method)array_fromfile},
+ {"fromlist", (method)array_fromlist},
+ {"fromstring", (method)array_fromstring},
+/* {"index", (method)array_index},*/
+ {"insert", (method)array_insert},
+ {"read", (method)array_fromfile},
+/* {"remove", (method)array_remove},*/
+ {"reverse", (method)array_reverse},
+/* {"sort", (method)array_sort},*/
+ {"tofile", (method)array_tofile},
+ {"tolist", (method)array_tolist},
+ {"tostring", (method)array_tostring},
+ {"write", (method)array_tofile},
{NULL, NULL} /* sentinel */
};
@@ -1060,65 +1045,51 @@ array_repr(a)
v = array_tostring(a, (object *)NULL);
t = reprobject(v);
XDECREF(v);
- joinstring(&s, t);
- XDECREF(t);
- t = newstringobject(")");
- joinstring(&s, t);
- XDECREF(t);
- if (err_occurred()) {
- XDECREF(s);
- s = NULL;
- }
+ joinstring_decref(&s, t);
+ joinstring_decref(&s, newstringobject(")"));
return s;
}
sprintf(buf, "array('%c', [", a->ob_descr->typecode);
s = newstringobject(buf);
comma = newstringobject(", ");
for (i = 0; i < len && !err_occurred(); i++) {
+ if (i > 0)
+ joinstring(&s, comma);
v = (a->ob_descr->getitem)(a, i);
t = reprobject(v);
XDECREF(v);
- if (i > 0)
- joinstring(&s, comma);
- joinstring(&s, t);
- XDECREF(t);
+ joinstring_decref(&s, t);
}
XDECREF(comma);
- t = newstringobject("])");
- joinstring(&s, t);
- XDECREF(t);
- if (err_occurred()) {
- XDECREF(s);
- s = NULL;
- }
+ joinstring_decref(&s, newstringobject("])"));
return s;
}
static sequence_methods array_as_sequence = {
- array_length, /*sq_length*/
- array_concat, /*sq_concat*/
- array_repeat, /*sq_repeat*/
- array_item, /*sq_item*/
- array_slice, /*sq_slice*/
- array_ass_item, /*sq_ass_item*/
- array_ass_slice, /*sq_ass_slice*/
+ (inquiry)array_length, /*sq_length*/
+ (binaryfunc)array_concat, /*sq_concat*/
+ (intargfunc)array_repeat, /*sq_repeat*/
+ (intargfunc)array_item, /*sq_item*/
+ (intintargfunc)array_slice, /*sq_slice*/
+ (intobjargproc)array_ass_item, /*sq_ass_item*/
+ (intintobjargproc)array_ass_slice, /*sq_ass_slice*/
};
-typeobject Arraytype = {
+static typeobject Arraytype = {
OB_HEAD_INIT(&Typetype)
0,
"array",
sizeof(arrayobject),
0,
- array_dealloc, /*tp_dealloc*/
- array_print, /*tp_print*/
- array_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- array_compare, /*tp_compare*/
- array_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- &array_as_sequence, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
+ (destructor)array_dealloc, /*tp_dealloc*/
+ (printfunc)array_print, /*tp_print*/
+ (getattrfunc)array_getattr, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ (cmpfunc)array_compare, /*tp_compare*/
+ (reprfunc)array_repr, /*tp_repr*/
+ 0, /*tp_as_number*/
+ &array_as_sequence, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
};
@@ -1187,33 +1158,3 @@ initarray()
{
initmodule("array", a_methods);
}
-
-
-#ifdef NEED_MEMMOVE
-
-/* A perhaps slow but I hope correct implementation of memmove */
-
-char *memmove(dst, src, n)
- char *dst;
- char *src;
- int n;
-{
- char *realdst = dst;
- if (n <= 0)
- return dst;
- if (src >= dst+n || dst >= src+n)
- return memcpy(dst, src, n);
- if (src > dst) {
- while (--n >= 0)
- *dst++ = *src++;
- }
- else if (src < dst) {
- src += n;
- dst += n;
- while (--n >= 0)
- *--dst = *--src;
- }
- return realdst;
-}
-
-#endif
diff --git a/Modules/audioop.c b/Modules/audioop.c
index 8bd833ad48..cfb97f2904 100644
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -22,17 +22,19 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
-/* audioopmodele - Module to detect peak values in arrays */
+/* audioopmodule - Module to detect peak values in arrays */
-#ifdef sun
-#define signed
+#include "allobjects.h"
+#include "modsupport.h"
+
+#if defined(__CHAR_UNSIGNED__) && defined(signed)
+!ERROR!; READ THE SOURCE FILE!;
+/* This module currently does not work on systems where only unsigned
+ characters are available. Take it out of Setup. Sorry. */
#endif
#include <math.h>
-#include "allobjects.h"
-#include "modsupport.h"
-
/* Code shamelessly stolen from sox,
** (c) Craig Reese, Joe Campbell and Jeff Poskanzer 1989 */
@@ -213,32 +215,6 @@ audioop_max(self, args)
}
static object *
-audioop_minmax(self, args)
- object *self;
- object *args;
-{
- signed char *cp;
- int len, size, val;
- int i;
- int min = 0x7fffffff, max = -0x7fffffff;
-
- if (!getargs(args, "(s#i)", &cp, &len, &size))
- return NULL;
- if (size != 1 && size != 2 && size != 4) {
- err_setstr(AudioopError, "Size should be 1, 2 or 4");
- return NULL;
- }
- for (i = 0; i < len; i += size) {
- if (size == 1) val = (int) *CHARP(cp, i);
- else if (size == 2) val = (int) *SHORTP(cp, i);
- else if (size == 4) val = (int) *LONGP(cp, i);
- if (val > max) max = val;
- if (val < min) min = val;
- }
- return mkvalue("(ii)", min, max);
-}
-
-static object *
audioop_avg(self, args)
object *self;
object *args;
@@ -997,136 +973,6 @@ audioop_ulaw2lin(self, args)
}
static object *
-audioop_lin2adpcm3(self, args)
- object *self;
- object *args;
-{
- signed char *cp;
- signed char *ncp;
- int len, size, val, step, valprev, delta;
- object *rv, *state, *str;
- int i;
-
- if ( !getargs(args, "(s#iO)",
- &cp, &len, &size, &state) )
- return 0;
-
-
- if ( size != 1 && size != 2 && size != 4) {
- err_setstr(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
-
- str = newsizedstringobject(NULL, len/size);
- if ( str == 0 )
- return 0;
- ncp = (signed char *)getstringvalue(str);
-
- /* Decode state, should have (value, step) */
- if ( state == None ) {
- /* First time, it seems. Set defaults */
- valprev = 0;
- step = 4; /* The '4' is magic. Dunno it's significance */
- } else if ( !getargs(state, "(ii)", &valprev, &step) )
- return 0;
-
- for ( i=0; i < len; i += size ) {
- if ( size == 1 ) val = ((int)*CHARP(cp, i)) << 8;
- else if ( size == 2 ) val = (int)*SHORTP(cp, i);
- else if ( size == 4 ) val = ((int)*LONGP(cp, i)) >> 16;
-
- /* Step 1 - compute difference with previous value */
- delta = (val - valprev)/step;
-
- /* Step 2 - Clamp */
- if ( delta < -4 )
- delta = -4;
- else if ( delta > 3 )
- delta = 3;
-
- /* Step 3 - Update previous value */
- valprev += delta*step;
-
- /* Step 4 - Clamp previous value to 16 bits */
- if ( valprev > 32767 )
- valprev = 32767;
- else if ( valprev < -32768 )
- valprev = -32768;
-
- /* Step 5 - Update step value */
- step = step * newstep[abs(delta)];
- step++; /* Don't understand this. */
-
- /* Step 6 - Output value (as a whole byte, currently) */
- *ncp++ = delta;
- }
- rv = mkvalue("(O(ii))", str, valprev, step);
- DECREF(str);
- return rv;
-}
-
-static object *
-audioop_adpcm32lin(self, args)
- object *self;
- object *args;
-{
- signed char *cp;
- signed char *ncp;
- int len, size, val, valprev, step, delta;
- object *rv, *str, *state;
- int i;
-
- if ( !getargs(args, "(s#iO)",
- &cp, &len, &size, &state) )
- return 0;
-
- if ( size != 1 && size != 2 && size != 4) {
- err_setstr(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
-
- /* Decode state, should have (value, step) */
- if ( state == None ) {
- /* First time, it seems. Set defaults */
- valprev = 0;
- step = 4; /* The '4' is magic. Dunno it's significance */
- } else if ( !getargs(state, "(ii)", &valprev, &step) )
- return 0;
-
- str = newsizedstringobject(NULL, len*size);
- if ( str == 0 )
- return 0;
- ncp = (signed char *)getstringvalue(str);
-
- for ( i=0; i < len*size; i += size ) {
- /* Step 1 - get the delta value */
- delta = *cp++;
-
- /* Step 2 - update output value */
- valprev = valprev + delta*step;
-
- /* Step 3 - clamp output value */
- if ( valprev > 32767 )
- valprev = 32767;
- else if ( valprev < -32768 )
- valprev = -32768;
-
- /* Step 4 - Update step value */
- step = step * newstep[abs(delta)];
- step++;
-
- /* Step 5 - Output value */
- if ( size == 1 ) *CHARP(ncp, i) = (signed char)(valprev >> 8);
- else if ( size == 2 ) *SHORTP(ncp, i) = (short)(valprev);
- else if ( size == 4 ) *LONGP(ncp, i) = (long)(valprev<<16);
- }
-
- rv = mkvalue("(O(ii))", str, valprev, step);
- DECREF(str);
- return rv;
-}
-
-static object *
audioop_lin2adpcm(self, args)
object *self;
object *args;
@@ -1330,7 +1176,6 @@ audioop_adpcm2lin(self, args)
static struct methodlist audioop_methods[] = {
{ "max", audioop_max },
- { "minmax", audioop_minmax },
{ "avg", audioop_avg },
{ "maxpp", audioop_maxpp },
{ "avgpp", audioop_avgpp },
@@ -1347,8 +1192,6 @@ static struct methodlist audioop_methods[] = {
{ "lin2lin", audioop_lin2lin },
{ "adpcm2lin", audioop_adpcm2lin },
{ "lin2adpcm", audioop_lin2adpcm },
- { "adpcm32lin", audioop_adpcm32lin },
- { "lin2adpcm3", audioop_lin2adpcm3 },
{ "tomono", audioop_tomono },
{ "tostereo", audioop_tostereo },
{ "getsample", audioop_getsample },
diff --git a/Modules/cdmodule.c b/Modules/cdmodule.c
index b5d0defd59..0630ebc735 100644
--- a/Modules/cdmodule.c
+++ b/Modules/cdmodule.c
@@ -1,5 +1,5 @@
/**********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -440,23 +440,23 @@ CD_togglepause(self, args)
}
static struct methodlist cdplayer_methods[] = {
- {"allowremoval", CD_allowremoval},
- {"bestreadsize", CD_bestreadsize},
- {"close", CD_close},
- {"eject", CD_eject},
- {"getstatus", CD_getstatus},
- {"gettrackinfo", CD_gettrackinfo},
- {"msftoblock", CD_msftoblock},
- {"play", CD_play},
- {"playabs", CD_playabs},
- {"playtrack", CD_playtrack},
- {"playtrackabs", CD_playtrackabs},
- {"preventremoval", CD_preventremoval},
- {"readda", CD_readda},
- {"seek", CD_seek},
- {"seektrack", CD_seektrack},
- {"stop", CD_stop},
- {"togglepause", CD_togglepause},
+ {"allowremoval", (method)CD_allowremoval},
+ {"bestreadsize", (method)CD_bestreadsize},
+ {"close", (method)CD_close},
+ {"eject", (method)CD_eject},
+ {"getstatus", (method)CD_getstatus},
+ {"gettrackinfo", (method)CD_gettrackinfo},
+ {"msftoblock", (method)CD_msftoblock},
+ {"play", (method)CD_play},
+ {"playabs", (method)CD_playabs},
+ {"playtrack", (method)CD_playtrack},
+ {"playtrackabs", (method)CD_playtrackabs},
+ {"preventremoval", (method)CD_preventremoval},
+ {"readda", (method)CD_readda},
+ {"seek", (method)CD_seek},
+ {"seektrack", (method)CD_seektrack},
+ {"stop", (method)CD_stop},
+ {"togglepause", (method)CD_togglepause},
{NULL, NULL} /* sentinel */
};
@@ -484,9 +484,9 @@ typeobject CdPlayertype = {
sizeof(cdplayerobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- cdplayer_dealloc, /*tp_dealloc*/
+ (destructor)cdplayer_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- cdplayer_getattr, /*tp_getattr*/
+ (getattrfunc)cdplayer_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
@@ -755,12 +755,12 @@ CD_addcallback(self, args)
}
static struct methodlist cdparser_methods[] = {
- {"addcallback", CD_addcallback},
- {"deleteparser", CD_deleteparser},
- {"parseframe", CD_parseframe},
- {"removecallback", CD_removecallback},
- {"resetparser", CD_resetparser},
- {"setcallback", CD_addcallback}, /* backward compatibility */
+ {"addcallback", (method)CD_addcallback},
+ {"deleteparser", (method)CD_deleteparser},
+ {"parseframe", (method)CD_parseframe},
+ {"removecallback", (method)CD_removecallback},
+ {"resetparser", (method)CD_resetparser},
+ {"setcallback", (method)CD_addcallback}, /* backward compatibility */
{NULL, NULL} /* sentinel */
};
@@ -795,9 +795,9 @@ typeobject CdParsertype = {
sizeof(cdparserobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- cdparser_dealloc, /*tp_dealloc*/
+ (destructor)cdparser_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- cdparser_getattr, /*tp_getattr*/
+ (getattrfunc)cdparser_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
@@ -877,10 +877,10 @@ CD_timetoa(self, args)
}
static struct methodlist CD_methods[] = {
- {"sbtoa", CD_sbtoa},
- {"open", CD_open},
- {"createparser",CD_createparser},
- {"timetoa", CD_timetoa},
+ {"sbtoa", (method)CD_sbtoa},
+ {"open", (method)CD_open},
+ {"createparser",(method)CD_createparser},
+ {"timetoa", (method)CD_timetoa},
{NULL, NULL} /* Sentinel */
};
diff --git a/Modules/cgen.py b/Modules/cgen.py
index 434765b783..c133b2c878 100644
--- a/Modules/cgen.py
+++ b/Modules/cgen.py
@@ -1,3 +1,26 @@
+########################################################################
+# Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
+# Amsterdam, The Netherlands.
+#
+# All Rights Reserved
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies and that
+# both that copyright notice and this permission notice appear in
+# supporting documentation, and that the names of Stichting Mathematisch
+# Centrum or CWI not be used in advertising or publicity pertaining to
+# distribution of the software without specific, written prior permission.
+#
+# STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
+# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
+# FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+########################################################################
+
# Python script to parse cstubs file for gl and generate C stubs.
# usage: python cgen.py <cstubs >glmodule.c
#
diff --git a/Modules/cgensupport.h b/Modules/cgensupport.h
index 8472b0349c..4b295b30aa 100644
--- a/Modules/cgensupport.h
+++ b/Modules/cgensupport.h
@@ -5,7 +5,7 @@ extern "C" {
#endif
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -35,7 +35,7 @@ typedef char *string;
#define mknewlongobject(x) newintobject(x)
#define mknewshortobject(x) newintobject((long)x)
#define mknewfloatobject(x) newfloatobject(x)
-#define mknewcharobject(c) mkvalue("c", c)
+#define mknewcharobject(ch) mkvalue("c", ch)
extern int getiobjectarg PROTO((object *args, int nargs, int i, object **p_a));
extern int getilongarg PROTO((object *args, int nargs, int i, long *p_a));
diff --git a/Modules/clmodule.c b/Modules/clmodule.c
index 63e81db470..75542d1ecb 100644
--- a/Modules/clmodule.c
+++ b/Modules/clmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -675,9 +675,9 @@ static typeobject Cltype = {
sizeof(clobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- cl_dealloc, /*tp_dealloc*/
+ (destructor)cl_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- cl_getattr, /*tp_getattr*/
+ (getattrfunc)cl_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
@@ -711,7 +711,7 @@ doOpen(object *self, object *args, int (*open_func)(int, CL_Handle *),
err_setstr(ClError, "Open(De)Compressor failed");
return NULL;
}
- return new;
+ return (object *)new;
}
static object *
diff --git a/Modules/config.c.in b/Modules/config.c.in
index b4f7d3dfff..cc2371af86 100644
--- a/Modules/config.c.in
+++ b/Modules/config.c.in
@@ -1,5 +1,5 @@
-/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+/* -*- C -*- ***********************************************
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -22,115 +22,73 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
-/* Configurable Python configuration file */
+/* Universal Python configuration file */
-/* These modules are normally always included, but *may* be taken out */
-#define USE_MARSHAL 1 /* This is linked anyway */
-#define USE_MATH 1
-#define USE_STRUCT 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_STDWIN 1 /* You may turn this off */
-#define USE_STROP
-#endif
-
-#ifdef unix
-#define USE_GRP 1 /* Use together with pwd */
-#define USE_POSIX 1
-#define USE_PWD 1 /* Use together with grp */
-#define USE_SELECT 1
-#define USE_SOCKET 1
-#endif
-
-#ifdef MSDOS
-#define USE_POSIX 1 /* Subset defined in posixmodule.c */
-#define USE_REGEX 1
-#define USE_STROP 1
-#define USE_PC 1
+#ifdef HAVE_CONFIG_H
+#include "config.h"
#endif
#include <stdio.h>
+#include <string.h>
-#include "PROTO.h"
+#include "myproto.h"
#include "mymalloc.h"
#include "osdefs.h"
+#include "intrcheck.h"
-#include "patchlevel.h"
-#define VERSION "0.9.%d++ (%s)"
+#ifndef NO_MAIN
-#ifdef __DATE__
-#define DATE __DATE__
-#else
-#define DATE ">= 3 Nov 1993"
-#endif
-
-char version[80];
+/* Normally, the main program is called from here (so everything else
+ can be in libPython.a). We save a pointer to argv[0] because it
+ may be needed for dynamic loading of modules in import.c. If you
+ have your own main program and want to use non-SunOS dynamic
+ loading, you will have to provide your own version of
+ getprogramname(). */
-char *argv0; /* For dynamic loading in import.c */
+static char *argv0;
-extern char verbose;
-
-/*ARGSUSED*/
-void
-initargs(p_argc, p_argv)
- int *p_argc;
- char ***p_argv;
+main(argc, argv)
+ int argc;
+ char **argv;
{
- sprintf(version, VERSION, PATCHLEVEL, DATE);
-
- argv0 = **p_argv;
-
-#ifdef USE_FROZEN
- if (verbose)
-#else
- if (verbose || *p_argc < 2 && isatty(0) && isatty(1))
+#ifdef macintosh
+ wargs(&argc, &argv);
#endif
- {
- printf("Python %s.\n", version);
- printf(
-"Copyright 1990, 1991, 1992, 1993 Stichting Mathematisch Centrum, Amsterdam\n");
- }
+ argv0 = argv[0];
+ realmain(argc, argv);
}
-void
-initcalls()
+char *
+getprogramname()
{
+ return argv0;
}
-void
-donecalls()
-{
-#ifdef USE_AUDIO
- asa_done();
#endif
-}
-#ifndef PYTHONPATH
+/* Return the initial python search path. This is called once from
+ initsys() to initialize sys.path.
+ The environment variable PYTHONPATH is fetched and the default path
+ appended. (The Mac has no environment variables, so there the
+ default path is always returned.) The default path may be passed
+ to the preprocessor; if not, a system-dependent default is used. */
+
+#ifndef PYTHONPATH
#ifdef macintosh
-/* On the Mac, the search path is a space-separated list of directories */
-#define PYTHONPATH ": :lib :demo"
+#define PYTHONPATH ": :Lib :Lib:stdwin :Demo"
#endif /* macintosh */
+#endif /* !PYTHONPATH */
-#ifdef unix
-#define PYTHONPATH ".:/usr/local/lib/python"
-#endif /* unix */
-
-#ifdef MSDOS
-/* In MS-DOS, the delimiter is a semicolon */
+#ifndef PYTHONPATH
+#if defined(MSDOS) || defined(NT)
#define PYTHONPATH ".;..\\lib;\\python\\lib"
-#endif /* MSDOS */
+#endif /* MSDOS || NT */
+#endif /* !PYTHONPATH */
#ifndef PYTHONPATH
-ERROR; ERROR; On what kind of system are you?;
-#endif
-
+#define PYTHONPATH ".:/usr/local/lib/python"
#endif /* !PYTHONPATH */
extern char *getenv();
@@ -163,335 +121,31 @@ getpythonpath()
/* Table of built-in modules.
- These are initialized when first imported. */
+ These are initialized when first imported.
+ Note: selection of optional extensions is now generally done by the
+ makesetup script. */
-/* Standard modules */
+/* -- ADDMODULE MARKER 1 -- */
-#ifdef USE_AL
-extern void inital();
-#endif
-#ifdef USE_AMOEBA
-extern void initamoeba();
-#endif
-#ifdef USE_AUDIO
-extern void initaudio();
-#endif
-#ifdef USE_AUDIOOP
-extern void initaudioop();
-#endif
-#ifdef USE_CD
-extern void initcd();
-#endif
-#ifdef USE_CL
-extern void initcl();
-#endif
-#ifdef USE_DBM
-extern void initdbm();
-#endif
-#ifdef USE_FCNTL
-extern void initfcntl();
-#endif
-#ifdef USE_FL
-extern void initfl();
-#endif
-#ifdef USE_FM
-extern void initfm();
-#endif
-#ifdef USE_GL
-extern void initgl();
-#endif
-#ifdef USE_GRP
-extern void initgrp();
-#endif
-#ifdef USE_IMGFILE
-extern void initimgfile();
-#endif
-#ifdef USE_JPEG
-extern void initjpeg();
-#endif
-#ifdef USE_MAC
-extern void initmac();
-#endif
-#ifdef USE_MARSHAL
extern void initmarshal();
-#endif
-#ifdef USE_MATH
-extern void initmath();
-#endif
-#ifdef USE_NIS
-extern void initnis();
-#endif
-#ifdef USE_PANEL
-extern void initpanel();
-#endif
-#ifdef USE_POSIX
-extern void initposix();
-#endif
-#ifdef USE_PWD
-extern void initpwd();
-#endif
-#ifdef USE_REGEX
-extern void initregex();
-#endif
-#ifdef USE_ROTOR
-extern void initrotor();
-#endif
-#ifdef USE_SELECT
-extern void initselect();
-#endif
-#ifdef USE_SGI
-extern void initsgi();
-#endif
-#ifdef USE_SOCKET
-extern void initsocket();
-#endif
-#ifdef USE_STDWIN
-extern void initstdwin();
-#endif
-#ifdef USE_STROP
-extern void initstrop();
-#endif
-#ifdef USE_STRUCT
-extern void initstruct();
-#endif
-#ifdef USE_SUNAUDIODEV
-extern void initsunaudiodev();
-#endif
-#ifdef USE_THREAD
-extern void initthread();
-#endif
-#ifdef USE_SV
-extern void initsv();
-#endif
-#ifdef USE_TIME
-extern void inittime();
-#endif
-#ifdef USE_IMAGEOP
-extern void initimageop();
-#endif
-#ifdef USE_MPZ
-extern void initmpz();
-#endif
-#ifdef USE_MD5
-extern void initmd5();
-#endif
-#ifdef USE_ARRAY
-extern void initarray();
-#endif
-#ifdef USE_XT
-extern void initXt();
-#endif
-#ifdef USE_XAW
-extern void initXaw();
-#endif
-#ifdef USE_XM
-extern void initXm();
-#endif
-#ifdef USE_GLX
-extern void initGlx();
-#endif
-#ifdef USE_HTML
-extern void initHTML();
-#endif
-#ifdef USE_XLIB
-extern void initXlib();
-#endif
-#ifdef USE_PARSER
-extern void initparser();
-#endif
-#ifdef USE_RGBIMG
-extern void initrgbimg();
-#endif
-/* -- ADDMODULE MARKER 1 -- */
struct {
char *name;
void (*initfunc)();
} inittab[] = {
-#ifdef USE_AL
- {"al", inital},
-#endif
-
-#ifdef USE_AMOEBA
- {"amoeba", initamoeba},
-#endif
-
-#ifdef USE_AUDIO
- {"audio", initaudio},
-#endif
-
-#ifdef USE_AUDIOOP
- {"audioop", initaudioop},
-#endif
-
-#ifdef USE_CD
- {"cd", initcd},
-#endif
-
-#ifdef USE_CL
- {"cl", initcl},
-#endif
-
-#ifdef USE_DBM
- {"dbm", initdbm},
-#endif
-
-#ifdef USE_FCNTL
- {"fcntl", initfcntl},
-#endif
-
-#ifdef USE_FL
- {"fl", initfl},
-#endif
-
-#ifdef USE_FM
- {"fm", initfm},
-#endif
-
-#ifdef USE_GL
- {"gl", initgl},
-#endif
-
-#ifdef USE_GRP
- {"grp", initgrp},
-#endif
-
-#ifdef USE_IMGFILE
- {"imgfile", initimgfile},
-#endif
-
-#ifdef USE_JPEG
- {"jpeg", initjpeg},
-#endif
-
-#ifdef USE_MAC
- {"mac", initmac},
-#endif
-
-#ifdef USE_MARSHAL
- {"marshal", initmarshal},
-#endif
-
-#ifdef USE_MATH
- {"math", initmath},
-#endif
-
-#ifdef USE_NIS
- {"nis", initnis},
-#endif
-
-#ifdef USE_PANEL
- {"pnl", initpanel},
-#endif
-
-#ifdef USE_POSIX
- {"posix", initposix},
-#endif
-
-#ifdef USE_PWD
- {"pwd", initpwd},
-#endif
-
-#ifdef USE_REGEX
- {"regex", initregex},
-#endif
-
-#ifdef USE_ROTOR
- {"rotor", initrotor},
-#endif
-
-#ifdef USE_SELECT
- {"select", initselect},
-#endif
-
-#ifdef USE_SGI
- {"sgi", initsgi},
-#endif
-
-#ifdef USE_SOCKET
- {"socket", initsocket},
-#endif
-
-#ifdef USE_STDWIN
- {"stdwin", initstdwin},
-#endif
-
-#ifdef USE_STROP
- {"strop", initstrop},
-#endif
-
-#ifdef USE_STRUCT
- {"struct", initstruct},
-#endif
-
-#ifdef USE_SUNAUDIODEV
- {"sunaudiodev", initsunaudiodev},
-#endif
-
-#ifdef USE_SV
- {"sv", initsv},
-#endif
-
-#ifdef USE_THREAD
- {"thread", initthread},
-#endif
-
-#ifdef USE_TIME
- {"time", inittime},
-#endif
-
-#ifdef USE_IMAGEOP
- {"imageop", initimageop},
-#endif
-
-#ifdef USE_MPZ
- {"mpz", initmpz},
-#endif
-
-#ifdef USE_MD5
- {"md5", initmd5},
-#endif
-
-#ifdef USE_ARRAY
- {"array", initarray},
-#endif
-
-#ifdef USE_XT
- {"Xt", initXt},
-#endif
-
-#ifdef USE_XAW
- {"Xaw", initXaw},
-#endif
-
-#ifdef USE_XM
- {"Xm", initXm},
-#endif
-
-#ifdef USE_GLX
- {"Glx", initGlx},
-#endif
-
-#ifdef USE_HTML
- {"HTML", initHTML},
-#endif
-
-#ifdef USE_XLIB
- {"Xlib", initXlib},
-#endif
+/* -- ADDMODULE MARKER 2 -- */
-#ifdef USE_PARSER
- {"parser", initparser},
-#endif
+ /* This module "lives in" with marshal.c */
+ {"marshal", initmarshal},
-#ifdef USE_RGBIMG
- {"rgbimg", initrgbimg},
-#endif
-
-/* -- ADDMODULE MARKER 2 -- */
+ /* These entries are here for sys.builtin_module_names */
+ {"__main__", NULL},
+ {"__builtin__", NULL},
+ {"sys", NULL},
- {0, 0} /* Sentinel */
+ /* Sentinel */
+ {0, 0}
};
#ifdef USE_FROZEN
diff --git a/Modules/cstubs b/Modules/cstubs
index b365f33f16..848102459f 100644
--- a/Modules/cstubs
+++ b/Modules/cstubs
@@ -1,3 +1,27 @@
+/***********************************************************
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
+Amsterdam, The Netherlands.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Stichting Mathematisch
+Centrum or CWI not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+
+STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
+FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+******************************************************************/
+
/*
Input used to generate the Python module "glmodule.c".
The stub generator is a Python script called "cgen.py".
diff --git a/Modules/dbmmodule.c b/Modules/dbmmodule.c
index 0f368d202f..b484917812 100644
--- a/Modules/dbmmodule.c
+++ b/Modules/dbmmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -39,7 +39,7 @@ typedef struct {
DBM *di_dbm;
} dbmobject;
-extern typeobject Dbmtype; /* Really forward */
+staticforward typeobject Dbmtype;
#define is_dbmobject(v) ((v)->ob_type == &Dbmtype)
@@ -131,6 +131,7 @@ dbm_ass_sub(dp, v, w)
dp->di_size = -1;
if (w == NULL) {
if ( dbm_delete(dp->di_dbm, krec) < 0 ) {
+ dbm_clearerr(dp->di_dbm);
err_setstr(KeyError, GETSTRINGVALUE((stringobject *)v));
return -1;
}
@@ -141,6 +142,7 @@ dbm_ass_sub(dp, v, w)
return -1;
}
if ( dbm_store(dp->di_dbm, krec, drec, DBM_REPLACE) < 0 ) {
+ dbm_clearerr(dp->di_dbm);
err_setstr(DbmError, "Cannot add item to database");
return -1;
}
@@ -154,9 +156,9 @@ dbm_ass_sub(dp, v, w)
}
static mapping_methods dbm_as_mapping = {
- dbm_length, /*mp_length*/
- dbm_subscript, /*mp_subscript*/
- dbm_ass_sub, /*mp_ass_subscript*/
+ (inquiry)dbm_length, /*mp_length*/
+ (binaryfunc)dbm_subscript, /*mp_subscript*/
+ (objobjargproc)dbm_ass_sub, /*mp_ass_subscript*/
};
static object *
@@ -201,8 +203,8 @@ dbm_has_key(dp, args)
}
static struct methodlist dbm_methods[] = {
- {"keys", dbm_keys},
- {"has_key", dbm_has_key},
+ {"keys", (method)dbm_keys},
+ {"has_key", (method)dbm_has_key},
{NULL, NULL} /* sentinel */
};
@@ -214,20 +216,20 @@ dbm_getattr(dp, name)
return findmethod(dbm_methods, (object *)dp, name);
}
-typeobject Dbmtype = {
+static typeobject Dbmtype = {
OB_HEAD_INIT(&Typetype)
0,
"Dbm_dictionary",
sizeof(dbmobject),
0,
- dbm_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- dbm_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
+ (destructor)dbm_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)dbm_getattr, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
&dbm_as_mapping, /*tp_as_mapping*/
};
@@ -258,7 +260,7 @@ dbmopen(self, args)
}
static struct methodlist dbmmodule_methods[] = {
- { "open", dbmopen },
+ { "open", (method)dbmopen },
{ 0, 0 },
};
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c
index 7862b06204..0c6b4f0730 100644
--- a/Modules/fcntlmodule.c
+++ b/Modules/fcntlmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
diff --git a/Modules/flmodule.c b/Modules/flmodule.c
index ce228617f3..ab23b47347 100644
--- a/Modules/flmodule.c
+++ b/Modules/flmodule.c
@@ -1,5 +1,5 @@
/**********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -56,7 +56,7 @@ typedef struct {
object *ob_callback_arg;
} genericobject;
-extern typeobject GenericObjecttype; /* Forward */
+staticforward typeobject GenericObjecttype;
#define is_genericobject(g) ((g)->ob_type == &GenericObjecttype)
@@ -298,16 +298,16 @@ generic_set_object_shortcut(g, args)
}
static struct methodlist generic_methods[] = {
- {"set_call_back", generic_set_call_back},
- {"delete_object", generic_delete_object},
- {"show_object", generic_show_object},
- {"hide_object", generic_hide_object},
- {"redraw_object", generic_redraw_object},
- {"freeze_object", generic_freeze_object},
- {"unfreeze_object", generic_unfreeze_object},
- {"activate_object", generic_activate_object},
- {"deactivate_object", generic_deactivate_object},
- {"set_object_shortcut", generic_set_object_shortcut},
+ {"set_call_back", (method)generic_set_call_back},
+ {"delete_object", (method)generic_delete_object},
+ {"show_object", (method)generic_show_object},
+ {"hide_object", (method)generic_hide_object},
+ {"redraw_object", (method)generic_redraw_object},
+ {"freeze_object", (method)generic_freeze_object},
+ {"unfreeze_object", (method)generic_unfreeze_object},
+ {"activate_object", (method)generic_activate_object},
+ {"deactivate_object", (method)generic_deactivate_object},
+ {"set_object_shortcut", (method)generic_set_object_shortcut},
{NULL, NULL} /* sentinel */
};
@@ -424,19 +424,19 @@ generic_repr(g)
return newstringobject(buf);
}
-typeobject GenericObjecttype = {
+static typeobject GenericObjecttype = {
OB_HEAD_INIT(&Typetype)
- 0, /*ob_size*/
- "FORMS_object", /*tp_name*/
- sizeof(genericobject), /*tp_size*/
- 0, /*tp_itemsize*/
+ 0, /*ob_size*/
+ "FORMS_object", /*tp_name*/
+ sizeof(genericobject), /*tp_size*/
+ 0, /*tp_itemsize*/
/* methods */
- generic_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- generic_getattr, /*tp_getattr*/
- generic_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- generic_repr, /*tp_repr*/
+ (destructor)generic_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)generic_getattr, /*tp_getattr*/
+ (setattrfunc)generic_setattr, /*tp_setattr*/
+ 0, /*tp_compare*/
+ (reprfunc)generic_repr, /*tp_repr*/
};
static object *
@@ -837,24 +837,24 @@ set_browser_specialkey (g, args)
}
static struct methodlist browser_methods[] = {
- {"set_browser_topline", set_browser_topline},
- {"clear_browser", clear_browser},
- {"add_browser_line", add_browser_line},
- {"addto_browser", addto_browser},
- {"insert_browser_line", insert_browser_line},
- {"delete_browser_line", delete_browser_line},
- {"replace_browser_line", replace_browser_line},
- {"get_browser_line", get_browser_line},
- {"load_browser", load_browser},
- {"get_browser_maxline", get_browser_maxline},
- {"select_browser_line", select_browser_line},
- {"deselect_browser_line", deselect_browser_line},
- {"deselect_browser", deselect_browser},
- {"isselected_browser_line", isselected_browser_line},
- {"get_browser", get_browser},
- {"set_browser_fontsize", set_browser_fontsize},
- {"set_browser_fontstyle", set_browser_fontstyle},
- {"set_browser_specialkey", set_browser_specialkey},
+ {"set_browser_topline", (method)set_browser_topline},
+ {"clear_browser", (method)clear_browser},
+ {"add_browser_line", (method)add_browser_line},
+ {"addto_browser", (method)addto_browser},
+ {"insert_browser_line", (method)insert_browser_line},
+ {"delete_browser_line", (method)delete_browser_line},
+ {"replace_browser_line", (method)replace_browser_line},
+ {"get_browser_line", (method)get_browser_line},
+ {"load_browser", (method)load_browser},
+ {"get_browser_maxline", (method)get_browser_maxline},
+ {"select_browser_line", (method)select_browser_line},
+ {"deselect_browser_line", (method)deselect_browser_line},
+ {"deselect_browser", (method)deselect_browser},
+ {"isselected_browser_line", (method)isselected_browser_line},
+ {"get_browser", (method)get_browser},
+ {"set_browser_fontsize", (method)set_browser_fontsize},
+ {"set_browser_fontstyle", (method)set_browser_fontstyle},
+ {"set_browser_specialkey", (method)set_browser_specialkey},
{NULL, NULL} /* sentinel */
};
@@ -893,10 +893,10 @@ set_button_shortcut(g, args)
}
static struct methodlist button_methods[] = {
- {"set_button", set_button},
- {"get_button", get_button},
- {"get_button_numb", get_button_numb},
- {"set_button_shortcut", set_button_shortcut},
+ {"set_button", (method)set_button},
+ {"get_button", (method)get_button},
+ {"get_button_numb", (method)get_button_numb},
+ {"set_button_shortcut", (method)set_button_shortcut},
{NULL, NULL} /* sentinel */
};
@@ -975,15 +975,15 @@ set_choice_fontstyle (g, args)
}
static struct methodlist choice_methods[] = {
- {"set_choice", set_choice},
- {"get_choice", get_choice},
- {"clear_choice", clear_choice},
- {"addto_choice", addto_choice},
- {"replace_choice", replace_choice},
- {"delete_choice", delete_choice},
- {"get_choice_text", get_choice_text},
- {"set_choice_fontsize", set_choice_fontsize},
- {"set_choice_fontstyle",set_choice_fontstyle},
+ {"set_choice", (method)set_choice},
+ {"get_choice", (method)get_choice},
+ {"clear_choice", (method)clear_choice},
+ {"addto_choice", (method)addto_choice},
+ {"replace_choice", (method)replace_choice},
+ {"delete_choice", (method)delete_choice},
+ {"get_choice_text", (method)get_choice_text},
+ {"set_choice_fontsize", (method)set_choice_fontsize},
+ {"set_choice_fontstyle",(method)set_choice_fontstyle},
{NULL, NULL} /* sentinel */
};
@@ -1005,7 +1005,7 @@ get_clock(g, args)
}
static struct methodlist clock_methods[] = {
- {"get_clock", get_clock},
+ {"get_clock", (method)get_clock},
{NULL, NULL} /* sentinel */
};
@@ -1060,12 +1060,12 @@ set_counter_return (g, args)
}
static struct methodlist counter_methods[] = {
- {"set_counter_value", set_counter_value},
- {"get_counter_value", get_counter_value},
- {"set_counter_bounds", set_counter_bounds},
- {"set_counter_step", set_counter_step},
- {"set_counter_precision", set_counter_precision},
- {"set_counter_return", set_counter_return},
+ {"set_counter_value", (method)set_counter_value},
+ {"get_counter_value", (method)get_counter_value},
+ {"set_counter_bounds", (method)set_counter_bounds},
+ {"set_counter_step", (method)set_counter_step},
+ {"set_counter_precision", (method)set_counter_precision},
+ {"set_counter_return", (method)set_counter_return},
{NULL, NULL} /* sentinel */
};
@@ -1113,11 +1113,11 @@ set_dial_step (g, args)
}
static struct methodlist dial_methods[] = {
- {"set_dial_value", set_dial_value},
- {"get_dial_value", get_dial_value},
- {"set_dial_bounds", set_dial_bounds},
- {"get_dial_bounds", get_dial_bounds},
- {"set_dial_step", set_dial_step},
+ {"set_dial_value", (method)set_dial_value},
+ {"get_dial_value", (method)get_dial_value},
+ {"set_dial_bounds", (method)set_dial_bounds},
+ {"get_dial_bounds", (method)get_dial_bounds},
+ {"set_dial_step", (method)set_dial_step},
{NULL, NULL} /* sentinel */
};
@@ -1156,10 +1156,10 @@ set_input_return (g, args)
}
static struct methodlist input_methods[] = {
- {"set_input", set_input},
- {"get_input", get_input},
- {"set_input_color", set_input_color},
- {"set_input_return", set_input_return},
+ {"set_input", (method)set_input},
+ {"get_input", (method)get_input},
+ {"set_input_color", (method)set_input_color},
+ {"set_input_return", (method)set_input_return},
{NULL, NULL} /* sentinel */
};
@@ -1201,10 +1201,10 @@ addto_menu (g, args)
}
static struct methodlist menu_methods[] = {
- {"set_menu", set_menu},
- {"get_menu", get_menu},
- {"get_menu_text", get_menu_text},
- {"addto_menu", addto_menu},
+ {"set_menu", (method)set_menu},
+ {"get_menu", (method)get_menu},
+ {"get_menu_text", (method)get_menu_text},
+ {"addto_menu", (method)addto_menu},
{NULL, NULL} /* sentinel */
};
@@ -1277,14 +1277,14 @@ set_slider_step (g, args)
static struct methodlist slider_methods[] = {
- {"set_slider_value", set_slider_value},
- {"get_slider_value", get_slider_value},
- {"set_slider_bounds", set_slider_bounds},
- {"get_slider_bounds", get_slider_bounds},
- {"set_slider_return", set_slider_return},
- {"set_slider_size", set_slider_size},
- {"set_slider_precision",set_slider_precision},
- {"set_slider_step", set_slider_step},
+ {"set_slider_value", (method)set_slider_value},
+ {"get_slider_value", (method)get_slider_value},
+ {"set_slider_bounds", (method)set_slider_bounds},
+ {"get_slider_bounds", (method)get_slider_bounds},
+ {"set_slider_return", (method)set_slider_return},
+ {"set_slider_size", (method)set_slider_size},
+ {"set_slider_precision",(method)set_slider_precision},
+ {"set_slider_step", (method)set_slider_step},
{NULL, NULL} /* sentinel */
};
@@ -1357,14 +1357,14 @@ get_positioner_ybounds (g, args)
}
static struct methodlist positioner_methods[] = {
- {"set_positioner_xvalue", set_positioner_xvalue},
- {"set_positioner_yvalue", set_positioner_yvalue},
- {"set_positioner_xbounds", set_positioner_xbounds},
- {"set_positioner_ybounds", set_positioner_ybounds},
- {"get_positioner_xvalue", get_positioner_xvalue},
- {"get_positioner_yvalue", get_positioner_yvalue},
- {"get_positioner_xbounds", get_positioner_xbounds},
- {"get_positioner_ybounds", get_positioner_ybounds},
+ {"set_positioner_xvalue", (method)set_positioner_xvalue},
+ {"set_positioner_yvalue", (method)set_positioner_yvalue},
+ {"set_positioner_xbounds", (method)set_positioner_xbounds},
+ {"set_positioner_ybounds", (method)set_positioner_ybounds},
+ {"get_positioner_xvalue", (method)get_positioner_xvalue},
+ {"get_positioner_yvalue", (method)get_positioner_yvalue},
+ {"get_positioner_xbounds", (method)get_positioner_xbounds},
+ {"get_positioner_ybounds", (method)get_positioner_ybounds},
{NULL, NULL} /* sentinel */
};
@@ -1387,8 +1387,8 @@ get_timer (g, args)
}
static struct methodlist timer_methods[] = {
- {"set_timer", set_timer},
- {"get_timer", get_timer},
+ {"set_timer", (method)set_timer},
+ {"get_timer", (method)get_timer},
{NULL, NULL} /* sentinel */
};
@@ -1399,7 +1399,7 @@ typedef struct {
FL_FORM *ob_form;
} formobject;
-extern typeobject Formtype; /* Forward */
+staticforward typeobject Formtype;
#define is_formobject(v) ((v)->ob_type == &Formtype)
@@ -1813,40 +1813,40 @@ form_set_object_focus(f, args)
static struct methodlist form_methods[] = {
/* adm */
- {"show_form", form_show_form},
- {"hide_form", form_hide_form},
- {"redraw_form", form_redraw_form},
- {"set_form_position", form_set_form_position},
- {"set_form_size", form_set_form_size},
- {"scale_form", form_scale_form},
- {"freeze_form", form_freeze_form},
- {"unfreeze_form", form_unfreeze_form},
- {"activate_form", form_activate_form},
- {"deactivate_form", form_deactivate_form},
- {"bgn_group", form_bgn_group},
- {"end_group", form_end_group},
- {"find_first", form_find_first},
- {"find_last", form_find_last},
- {"set_object_focus", form_set_object_focus},
+ {"show_form", (method)form_show_form},
+ {"hide_form", (method)form_hide_form},
+ {"redraw_form", (method)form_redraw_form},
+ {"set_form_position", (method)form_set_form_position},
+ {"set_form_size", (method)form_set_form_size},
+ {"scale_form", (method)form_scale_form},
+ {"freeze_form", (method)form_freeze_form},
+ {"unfreeze_form", (method)form_unfreeze_form},
+ {"activate_form", (method)form_activate_form},
+ {"deactivate_form", (method)form_deactivate_form},
+ {"bgn_group", (method)form_bgn_group},
+ {"end_group", (method)form_end_group},
+ {"find_first", (method)form_find_first},
+ {"find_last", (method)form_find_last},
+ {"set_object_focus", (method)form_set_object_focus},
/* basic objects */
- {"add_button", form_add_button},
-/* {"add_bitmap", form_add_bitmap}, */
- {"add_lightbutton", form_add_lightbutton},
- {"add_roundbutton", form_add_roundbutton},
- {"add_menu", form_add_menu},
- {"add_slider", form_add_slider},
- {"add_positioner", form_add_positioner},
- {"add_valslider", form_add_valslider},
- {"add_dial", form_add_dial},
- {"add_counter", form_add_counter},
- {"add_box", form_add_box},
- {"add_clock", form_add_clock},
- {"add_choice", form_add_choice},
- {"add_browser", form_add_browser},
- {"add_input", form_add_input},
- {"add_timer", form_add_timer},
- {"add_text", form_add_text},
+ {"add_button", (method)form_add_button},
+/* {"add_bitmap", (method)form_add_bitmap}, */
+ {"add_lightbutton", (method)form_add_lightbutton},
+ {"add_roundbutton", (method)form_add_roundbutton},
+ {"add_menu", (method)form_add_menu},
+ {"add_slider", (method)form_add_slider},
+ {"add_positioner", (method)form_add_positioner},
+ {"add_valslider", (method)form_add_valslider},
+ {"add_dial", (method)form_add_dial},
+ {"add_counter", (method)form_add_counter},
+ {"add_box", (method)form_add_box},
+ {"add_clock", (method)form_add_clock},
+ {"add_choice", (method)form_add_choice},
+ {"add_browser", (method)form_add_browser},
+ {"add_input", (method)form_add_input},
+ {"add_timer", (method)form_add_timer},
+ {"add_text", (method)form_add_text},
{NULL, NULL} /* sentinel */
};
@@ -1918,19 +1918,19 @@ form_repr(f)
return newstringobject(buf);
}
-typeobject Formtype = {
+static typeobject Formtype = {
OB_HEAD_INIT(&Typetype)
- 0, /*ob_size*/
- "FORMS_form", /*tp_name*/
- sizeof(formobject), /*tp_size*/
- 0, /*tp_itemsize*/
+ 0, /*ob_size*/
+ "FORMS_form", /*tp_name*/
+ sizeof(formobject), /*tp_size*/
+ 0, /*tp_itemsize*/
/* methods */
- form_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- form_getattr, /*tp_getattr*/
- form_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- form_repr, /*tp_repr*/
+ (destructor)form_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)form_getattr, /*tp_getattr*/
+ (setattrfunc)form_setattr, /*tp_setattr*/
+ 0, /*tp_compare*/
+ (reprfunc)form_repr, /*tp_repr*/
};
static object *
diff --git a/Modules/fmmodule.c b/Modules/fmmodule.c
index aa49be36a2..4875d9a2d5 100644
--- a/Modules/fmmodule.c
+++ b/Modules/fmmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -40,7 +40,7 @@ typedef struct {
fmfonthandle fh_fh;
} fhobject;
-extern typeobject Fhtype; /* Really static, forward */
+staticforward typeobject Fhtype;
#define is_fhobject(v) ((v)->ob_type == &Fhtype)
@@ -166,15 +166,15 @@ fh_getstrwidth(self, args)
}
static struct methodlist fh_methods[] = {
- {"scalefont", fh_scalefont},
- {"setfont", fh_setfont},
- {"getfontname", fh_getfontname},
- {"getcomment", fh_getcomment},
- {"getfontinfo", fh_getfontinfo},
+ {"scalefont", (method)fh_scalefont},
+ {"setfont", (method)fh_setfont},
+ {"getfontname", (method)fh_getfontname},
+ {"getcomment", (method)fh_getcomment},
+ {"getfontinfo", (method)fh_getfontinfo},
#if 0
- {"getwholemetrics", fh_getwholemetrics},
+ {"getwholemetrics", (method)fh_getwholemetrics},
#endif
- {"getstrwidth", fh_getstrwidth},
+ {"getstrwidth", (method)fh_getstrwidth},
{NULL, NULL} /* sentinel */
};
@@ -196,17 +196,17 @@ fh_dealloc(fhp)
static typeobject Fhtype = {
OB_HEAD_INIT(&Typetype)
- 0, /*ob_size*/
- "font handle", /*tp_name*/
- sizeof(fhobject), /*tp_size*/
- 0, /*tp_itemsize*/
+ 0, /*ob_size*/
+ "font handle", /*tp_name*/
+ sizeof(fhobject), /*tp_size*/
+ 0, /*tp_itemsize*/
/* methods */
- fh_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- fh_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
+ (destructor)fh_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)fh_getattr, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
};
diff --git a/Modules/imageop.c b/Modules/imageop.c
index 841ec1b2b4..57cb90b7e7 100644
--- a/Modules/imageop.c
+++ b/Modules/imageop.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -161,7 +161,7 @@ imageop_tovideo(self, args)
for (y=1; y<maxy; y++) { /* Interpolate other lines */
for(x=0; x<maxx; x++) {
i = y*maxx + x;
- *ncp++ = (cp[i] + cp[i-maxx]) >> 1;
+ *ncp++ = ((int)cp[i] + (int)cp[i-maxx]) >> 1;
}
}
} else {
@@ -171,11 +171,11 @@ imageop_tovideo(self, args)
for(x=0; x<maxx; x++) {
i = (y*maxx + x)*4 + 1;
*ncp++ = 0; /* Skip alfa comp */
- *ncp++ = (cp[i] + cp[i-4*maxx]) >> 1;
+ *ncp++ = ((int)cp[i] + (int)cp[i-4*maxx]) >> 1;
i++;
- *ncp++ = (cp[i] + cp[i-4*maxx]) >> 1;
+ *ncp++ = ((int)cp[i] + (int)cp[i-4*maxx]) >> 1;
i++;
- *ncp++ = (cp[i] + cp[i-4*maxx]) >> 1;
+ *ncp++ = ((int)cp[i] + (int)cp[i-4*maxx]) >> 1;
}
}
}
@@ -210,7 +210,7 @@ imageop_grey2mono(self, args)
bit = 0x80;
ovalue = 0;
for ( i=0; i < len; i++ ) {
- if ( cp[i] > tres )
+ if ( (int)cp[i] > tres )
ovalue |= bit;
bit >>= 1;
if ( bit == 0 ) {
@@ -252,7 +252,7 @@ imageop_grey2grey4(self, args)
pos = 0;
ovalue = 0;
for ( i=0; i < len; i++ ) {
- ovalue |= (cp[i] & 0xf0) >> pos;
+ ovalue |= ((int)cp[i] & 0xf0) >> pos;
pos += 4;
if ( pos == 8 ) {
*ncp++ = ovalue;
@@ -293,7 +293,7 @@ imageop_grey2grey2(self, args)
pos = 0;
ovalue = 0;
for ( i=0; i < len; i++ ) {
- ovalue |= (cp[i] & 0xc0) >> pos;
+ ovalue |= ((int)cp[i] & 0xc0) >> pos;
pos += 2;
if ( pos == 8 ) {
*ncp++ = ovalue;
diff --git a/Modules/imgfile.c b/Modules/imgfile.c
index e57d6c4052..7163d72274 100644
--- a/Modules/imgfile.c
+++ b/Modules/imgfile.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
diff --git a/Modules/makesetup b/Modules/makesetup
index b5cc57bb9c..69159f7989 100755
--- a/Modules/makesetup
+++ b/Modules/makesetup
@@ -1,24 +1,103 @@
#! /bin/sh
-# This script converts Makefile.in.in and config.c.in into Makefile.in
-# and config.c, based on the module definitions found in the file
-# Setup.
+# Convert templates into Makefile and config.c, based on the module
+# definitions found in the file Setup.
+#
+# Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-n [Setup] ...]
+#
+# Options:
+# -s directory: alternative source directory (default derived from $0)
+# -c file: alternative config.c template (default $srcdir/config.c.in)
+# -c -: don't write config.c
+# -m file: alternative Makefile template (default ./Makefile.pre)
+# -m -: don't write Makefile
+#
+# Remaining arguments are one or more Setup files (default ./Setup).
+# Setup files after a -n option are used for their variables, modules
+# and libraries but not for their .o files.
+#
+# See Setup.in for a description of the format of the Setup file.
+#
+# The following edits are made:
+#
+# Copying config.c.in to config.c:
+# - insert an identifying comment at the start
+# - for each <module> mentioned in Setup:
+# + insert 'extern void init<module>();' before MARKER 1
+# + insert '{"<module>", initmodule},' before MARKER 2
+#
+# Copying Makefile.pre to Makefile:
+# - insert an identifying comment at the start
+# - replace @MODOBJS@ by the list of objects from Setup (except for
+# Setup files after a -n option)
+# - replace @MODLIBS@ by the list of libraries from Setup
+# - for each object file mentioned in Setup, insert a rule
+# '<file>.o: <file>.c; <build commands>' before the comment
+# 'Rules added by makesetup'
+# - for each variable definition found in Setup, insert the definition
+# before the comment 'Definitions added by makesetup'
+# Loop over command line options
+usage='
+usage: makesetup [-s srcdir] [-c config.c.in] [-m Makefile.pre]
+ [Setup] ... [-n [Setup] ...]'
+srcdir=''
+config=''
+makepre=''
+noobjects=''
+while :
+do
+ case $1 in
+ -s) shift; srcdir=$1; shift;;
+ -c) shift; config=$1; shift;;
+ -m) shift; makepre=$1; shift;;
+ --) shift; break;;
+ -n) noobjects=yes;;
+ -*) echo "$usage" 1>&2; exit 2;;
+ *) break;;
+ esac
+done
+
+# Set default srcdir and config if not set by command line
+# (Not all systems have dirname)
+case $srcdir in
+'') case $0 in
+ */*) srcdir=`echo $0 | sed 's,/[^/]*$,,'`;;
+ *) srcdir=.;;
+ esac;;
+esac
+case $config in
+'') config=$srcdir/config.c.in;;
+esac
+case $makepre in
+'') makepre=Makefile.pre;;
+esac
+
+# Newline for sed i and a commands
NL="\\
"
-sed -e 's/#.*//' -e '/^[ ]*$/d' ${1-Setup} |
+# Main loop
+for i in ${*-Setup}
+do
+ case $i in
+ -n) echo '<noobjects>';;
+ *) cat "$i";;
+ esac
+done |
+sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' |
(
DEFS=
MODS=
OBJS=
LIBS=
RULES=
-
while read line
do
+ # Output DEFS in reverse order so first definition overrides
case $line in
- *=*) DEFS="$DEFS$line$NL"; continue;;
+ *=*) DEFS="$line$NL$DEFS"; continue;;
+ '<noobjects>') noobjects=yes; continue;;
esac
objs=
cpps=
@@ -27,7 +106,7 @@ sed -e 's/#.*//' -e '/^[ ]*$/d' ${1-Setup} |
do
case $arg in
-[IDUC]*) cpps="$cpps $arg";;
- -[Ll]*) LIBS="$LIBS $arg";;
+ -[A-Zl]*) LIBS="$LIBS $arg";;
*.a) LIBS="$LIBS $arg";;
*.o) objs="$objs $arg";;
*.*) echo 1>&2 "bad word $arg in $line"
@@ -37,9 +116,16 @@ sed -e 's/#.*//' -e '/^[ ]*$/d' ${1-Setup} |
exit 1;;
esac
done
+ case $noobjects in
+ yes) continue;;
+ esac
for obj in $objs
do
src=`basename $obj .o`.c
+ case $src in
+ glmodule.c) ;;
+ *) src='$(srcdir)/'$src;;
+ esac
RULES="$RULES$obj: $src; \$(CC) \$(CFLAGS) $cpps -c $src$NL"
done
OBJS="$OBJS $objs"
@@ -52,20 +138,29 @@ sed -e 's/#.*//' -e '/^[ ]*$/d' ${1-Setup} |
EXTDECLS="${EXTDECLS}extern void init$mod();$NL"
INITBITS="${INITBITS} {\"$mod\", init$mod},$NL"
done
- sed -e "
- /MARKER 1/i$NL$EXTDECLS
+ case $config in
+ -) ;;
+ *) sed -e "
+ 1i$NL/* Generated automatically from $config by makesetup. */
+ /MARKER 1/i$NL$EXTDECLS
/MARKER 2/i$NL$INITBITS
- " config.c.in >config.c
+ " $config >config.c
+ ;;
+ esac
- sed -e "
+ case $makepre in
+ -) ;;
+ *) sed -e "
+ 1i$NL# Generated automatically from $makepre by makesetup.
s%@MODOBJS@%$OBJS%
s%@MODLIBS@%$LIBS%
- /Rules added by ..makesetup/a$NL$NL$RULES
-
- /Definitions added by ..makesetup/a$NL$NL$DEFS
-
- " Makefile.in.in >Makefile.in
+ /Rules added by makesetup/a$NL$NL$RULES
+ /Definitions added by makesetup/a$NL$NL$DEFS
+
+ " $makepre >Makefile
+ ;;
+ esac
)
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 67e3cf7796..4137e60ab7 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -40,9 +40,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#undef HUGE_VAL
#endif
+#ifndef macintosh
#ifndef __STDC__
extern double fmod PROTO((double, double));
#endif
+#endif
#ifdef HUGE_VAL
#define CHECK(x) if (errno != 0) ; \
@@ -132,10 +134,14 @@ FUNC1(math_sqrt, sqrt)
FUNC1(math_tan, tan)
FUNC1(math_tanh, tanh)
+#ifndef macintosh
+
double frexp PROTO((double, int *));
double ldexp PROTO((double, int));
double modf PROTO((double, double *));
+#endif
+
static object *
math_frexp(self, args)
object *self;
@@ -180,7 +186,15 @@ math_modf(self, args)
if (!getdoublearg(args, &x))
return NULL;
errno = 0;
+#ifdef MPW /* MPW C modf expects pointer to extended as second argument */
+{
+ extended e;
+ x = modf(x, &e);
+ y = e;
+}
+#else
x = modf(x, &y);
+#endif
CHECK(x);
if (errno != 0)
return math_error();
diff --git a/Modules/md5.h b/Modules/md5.h
index 5c01861bd0..29ac5407e0 100644
--- a/Modules/md5.h
+++ b/Modules/md5.h
@@ -32,6 +32,9 @@ documentation and/or software.
The following makes PROTOTYPES default to 0 if it has not already
been defined with C compiler flags.
*/
+#ifdef HAVE_PROTOTYPES
+#define PROTOTYPES 1
+#endif
#ifndef PROTOTYPES
#define PROTOTYPES 0
#endif
diff --git a/Modules/md5c.c b/Modules/md5c.c
index ffa0f0f2ad..d7c7e4fb27 100644
--- a/Modules/md5c.c
+++ b/Modules/md5c.c
@@ -23,6 +23,9 @@ These notices must be retained in any copies of any part of this
documentation and/or software.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "md5.h"
/* Constants for MD5Transform routine.
diff --git a/Modules/md5module.c b/Modules/md5module.c
index 6230cee193..68d52f46dc 100644
--- a/Modules/md5module.c
+++ b/Modules/md5module.c
@@ -1,6 +1,6 @@
/***********************************************************
-Copyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The
-Netherlands.
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
+Amsterdam, The Netherlands.
All Rights Reserved
@@ -21,44 +21,43 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
+
/* MD5 module */
-/* This module provides an interface to a message digest algorithm,
- MD5 in this case */
+/* This module provides an interface to the RSA Data Security,
+ Inc. MD5 Message-Digest Algorithm, described in RFC 1321.
+ It requires the files md5c.c and md5.h (which are slightly changed
+ from the versions in the RFC to avoid the "global.h" file.) */
+
/* MD5 objects */
#include "allobjects.h"
-#include "modsupport.h" /* For getargs() etc. */
+#include "modsupport.h"
#include "md5.h"
+
typedef struct {
OB_HEAD
MD5_CTX md5; /* the context holder */
} md5object;
-extern typeobject MD5type; /* Really static, forward */
+staticforward typeobject MD5type;
#define is_md5object(v) ((v)->ob_type == &MD5type)
-/* #define MD5_DEBUG */
-
static md5object *
newmd5object()
{
md5object *md5p;
-
-#ifdef MD5_DEBUG
- fputs( "md5_object() called...\n", stderr );
-#endif /* def MD5_DEBUG */
md5p = NEWOBJ(md5object, &MD5type);
if (md5p == NULL)
return NULL;
MD5Init(&md5p->md5); /* actual initialisation */
return md5p;
-} /* newmd5object() */
+}
/* MD5 methods */
@@ -67,56 +66,20 @@ static void
md5_dealloc(md5p)
md5object *md5p;
{
-#ifdef MD5_DEBUG
- fputs( "md5_dealloc() called...\n", stderr );
-#endif /* def MD5_DEBUG */
-
DEL(md5p);
-} /* md5_dealloc() */
-
-
-/* MD5 initialisation */
-
-static object *
-MD5_md5(self, args)
- object *self;
- object *args;
-{
- md5object *md5p;
- char *cp = (char *)NULL;
- int len;
-
-
-#ifdef MD5_DEBUG
- fputs("MD5_md5() called...\n", stderr);
-#endif /* def MD5_DEBUG */
-
- if (!getargs(args, "")) {
- err_clear();
- if (!getargs(args, "s#", &cp, &len))
- return NULL;
- }
-
- if ((md5p = newmd5object()) == NULL)
- return NULL;
-
- if (cp)
- MD5Update(&md5p->md5, cp, len);
-
- return (object *)md5p;
-} /* MD5_md5() */
+}
/* MD5 methods-as-attributes */
+
static object *
md5_update(self, args)
md5object *self;
object *args;
{
- char *cp;
+ unsigned char *cp;
int len;
-
if (!getargs(args, "s#", &cp, &len))
return NULL;
@@ -124,9 +87,8 @@ md5_update(self, args)
INCREF(None);
return None;
-} /* md5_update() */
+}
-#define DIGESTLEN 16 /* this is used twice--walrus@umich.edu */
static object *
md5_digest(self, args)
md5object *self;
@@ -134,8 +96,7 @@ md5_digest(self, args)
{
MD5_CTX mdContext;
- char aDigest[DIGESTLEN];
-
+ unsigned char aDigest[16];
if (!getnoarg(args))
return NULL;
@@ -144,9 +105,8 @@ md5_digest(self, args)
mdContext = self->md5;
MD5Final(aDigest, &mdContext);
- return newsizedstringobject((char *)aDigest, DIGESTLEN);
-} /* md5_digest() */
-#undef DIGESTLEN
+ return newsizedstringobject((char *)aDigest, 16);
+}
static object *
md5_copy(self, args)
@@ -155,7 +115,6 @@ md5_copy(self, args)
{
md5object *md5p;
-
if (!getnoarg(args))
return NULL;
@@ -165,13 +124,12 @@ md5_copy(self, args)
md5p->md5 = self->md5;
return (object *)md5p;
-} /* md5_copy() */
+}
-
static struct methodlist md5_methods[] = {
- {"update", md5_update},
- {"digest", md5_digest},
- {"copy", md5_copy},
+ {"update", (method)md5_update},
+ {"digest", (method)md5_digest},
+ {"copy", (method)md5_copy},
{NULL, NULL} /* sentinel */
};
@@ -181,31 +139,56 @@ md5_getattr(self, name)
char *name;
{
return findmethod(md5_methods, (object *)self, name);
-} /* md5_getattr() */
+}
-#ifndef _AIX
-static
-#endif
-typeobject MD5type = {
+static typeobject MD5type = {
OB_HEAD_INIT(&Typetype)
0, /*ob_size*/
"md5", /*tp_name*/
sizeof(md5object), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- md5_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- md5_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
+ (destructor)md5_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)md5_getattr, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
};
+
+/* MD5 functions */
+
+static object *
+MD5_md5(self, args)
+ object *self;
+ object *args;
+{
+ md5object *md5p;
+ unsigned char *cp = NULL;
+ int len;
+
+ if (!getargs(args, "")) {
+ err_clear();
+ if (!getargs(args, "s#", &cp, &len))
+ return NULL;
+ }
+
+ if ((md5p = newmd5object()) == NULL)
+ return NULL;
+
+ if (cp)
+ MD5Update(&md5p->md5, cp, len);
+
+ return (object *)md5p;
+}
+
+
/* List of functions exported by this module */
static struct methodlist md5_functions[] = {
- {"md5", MD5_md5},
+ {"md5", (method)MD5_md5},
{NULL, NULL} /* Sentinel */
};
@@ -215,12 +198,5 @@ static struct methodlist md5_functions[] = {
void
initmd5()
{
-#ifdef MD5_DEBUG
- fputs( "initmd5() called...\n", stderr );
-#endif /* def MD5_DEBUG */
(void)initmodule("md5", md5_functions);
-} /* initmd5() */
-
-#ifdef MAKEDUMMYINT
-int _md5_dummy_int; /* XXX otherwise, we're .bss-less (DYNLOAD->Jack?) */
-#endif /* def MAKEDUMMYINT */
+}
diff --git a/Modules/mpzmodule.c b/Modules/mpzmodule.c
index d0b9d7f9a9..9d0bdb086b 100644
--- a/Modules/mpzmodule.c
+++ b/Modules/mpzmodule.c
@@ -1,6 +1,6 @@
/***********************************************************
-Copyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The
-Netherlands.
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
+Amsterdam, The Netherlands.
All Rights Reserved
@@ -21,6 +21,7 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
+
/* MPZ module */
/* This module provides an interface to an alternate Multi-Precision
@@ -35,6 +36,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "allobjects.h"
#include "modsupport.h" /* For getargs() etc. */
#include <assert.h>
+#include <sys/types.h> /* For size_t */
/*
** These are the cpp-flags used in this file...
@@ -89,7 +91,7 @@ typedef struct {
MP_INT mpz; /* the actual number */
} mpzobject;
-extern typeobject MPZtype; /* Really static, forward */
+staticforward typeobject MPZtype;
#define is_mpzobject(v) ((v)->ob_type == &MPZtype)
@@ -993,8 +995,10 @@ mpz_mpzcoerce(z)
err_setstr(TypeError, "number coercion (to mpzobject) failed");
return NULL;
} /* mpz_mpzcoerce() */
-
-static void mpz_divm();
+
+/* Forward */
+static void mpz_divm PROTO((MP_INT *res, const MP_INT *num,
+ const MP_INT *den, const MP_INT *mod));
static object *
MPZ_powm(self, args)
@@ -1546,7 +1550,7 @@ static struct methodlist mpz_methods[] = {
{"hex", mpz_hex},
{"oct", mpz_oct},
#endif /* def MPZ_CONVERSIONS_AS_METHODS */
- {"binary", (object * (*) (object *, object *)) mpz_binary},
+ {"binary", (object *(*)(object *, object *))mpz_binary},
{NULL, NULL} /* sentinel */
};
@@ -1601,9 +1605,10 @@ mpz_repr(v)
-#define UF (object* (*) FPROTO((object *))) /* Unary function */
-#define BF (object* (*) FPROTO((object *, object *))) /* Binary function */
-#define IF (int (*) FPROTO((object *))) /* Int function */
+#define UF (unaryfunc)
+#define BF (binaryfunc)
+#define IF (inquiry)
+#define CF (coercion)
static number_methods mpz_as_number = {
BF mpz_addition, /*nb_add*/
@@ -1623,8 +1628,7 @@ static number_methods mpz_as_number = {
BF mpz_andfunc, /*nb_and*/
BF mpz_xorfunc, /*nb_xor*/
BF mpz_orfunc, /*nb_or*/
- (int (*) FPROTO((object **, object **)))
- mpz_coerce, /*nb_coerce*/
+ CF mpz_coerce, /*nb_coerce*/
#ifndef MPZ_CONVERSIONS_AS_METHODS
UF mpz_int, /*nb_int*/
UF mpz_long, /*nb_long*/
@@ -1641,13 +1645,13 @@ static typeobject MPZtype = {
sizeof(mpzobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- (void (*) (object *)) mpz_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- (object * (*)(object *, char *)) mpz_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- (int (*) (object *, object *)) mpz_compare, /*tp_compare*/
- mpz_repr, /*tp_repr*/
- &mpz_as_number, /*tp_as_number*/
+ (destructor)mpz_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)mpz_getattr, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ (cmpfunc)mpz_compare, /*tp_compare*/
+ (reprfunc)mpz_repr, /*tp_repr*/
+ &mpz_as_number, /*tp_as_number*/
};
/* List of functions exported by this module */
diff --git a/Modules/nismodule.c b/Modules/nismodule.c
index 5db26f4fec..00c35616bf 100644
--- a/Modules/nismodule.c
+++ b/Modules/nismodule.c
@@ -57,6 +57,8 @@ nis_mapname (map)
return map;
}
+typedef int (*foreachfunc) PROTO((int, char *, int, char *, int, char *));
+
static int
nis_foreach (instatus, inkey, inkeylen, inval, invallen, indata)
int instatus;
@@ -134,7 +136,7 @@ nis_cat (self, args)
cat = newdictobject ();
if (cat == NULL)
return NULL;
- cb.foreach = nis_foreach;
+ cb.foreach = (foreachfunc)nis_foreach;
cb.data = (char *)cat;
BGN_SAVE
map = nis_mapname (map);
@@ -147,9 +149,17 @@ nis_cat (self, args)
return cat;
}
-#define YPPROC_MAPLIST ((u_long)11)
-#define YPPROG ((u_long)100004)
-#define YPVERS ((u_long)2)
+/* These should be u_long on Sun h/w but not on 64-bit h/w.
+ This is not portable to machines with 16-bit ints and no prototypes */
+#ifndef YPPROC_MAPLIST
+#define YPPROC_MAPLIST 11
+#endif
+#ifndef YPPROG
+#define YPPROG 100004
+#endif
+#ifndef YPVERS
+#define YPVERS 2
+#endif
typedef char *domainname;
typedef char *mapname;
@@ -260,8 +270,9 @@ nisproc_maplist_2(argp, clnt)
static nisresp_maplist res;
memset(&res, 0, sizeof(res));
- if (clnt_call(clnt, YPPROC_MAPLIST, nis_xdr_domainname, argp, nis_xdr_ypresp_maplist
-, &res, TIMEOUT) != RPC_SUCCESS) {
+ if (clnt_call(clnt, YPPROC_MAPLIST, nis_xdr_domainname, (caddr_t)argp,
+ nis_xdr_ypresp_maplist, (caddr_t)&res, TIMEOUT)
+ != RPC_SUCCESS) {
return (NULL);
}
return (&res);
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 3274c1a37a..04db26ee6f 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -22,6 +22,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
+/* Raw interface to the parser. */
+
#include "allobjects.h"
#include "node.h"
#include "token.h"
@@ -85,12 +87,10 @@ parser_parsefile(self, args)
err_errno(IOError);
return NULL;
}
- err = parse_file(fp, filename, file_input, &n);
+ n = parse_file(fp, filename, file_input);
fclose(fp);
- if (err != E_DONE) {
- err_input(err);
+ if (n == NULL)
return NULL;
- }
res = node2tuple(n);
freetree(n);
return res;
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 07d12e74e6..a0f34e5aa1 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -24,78 +24,115 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* POSIX module implementation */
-#ifdef AMOEBA
-#define NO_LSTAT
-#define SYSV
+#ifdef _M_IX86
+#define NT
+/* NT may be defined externally as well. If it is defined, the module is
+ actually called 'nt', not 'posix', and some functions don't exist. */
#endif
-#ifdef __sgi
-#define DO_PG
-#endif
-
-#ifdef _NEXT_SOURCE
-#define mode_t int
-#define NO_UNAME
-#endif
+#include "allobjects.h"
+#include "modsupport.h"
+#include "ceval.h"
-#include <signal.h>
#include <string.h>
-#include <setjmp.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifdef DO_TIMES
-#include <sys/times.h>
-#include <sys/param.h>
#include <errno.h>
-#endif
-#ifdef SYSV
-
-#define UTIME_STRUCT 1
-#include <dirent.h>
-#define direct dirent
-#ifdef i386
-#define mode_t int
-#endif
-
-#else /* !SYSV */
-
-#include <sys/dir.h>
+#ifndef macintosh
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
-#endif /* !SYSV */
+#include "mytime.h" /* For clock_t on some systems */
-#ifndef NO_UNISTD
-#include <unistd.h> /* Take this out and hope the best if it doesn't exist */
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
#endif
-#include "allobjects.h"
-#include "modsupport.h"
-#include "ceval.h"
-
-#ifdef _SEQUENT_
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#else /* _SEQUENT_ */
-/* XXX Aren't these always declared in unistd.h? */
+#else /* !HAVE_UNISTD_H */
+
+#ifdef macintosh
+#include "macdefs.h"
+#else
extern int mkdir PROTO((const char *, mode_t));
extern int chdir PROTO((const char *));
extern int rmdir PROTO((const char *));
extern int chmod PROTO((const char *, mode_t));
-extern char *getcwd(); /* No PROTO((char *, int)) -- non portable */
+extern int chown PROTO((const char *, uid_t, gid_t));
+extern char *getcwd PROTO((char *, int));
extern char *strerror PROTO((int));
extern int link PROTO((const char *, const char *));
extern int rename PROTO((const char *, const char *));
extern int stat PROTO((const char *, struct stat *));
extern int unlink PROTO((const char *));
extern int pclose PROTO((FILE *));
-#endif /* !_SEQUENT_ */
-#ifdef NO_LSTAT
-#define lstat stat
-#else
-extern int lstat PROTO((const char *, struct stat *));
+#ifdef HAVE_SYMLINK
extern int symlink PROTO((const char *, const char *));
#endif
+#ifdef HAVE_LSTAT
+extern int lstat PROTO((const char *, struct stat *));
+#endif
+#endif /* macintosh */
+#endif /* !HAVE_UNISTD_H */
+
+#if 1
+/* XXX These are for SunOS4.1.3 but shouldn't hurt elsewhere */
+extern int rename();
+extern int pclose();
+extern int lstat();
+extern int symlink();
+#endif
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif
+
+#ifdef HAVE_SYS_TIMES_H
+#include <sys/times.h>
+#endif
+
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
+#ifdef HAVE_SYS_UTSNAME_H
+#include <sys/utsname.h>
+#endif
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+
+/* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
+#if defined(DIRENT) || defined(_POSIX_VERSION)
+#include <dirent.h>
+#define NLENGTH(dirent) (strlen((dirent)->d_name))
+#else /* not (DIRENT or _POSIX_VERSION) */
+#define dirent direct
+#define NLENGTH(dirent) ((dirent)->d_namlen)
+#ifdef SYSNDIR
+#include <sys/ndir.h>
+#endif /* SYSNDIR */
+#ifdef SYSDIR
+#include <sys/dir.h>
+#endif /* SYSDIR */
+#ifdef NDIR
+#include <ndir.h>
+#endif /* NDIR */
+#endif /* not (DIRENT or _POSIX_VERSION) */
+
+#ifdef NT
+#include <direct.h>
+#include <io.h>
+#include <process.h>
+#include <windows.h>
+#define popen _popen
+#endif /* NT */
+
+#ifdef OS2
+#include <io.h>
+#endif
/* Return a dictionary corresponding to the POSIX environment table */
@@ -195,6 +232,25 @@ posix_strint(args, func)
}
static object *
+posix_strintint(args, func)
+ object *args;
+ int (*func) FPROTO((const char *, int, int));
+{
+ char *path;
+ int i,i2;
+ int res;
+ if (!getargs(args, "(sii)", &path, &i, &i2))
+ return NULL;
+ BGN_SAVE
+ res = (*func)(path, i, i2);
+ END_SAVE
+ if (res < 0)
+ return posix_error();
+ INCREF(None);
+ return None;
+}
+
+static object *
posix_do_stat(self, args, statfunc)
object *self;
object *args;
@@ -242,6 +298,16 @@ posix_chmod(self, args)
return posix_strint(args, chmod);
}
+#ifdef HAVE_CHOWN
+static object *
+posix_chown(self, args)
+ object *self;
+ object *args;
+{
+ return posix_strintint(args, chown);
+}
+#endif
+
static object *
posix_getcwd(self, args)
object *self;
@@ -259,6 +325,7 @@ posix_getcwd(self, args)
return newstringobject(buf);
}
+#ifdef HAVE_LINK
static object *
posix_link(self, args)
object *self;
@@ -266,7 +333,64 @@ posix_link(self, args)
{
return posix_2str(args, link);
}
+#endif
+
+#ifdef NT
+static object *
+posix_listdir(self, args)
+ object *self;
+ object *args;
+{
+ char *name;
+ int len;
+ object *d, *v;
+ HANDLE hFindFile;
+ WIN32_FIND_DATA FileData;
+ char namebuf[MAX_PATH+5];
+
+ if (!getargs(args, "s#", &name, &len))
+ return NULL;
+ if (len >= MAX_PATH) {
+ err_setstr(ValueError, "path too long");
+ return NULL;
+ }
+ strcpy(namebuf, name);
+ if (namebuf[len-1] != '/' && namebuf[len-1] != '\\')
+ namebuf[len++] = '/';
+ strcpy(namebuf + len, "*.*");
+
+ if ((d = newlistobject(0)) == NULL)
+ return NULL;
+
+ hFindFile = FindFirstFile(namebuf, &FileData);
+ if (hFindFile == INVALID_HANDLE_VALUE) {
+ errno = GetLastError();
+ return posix_error();
+ }
+ do {
+ v = newstringobject(FileData.cFileName);
+ if (v == NULL) {
+ DECREF(d);
+ d = NULL;
+ break;
+ }
+ if (addlistitem(d, v) != 0) {
+ DECREF(v);
+ DECREF(d);
+ d = NULL;
+ break;
+ }
+ DECREF(v);
+ } while (FindNextFile(hFindFile, &FileData) == TRUE);
+
+ if (FindClose(hFindFile) == FALSE) {
+ errno = GetLastError();
+ return posix_error();
+ }
+ return d;
+}
+#else /* ! NT */
static object *
posix_listdir(self, args)
object *self;
@@ -275,7 +399,7 @@ posix_listdir(self, args)
char *name;
object *d, *v;
DIR *dirp;
- struct direct *ep;
+ struct dirent *ep;
if (!getargs(args, "s", &name))
return NULL;
BGN_SAVE
@@ -308,6 +432,7 @@ posix_listdir(self, args)
return d;
}
+#endif /* ! NT */
static object *
posix_mkdir(self, args)
@@ -317,6 +442,7 @@ posix_mkdir(self, args)
return posix_strint(args, mkdir);
}
+#ifdef HAVE_NICE
static object *
posix_nice(self, args)
object *self;
@@ -331,21 +457,7 @@ posix_nice(self, args)
return posix_error();
return newintobject((long) value);
}
-
-#if i386 && ! _SEQUENT_
-int
-rename(from, to)
- char *from;
- char *to;
-{
- int status;
- /* XXX Shouldn't this unlink the destination first? */
- status = link(from, to);
- if (status != 0)
- return status;
- return unlink(from);
-}
-#endif /* i386 && ! _SEQUENT_ */
+#endif /* HAVE_NICE */
static object *
posix_rename(self, args)
@@ -408,11 +520,7 @@ posix_unlink(self, args)
return posix_1str(args, unlink);
}
-#ifndef NO_UNAME
-#include <sys/utsname.h>
-
-extern int uname PROTO((struct utsname *));
-
+#ifdef HAVE_UNAME
static object *
posix_uname(self, args)
object *self;
@@ -435,11 +543,7 @@ posix_uname(self, args)
u.version,
u.machine);
}
-#endif /* NO_UNAME */
-
-#ifdef UTIME_STRUCT
-#include <utime.h>
-#endif
+#endif /* HAVE_UNAME */
static object *
posix_utime(self, args)
@@ -449,12 +553,11 @@ posix_utime(self, args)
char *path;
int res;
-#ifdef UTIME_STRUCT
+#ifdef HAVE_UTIME_H
struct utimbuf buf;
#define ATIME buf.actime
#define MTIME buf.modtime
#define UTIME_ARG &buf
-
#else
time_t buf[2];
#define ATIME buf[0]
@@ -532,8 +635,12 @@ posix_execv(self, args)
}
argvlist[argc] = NULL;
+#ifdef BAD_EXEC_PROTOTYPES
+ execv(path, (const char **) argvlist);
+#else
execv(path, argvlist);
-
+#endif
+
/* If we get here it's definitely an error */
DEL(argvlist);
@@ -614,7 +721,12 @@ posix_execve(self, args)
}
envlist[envc] = 0;
+
+#ifdef BAD_EXEC_PROTOTYPES
+ execve(path, (const char **)argvlist, envlist);
+#else
execve(path, argvlist, envlist);
+#endif
/* If we get here it's definitely an error */
@@ -684,6 +796,7 @@ posix_getpid(self, args)
return newintobject((long)getpid());
}
+#ifdef HAVE_GETPGRP
static object *
posix_getpgrp(self, args)
object *self;
@@ -691,13 +804,15 @@ posix_getpgrp(self, args)
{
if (!getnoarg(args))
return NULL;
-#ifdef SYSV
- return newintobject((long)getpgrp());
-#else
+#ifdef GETPGRP_HAVE_ARG
return newintobject((long)getpgrp(0));
+#else
+ return newintobject((long)getpgrp());
#endif
}
+#endif /* HAVE_GETPGRP */
+#ifdef HAVE_SETPGRP
static object *
posix_setpgrp(self, args)
object *self;
@@ -705,16 +820,18 @@ posix_setpgrp(self, args)
{
if (!getnoarg(args))
return NULL;
-#ifdef SYSV
- if (setpgrp() < 0)
-#else
+#ifdef GETPGRP_HAVE_ARG
if (setpgrp(0, 0) < 0)
+#else
+ if (setpgrp() < 0)
#endif
return posix_error();
INCREF(None);
return None;
}
+#endif /* HAVE_SETPGRP */
+
static object *
posix_getppid(self, args)
object *self;
@@ -763,12 +880,10 @@ posix_popen(self, args)
END_SAVE
if (fp == NULL)
return posix_error();
- /* From now on, ignore SIGPIPE and let the error checking
- do the work. */
- (void) signal(SIGPIPE, SIG_IGN);
return newopenfileobject(fp, name, mode, pclose);
}
+#ifdef HAVE_SETUID
static object *
posix_setuid(self, args)
object *self;
@@ -782,7 +897,9 @@ posix_setuid(self, args)
INCREF(None);
return None;
}
+#endif
+#ifdef HAVE_SETGID
static object *
posix_setgid(self, args)
object *self;
@@ -796,17 +913,14 @@ posix_setgid(self, args)
INCREF(None);
return None;
}
+#endif
+#ifdef HAVE_WAITPID
static object *
posix_waitpid(self, args)
object *self;
object *args;
{
-#ifdef NO_WAITPID
- err_setstr(PosixError,
- "posix.waitpid() not supported on this system");
- return NULL;
-#else
int pid, options, sts;
if (!getargs(args, "(ii)", &pid, &options))
return NULL;
@@ -817,8 +931,8 @@ posix_waitpid(self, args)
return posix_error();
else
return mkvalue("ii", pid, sts);
-#endif
}
+#endif /* HAVE_WAITPID */
static object *
posix_wait(self, args)
@@ -826,8 +940,6 @@ posix_wait(self, args)
object *args;
{
int pid, sts;
- if (args != NULL)
- return posix_waitpid(self, args); /* BW compat */
BGN_SAVE
pid = wait(&sts);
END_SAVE
@@ -842,19 +954,20 @@ posix_lstat(self, args)
object *self;
object *args;
{
+#ifdef HAVE_LSTAT
return posix_do_stat(self, args, lstat);
+#else /* !HAVE_LSTAT */
+ return posix_do_stat(self, args, stat);
+#endif /* !HAVE_LSTAT */
}
+#ifdef HAVE_READLINK
static object *
posix_readlink(self, args)
object *self;
object *args;
{
-#ifdef NO_LSTAT
- err_setstr(PosixError, "readlink not implemented on this system");
- return NULL;
-#else
- char buf[1024]; /* XXX Should use MAXPATHLEN */
+ char buf[MAXPATHLEN];
char *path;
int n;
if (!getargs(args, "s", &path))
@@ -865,25 +978,23 @@ posix_readlink(self, args)
if (n < 0)
return posix_error();
return newsizedstringobject(buf, n);
-#endif
}
+#endif /* HAVE_READLINK */
+#ifdef HAVE_SYMLINK
static object *
posix_symlink(self, args)
object *self;
object *args;
{
-#ifdef NO_LSTAT
- err_setstr(PosixError, "symlink not implemented on this system");
- return NULL;
-#else
return posix_2str(args, symlink);
-#endif
}
+#endif /* HAVE_SYMLINK */
-
-#ifdef DO_TIMES
-
+#ifdef HAVE_TIMES
+#ifndef HZ
+#define HZ 60 /* Universal constant :-) */
+#endif
static object *
posix_times(self, args)
object *self;
@@ -903,11 +1014,9 @@ posix_times(self, args)
(double)t.tms_cutime / HZ,
(double)t.tms_cstime / HZ);
}
+#endif /* HAVE_TIMES */
-#endif /* DO_TIMES */
-
-#ifdef DO_PG
-
+#ifdef HAVE_SETSID
static object *
posix_setsid(self, args)
object *self;
@@ -920,7 +1029,9 @@ posix_setsid(self, args)
INCREF(None);
return None;
}
+#endif /* HAVE_SETSID */
+#ifdef HAVE_SETPGID
static object *
posix_setpgid(self, args)
object *self;
@@ -934,7 +1045,9 @@ posix_setpgid(self, args)
INCREF(None);
return None;
}
+#endif /* HAVE_SETPGID */
+#ifdef HAVE_TCGETPGRP
static object *
posix_tcgetpgrp(self, args)
object *self;
@@ -948,7 +1061,9 @@ posix_tcgetpgrp(self, args)
return posix_error();
return newintobject((long)pgid);
}
+#endif /* HAVE_TCGETPGRP */
+#ifdef HAVE_TCSETPGRP
static object *
posix_tcsetpgrp(self, args)
object *self;
@@ -962,8 +1077,7 @@ posix_tcsetpgrp(self, args)
INCREF(None);
return None;
}
-
-#endif /* DO_PG */
+#endif /* HAVE_TCSETPGRP */
/* Functions acting on file descriptors */
@@ -1150,7 +1264,6 @@ posix_fdopen(self, args)
return posix_error();
/* From now on, ignore SIGPIPE and let the error checking
do the work. */
- (void) signal(SIGPIPE, SIG_IGN);
return newopenfileobject(fp, "(fdopen)", mode, fclose);
}
@@ -1174,49 +1287,84 @@ posix_pipe(self, args)
static struct methodlist posix_methods[] = {
{"chdir", posix_chdir},
{"chmod", posix_chmod},
+#ifdef HAVE_CHOWN
+ {"chown", posix_chown},
+#endif
{"getcwd", posix_getcwd},
+#ifdef HAVE_LINK
{"link", posix_link},
+#endif
{"listdir", posix_listdir},
{"lstat", posix_lstat},
{"mkdir", posix_mkdir},
+#ifdef HAVE_NICE
{"nice", posix_nice},
+#endif
+#ifdef HAVE_READLINK
{"readlink", posix_readlink},
+#endif
{"rename", posix_rename},
{"rmdir", posix_rmdir},
{"stat", posix_stat},
+#ifdef HAVE_SYMLINK
{"symlink", posix_symlink},
+#endif
{"system", posix_system},
{"umask", posix_umask},
-#ifndef NO_UNAME
+#ifdef HAVE_UNAME
{"uname", posix_uname},
#endif
{"unlink", posix_unlink},
+#ifndef NT
{"utime", posix_utime},
-#ifdef DO_TIMES
+#endif /* ! NT */
+#ifdef HAVE_TIMES
{"times", posix_times},
#endif
{"_exit", posix__exit},
{"execv", posix_execv},
{"execve", posix_execve},
+#ifndef NT
{"fork", posix_fork},
{"getegid", posix_getegid},
{"geteuid", posix_geteuid},
{"getgid", posix_getgid},
+#endif /* ! NT */
{"getpid", posix_getpid},
+#ifdef HAVE_GETPGRP
{"getpgrp", posix_getpgrp},
+#endif
+#ifndef NT
{"getppid", posix_getppid},
{"getuid", posix_getuid},
{"kill", posix_kill},
+#endif /* ! NT */
{"popen", posix_popen},
+#ifdef HAVE_SETUID
{"setuid", posix_setuid},
+#endif
+#ifdef HAVE_SETGID
{"setgid", posix_setgid},
+#endif
+#ifdef HAVE_SETPGRP
{"setpgrp", posix_setpgrp},
+#endif
+#ifndef NT
{"wait", posix_wait},
+#endif /* ! NT */
+#ifdef HAVE_WAITPID
{"waitpid", posix_waitpid},
-#ifdef DO_PG
+#endif
+#ifdef HAVE_SETSID
{"setsid", posix_setsid},
+#endif
+#ifdef HAVE_SETPGID
{"setpgid", posix_setpgid},
+#endif
+#ifdef HAVE_TCGETPGRP
{"tcgetpgrp", posix_tcgetpgrp},
+#endif
+#ifdef HAVE_TCSETPGRP
{"tcsetpgrp", posix_tcsetpgrp},
#endif
{"open", posix_open},
@@ -1228,12 +1376,35 @@ static struct methodlist posix_methods[] = {
{"write", posix_write},
{"fstat", posix_fstat},
{"fdopen", posix_fdopen},
+#ifndef NT
{"pipe", posix_pipe},
+#endif /* ! NT */
{NULL, NULL} /* Sentinel */
};
+#ifdef NT
+void
+initnt()
+{
+ object *m, *d, *v;
+
+ m = initmodule("nt", posix_methods);
+ d = getmoduledict(m);
+
+ /* Initialize nt.environ dictionary */
+ v = convertenviron();
+ if (v == NULL || dictinsert(d, "environ", v) != 0)
+ fatal("can't define nt.environ");
+ DECREF(v);
+
+ /* Initialize nt.error exception */
+ PosixError = newstringobject("nt.error");
+ if (PosixError == NULL || dictinsert(d, "error", PosixError) != 0)
+ fatal("can't define nt.error");
+}
+#else /* ! NT */
void
initposix()
{
@@ -1253,17 +1424,4 @@ initposix()
if (PosixError == NULL || dictinsert(d, "error", PosixError) != 0)
fatal("can't define posix.error");
}
-
-
-/* Function used elsewhere to get a file's modification time */
-
-long
-getmtime(path)
- char *path;
-{
- struct stat st;
- if (stat(path, &st) != 0)
- return -1;
- else
- return st.st_mtime;
-}
+#endif /* ! NT */
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index 00ea348a2a..5775473697 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -22,18 +22,13 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
-/* Passwd/group file access module */
+/* UNIX password file access module */
#include "allobjects.h"
#include "modsupport.h"
#include <sys/types.h>
#include <pwd.h>
-#include <grp.h>
-
-
-/* Module pwd */
-
static object *mkpwent(p)
struct passwd *p;
@@ -109,94 +104,3 @@ initpwd()
{
initmodule("pwd", pwd_methods);
}
-
-
-/* Module grp */
-
-
-static object *mkgrent(p)
- struct group *p;
-{
- object *v, *w;
- char **member;
- if ((w = newlistobject(0)) == NULL) {
- return NULL;
- }
- for (member = p->gr_mem; *member != NULL; member++) {
- object *x = newstringobject(*member);
- if (x == NULL || addlistitem(w, x) != 0) {
- XDECREF(x);
- DECREF(w);
- return NULL;
- }
- }
- v = mkvalue("(sslO)",
- p->gr_name,
- p->gr_passwd,
- (long)p->gr_gid,
- w);
- DECREF(w);
- return v;
-}
-
-static object *grp_getgrgid(self, args)
- object *self, *args;
-{
- int gid;
- struct group *p;
- if (!getintarg(args, &gid))
- return NULL;
- if ((p = getgrgid(gid)) == NULL) {
- err_setstr(KeyError, "getgrgid(): gid not found");
- return NULL;
- }
- return mkgrent(p);
-}
-
-static object *grp_getgrnam(self, args)
- object *self, *args;
-{
- char *name;
- struct group *p;
- if (!getstrarg(args, &name))
- return NULL;
- if ((p = getgrnam(name)) == NULL) {
- err_setstr(KeyError, "getgrnam(): name not found");
- return NULL;
- }
- return mkgrent(p);
-}
-
-static object *grp_getgrall(self, args)
- object *self, *args;
-{
- object *d;
- struct group *p;
- if (!getnoarg(args))
- return NULL;
- if ((d = newlistobject(0)) == NULL)
- return NULL;
- setgrent();
- while ((p = getgrent()) != NULL) {
- object *v = mkgrent(p);
- if (v == NULL || addlistitem(d, v) != 0) {
- XDECREF(v);
- DECREF(d);
- return NULL;
- }
- }
- return d;
-}
-
-static struct methodlist grp_methods[] = {
- {"getgrgid", grp_getgrgid},
- {"getgrnam", grp_getgrnam},
- {"getgrall", grp_getgrall},
- {NULL, NULL} /* sentinel */
-};
-
-void
-initgrp()
-{
- initmodule("grp", grp_methods);
-}
diff --git a/Modules/regexmodule.c b/Modules/regexmodule.c
index 13c6cb216f..c4b15ff053 100644
--- a/Modules/regexmodule.c
+++ b/Modules/regexmodule.c
@@ -4,7 +4,7 @@ XXX support mstop parameter on search
*/
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -35,6 +35,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h"
#include "regexpr.h"
+#include "ctype.h"
static object *RegexError; /* Exception */
@@ -45,6 +46,9 @@ typedef struct {
char re_fastmap[256]; /* Storage for fastmap */
object *re_translate; /* String object for translate table */
object *re_lastok; /* String object last matched/searched */
+ object *re_groupindex; /* Group name to index dictionary */
+ object *re_givenpat; /* Pattern with symbolic groups */
+ object *re_realpat; /* Pattern without symbolic groups */
} regexobject;
/* Regex object methods */
@@ -55,8 +59,9 @@ reg_dealloc(re)
{
XDECREF(re->re_translate);
XDECREF(re->re_lastok);
- XDEL(re->re_patbuf.buffer);
- XDEL(re->re_patbuf.translate);
+ XDECREF(re->re_groupindex);
+ XDECREF(re->re_givenpat);
+ XDECREF(re->re_realpat);
DEL(re);
}
@@ -188,8 +193,24 @@ reg_group(re, args)
}
return res;
}
- if (!getargs(args, "i", &i))
- return NULL;
+ if (!getargs(args, "i", &i)) {
+ object *n;
+ err_clear();
+ if (!getargs(args, "S", &n))
+ return NULL;
+ else {
+ object *index;
+ if (re->re_groupindex == NULL)
+ index = NULL;
+ else
+ index = mappinglookup(re->re_groupindex, n);
+ if (index == NULL) {
+ err_setstr(RegexError, "group() group name doesn't exist");
+ return NULL;
+ }
+ i = getintvalue(index);
+ }
+ }
if (i < 0 || i >= RE_NREGS) {
err_setstr(RegexError, "group() index out of range");
return NULL;
@@ -209,9 +230,9 @@ reg_group(re, args)
}
static struct methodlist reg_methods[] = {
- {"match", reg_match},
- {"search", reg_search},
- {"group", reg_group},
+ {"match", (method)reg_match},
+ {"search", (method)reg_search},
+ {"group", (method)reg_group},
{NULL, NULL} /* sentinel */
};
@@ -243,12 +264,39 @@ reg_getattr(re, name)
INCREF(re->re_translate);
return re->re_translate;
}
+ if (strcmp(name, "groupindex") == 0) {
+ if (re->re_groupindex == NULL) {
+ INCREF(None);
+ return None;
+ }
+ INCREF(re->re_groupindex);
+ return re->re_groupindex;
+ }
+ if (strcmp(name, "realpat") == 0) {
+ if (re->re_realpat == NULL) {
+ INCREF(None);
+ return None;
+ }
+ INCREF(re->re_realpat);
+ return re->re_realpat;
+ }
+ if (strcmp(name, "givenpat") == 0) {
+ if (re->re_givenpat == NULL) {
+ INCREF(None);
+ return None;
+ }
+ INCREF(re->re_givenpat);
+ return re->re_givenpat;
+ }
if (strcmp(name, "__members__") == 0) {
- object *list = newlistobject(3);
+ object *list = newlistobject(6);
if (list) {
setlistitem(list, 0, newstringobject("last"));
setlistitem(list, 1, newstringobject("regs"));
setlistitem(list, 2, newstringobject("translate"));
+ setlistitem(list, 3, newstringobject("groupindex"));
+ setlistitem(list, 4, newstringobject("realpat"));
+ setlistitem(list, 5, newstringobject("givenpat"));
if (err_occurred()) {
DECREF(list);
list = NULL;
@@ -266,21 +314,25 @@ static typeobject Regextype = {
sizeof(regexobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- reg_dealloc, /*tp_dealloc*/
+ (destructor)reg_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- reg_getattr, /*tp_getattr*/
+ (getattrfunc)reg_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
};
static object *
-newregexobject(pat, size, translate)
- char *pat;
- int size;
+newregexobject(pattern, translate, givenpat, groupindex)
+ object *pattern;
object *translate;
+ object *givenpat;
+ object *groupindex;
{
regexobject *re;
+ char *pat = getstringvalue(pattern);
+ int size = getstringsize(pattern);
+
if (translate != NULL && getstringsize(translate) != 256) {
err_setstr(RegexError,
"translation table must be 256 bytes");
@@ -299,6 +351,11 @@ newregexobject(pat, size, translate)
XINCREF(translate);
re->re_translate = translate;
re->re_lastok = NULL;
+ re->re_groupindex = groupindex;
+ INCREF(pattern);
+ re->re_realpat = pattern;
+ INCREF(givenpat);
+ re->re_givenpat = givenpat;
error = re_compile_pattern(pat, size, &re->re_patbuf);
if (error != NULL) {
err_setstr(RegexError, error);
@@ -314,17 +371,131 @@ regex_compile(self, args)
object *self;
object *args;
{
- char *pat;
- int size;
+ object *pat = NULL;
object *tran = NULL;
- if (!getargs(args, "s#", &pat, &size)) {
+ if (!getargs(args, "S", &pat)) {
err_clear();
- if (!getargs(args, "(s#S)", &pat, &size, &tran))
+ if (!getargs(args, "(SS)", &pat, &tran))
return NULL;
}
- return newregexobject(pat, size, tran);
+ return newregexobject(pat, tran, pat, NULL);
}
+static object *
+symcomp(pattern, gdict)
+ object *pattern;
+ object *gdict;
+{
+ char *opat = getstringvalue(pattern);
+ char *oend = opat + getstringsize(pattern);
+ int group_count = 0;
+ int escaped = 0;
+ char *o = opat;
+ char *n;
+ char name_buf[128];
+ char *g;
+ object *npattern;
+ int require_escape = re_syntax & RE_NO_BK_PARENS ? 0 : 1;
+
+ npattern = newsizedstringobject((char*)NULL, getstringsize(pattern));
+ if (npattern == NULL)
+ return NULL;
+ n = getstringvalue(npattern);
+
+ while (o < oend) {
+ if (*o == '(' && escaped == require_escape) {
+ char *backtrack;
+ escaped = 0;
+ ++group_count;
+ *n++ = *o;
+ if (++o >= oend || *o != '<')
+ continue;
+ /* *o == '<' */
+ if (o+1 < oend && *(o+1) == '>')
+ continue;
+ backtrack = o;
+ g = name_buf;
+ for (++o; o < oend;) {
+ if (*o == '>') {
+ object *group_name = NULL;
+ object *group_index = NULL;
+ *g++ = '\0';
+ group_name = newstringobject(name_buf);
+ group_index = newintobject(group_count);
+ if (group_name == NULL || group_index == NULL
+ || mappinginsert(gdict, group_name, group_index) != 0) {
+ XDECREF(group_name);
+ XDECREF(group_index);
+ XDECREF(npattern);
+ return NULL;
+ }
+ ++o; /* eat the '>' */
+ break;
+ }
+ if (!isalnum(*o) && *o != '_') {
+ o = backtrack;
+ break;
+ }
+ *g++ = *o++;
+ }
+ }
+ if (*o == '[' && !escaped) {
+ *n++ = *o;
+ ++o; /* eat the char following '[' */
+ *n++ = *o;
+ while (o < oend && *o != ']') {
+ ++o;
+ *n++ = *o;
+ }
+ if (o < oend)
+ ++o;
+ }
+ else if (*o == '\\') {
+ escaped = 1;
+ *n++ = *o;
+ ++o;
+ }
+ else {
+ escaped = 0;
+ *n++ = *o;
+ ++o;
+ }
+ }
+
+ if (resizestring(&npattern, n - getstringvalue(npattern)) == 0)
+ return npattern;
+ else {
+ DECREF(npattern);
+ return NULL;
+ }
+
+}
+
+static object *
+regex_symcomp(self, args)
+ object *self;
+ object *args;
+{
+ object *pattern;
+ object *tran = NULL;
+ object *gdict = NULL;
+ object *npattern;
+ if (!getargs(args, "S", &pattern)) {
+ err_clear();
+ if (!getargs(args, "(SS)", &pattern, &tran))
+ return NULL;
+ }
+ gdict = newmappingobject();
+ if (gdict == NULL
+ || (npattern = symcomp(pattern, gdict)) == NULL) {
+ DECREF(gdict);
+ DECREF(pattern);
+ return NULL;
+ }
+ return newregexobject(npattern, tran, pattern, gdict);
+}
+
+
static object *cache_pat;
static object *cache_prog;
@@ -384,6 +555,7 @@ regex_set_syntax(self, args)
static struct methodlist regex_global_methods[] = {
{"compile", regex_compile},
+ {"symcomp", regex_symcomp},
{"match", regex_match},
{"search", regex_search},
{"set_syntax", regex_set_syntax},
diff --git a/Modules/regexpr.c b/Modules/regexpr.c
index d5c0c859a7..f87755870e 100644
--- a/Modules/regexpr.c
+++ b/Modules/regexpr.c
@@ -22,11 +22,9 @@ Free Software Foundation.
Emacs-specific code and syntax table code is almost directly borrowed
from GNU regexp.
-$Header$
-
*/
-#include "PROTO.h" /* For PROTO macro --Guido */
+#include "myproto.h" /* For PROTO macro --Guido */
#include <stdio.h>
#include <assert.h>
@@ -116,6 +114,7 @@ enum regexp_syntax_op /* syntax codes for plain and quoted characters */
static int re_compile_initialized = 0;
static int regexp_syntax = 0;
+int re_syntax = 0; /* Exported copy of regexp_syntax */
static unsigned char regexp_plain_ops[256];
static unsigned char regexp_quoted_ops[256];
static unsigned char regexp_precedences[Rnum_ops];
@@ -256,6 +255,7 @@ int syntax;
ret = regexp_syntax;
regexp_syntax = syntax;
+ re_syntax = syntax; /* Exported copy */
re_compile_initialize();
return ret;
}
@@ -644,7 +644,7 @@ regexp_t bufp;
}
if (range)
{
- for (a = prev; a <= ch; a++)
+ for (a = prev; a <= (int)ch; a++)
SETBIT(pattern, offset, a);
prev = -1;
range = 0;
diff --git a/Modules/regexpr.h b/Modules/regexpr.h
index 7e82abd7de..034da3c37e 100644
--- a/Modules/regexpr.h
+++ b/Modules/regexpr.h
@@ -25,11 +25,6 @@ Last modified: Mon Nov 4 15:49:46 1991 ylo
#ifndef REGEXPR_H
#define REGEXPR_H
-#if defined(__STDC__) || defined(THINK_C)
-#undef HAVE_PROTOTYPES
-#define HAVE_PROTOTYPES
-#endif
-
#define RE_NREGS 100 /* number of registers available */
typedef struct re_pattern_buffer
@@ -69,6 +64,10 @@ typedef struct re_registers
#ifdef HAVE_PROTOTYPES
+extern int re_syntax;
+/* This is the actual syntax mask. It was added so that Python
+ could do syntax-dependent munging of patterns before compilation. */
+
int re_set_syntax(int syntax);
/* This sets the syntax to use and returns the previous syntax. The
syntax is specified by a bit mask of the above defined bits. */
@@ -129,6 +128,7 @@ int re_exec(char *s);
#else /* HAVE_PROTOTYPES */
+extern int re_syntax;
int re_set_syntax();
char *re_compile_pattern();
int re_match();
diff --git a/Modules/rgbimgmodule.c b/Modules/rgbimgmodule.c
index 4421f5d0cc..de888eb96c 100644
--- a/Modules/rgbimgmodule.c
+++ b/Modules/rgbimgmodule.c
@@ -16,7 +16,9 @@
*/
#include "allobjects.h"
#include "modsupport.h"
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <string.h>
/*
@@ -199,7 +201,7 @@ IMAGE *image;
static int writetab(outf,tab,len)
FILE *outf;
-unsigned long *tab;
+/*unsigned*/ long *tab;
int len;
{
int r;
@@ -213,7 +215,7 @@ int len;
static readtab(inf,tab,len)
FILE *inf;
-unsigned long *tab;
+/*unsigned*/ long *tab;
int len;
{
while(len) {
@@ -744,7 +746,7 @@ initrgbimg()
object *m, *d;
m = initmodule("rgbimg", rgbimg_methods);
d = getmoduledict(m);
- ImgfileError = newstringobject("rgbimg,error");
+ ImgfileError = newstringobject("rgbimg.error");
if (ImgfileError == NULL || dictinsert(d, "error", ImgfileError))
fatal("can't define rgbimg.error");
}
diff --git a/Modules/rotormodule.c b/Modules/rotormodule.c
index d397e2cd25..a6d043f8f8 100644
--- a/Modules/rotormodule.c
+++ b/Modules/rotormodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -89,7 +89,7 @@ typedef struct {
unsigned char *advances; /* [num_rotors] */
} rotorobject;
-extern typeobject Rotortype; /* Really static, forward */
+staticforward typeobject Rotortype;
#define is_rotorobject(v) ((v)->ob_type == &Rotortype)
@@ -486,7 +486,7 @@ static unsigned char RTR_e_char(r, p)
}
} else {
while (i < r->rotors) {
- tp = r->e_rotor[(i*r->size)+(((r->positions[i] ^ tp) % r->size))];
+ tp = r->e_rotor[(i*r->size)+(((r->positions[i] ^ tp) % (unsigned int) r->size))];
i++;
}
}
@@ -525,7 +525,7 @@ static unsigned char RTR_d_char(r, c)
}
} else {
while (0 <= i) {
- tc = (r->positions[i] ^ r->d_rotor[(i*r->size)+tc]) % r->size;
+ tc = (r->positions[i] ^ r->d_rotor[(i*r->size)+tc]) % (unsigned int) r->size;
i--;
}
}
@@ -656,7 +656,7 @@ rotor_encrypt(self, args)
}
memset(tmp,'\0',len+1);
memcpy(tmp,string,len);
- RTR_e_region(self,tmp,len, TRUE);
+ RTR_e_region(self,(unsigned char *)tmp,len, TRUE);
rtn = newsizedstringobject(tmp,len);
free(tmp);
return(rtn);
@@ -680,7 +680,7 @@ rotor_encryptmore(self, args)
}
memset(tmp,'\0',len+1);
memcpy(tmp,string,len);
- RTR_e_region(self,tmp,len, FALSE);
+ RTR_e_region(self,(unsigned char *)tmp,len, FALSE);
rtn = newsizedstringobject(tmp,len);
free(tmp);
return(rtn);
@@ -704,7 +704,7 @@ rotor_decrypt(self, args)
}
memset(tmp,'\0',len+1);
memcpy(tmp,string,len);
- RTR_d_region(self,tmp,len, TRUE);
+ RTR_d_region(self,(unsigned char *)tmp,len, TRUE);
rtn = newsizedstringobject(tmp,len);
free(tmp);
return(rtn);
@@ -728,7 +728,7 @@ rotor_decryptmore(self, args)
}
memset(tmp,'\0',len+1);
memcpy(tmp,string,len);
- RTR_d_region(self,tmp,len, FALSE);
+ RTR_d_region(self,(unsigned char *)tmp,len, FALSE);
rtn = newsizedstringobject(tmp,len);
free(tmp);
return(rtn);
@@ -749,11 +749,11 @@ rotor_setkey(self, args)
}
static struct methodlist rotor_methods[] = {
- {"encrypt", rotor_encrypt},
- {"encryptmore", rotor_encryptmore},
- {"decrypt", rotor_decrypt},
- {"decryptmore", rotor_decryptmore},
- {"setkey", rotor_setkey},
+ {"encrypt", (method)rotor_encrypt},
+ {"encryptmore", (method)rotor_encryptmore},
+ {"decrypt", (method)rotor_decrypt},
+ {"decryptmore", (method)rotor_decryptmore},
+ {"setkey", (method)rotor_setkey},
{NULL, NULL} /* sentinel */
};
@@ -769,17 +769,17 @@ rotor_getattr(s, name)
static typeobject Rotortype = {
OB_HEAD_INIT(&Typetype)
- 0, /*ob_size*/
+ 0, /*ob_size*/
"rotor", /*tp_name*/
- sizeof(rotorobject), /*tp_size*/
- 0, /*tp_itemsize*/
+ sizeof(rotorobject), /*tp_size*/
+ 0, /*tp_itemsize*/
/* methods */
- rotor_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- rotor_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
+ (destructor)rotor_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)rotor_getattr, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
};
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 2cae7f44d9..ef3ec23346 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -28,7 +28,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h"
#include "ceval.h"
-#include "myselect.h"
+#include <sys/types.h>
+#include "myselect.h" /* Also includes mytime.h */
static object *SelectError;
@@ -63,12 +64,13 @@ list2set(list, set, fd2obj)
err_badarg();
return -1;
}
- if ( v >= FD_SETSIZE ) {
- err_setstr(SystemError, "FD_SETSIZE too low in select()");
+ if ( v < 0 || v >= FD_SETSIZE ) {
+ err_setstr(ValueError, "filedescriptor out of range in select()");
return -1;
}
if ( v > max ) max = v;
FD_SET(v, set);
+ XDECREF(fd2obj[v]);
fd2obj[v] = o;
}
return max+1;
@@ -91,11 +93,12 @@ set2list(set, max, fd2obj)
for(i=0; i<max; i++)
if ( FD_ISSET(i,set) ) {
if ( i > FD_SETSIZE ) {
- err_setstr(SystemError, "FD_SETSIZE too low in select()");
+ err_setstr(SystemError,
+ "filedescriptor out of range returned in select()");
return NULL;
}
o = fd2obj[i];
- if ( o == 0 ) {
+ if ( o == NULL ) {
err_setstr(SystemError,
"Bad filedescriptor returned from select()");
return NULL;
diff --git a/Modules/sgimodule.c b/Modules/sgimodule.c
index 418609de5a..92a8acd9d9 100644
--- a/Modules/sgimodule.c
+++ b/Modules/sgimodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 211ebe7cc3..640505b5ef 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -107,6 +107,19 @@ signal_handler(sig_num)
static object *
+signal_alarm(self, args)
+ object *self; /* Not used */
+ object *args;
+{
+ int t;
+ if (!getargs(args, "i", &t))
+ return NULL;
+ alarm(t);
+ INCREF(None);
+ return None;
+}
+
+static object *
signal_signal(self, args)
object *self; /* Not used */
object *args;
@@ -173,6 +186,7 @@ signal_getsignal(self, args)
/* List of functions defined in the module */
static struct methodlist signal_methods[] = {
+ {"alarm", signal_alarm},
{"signal", signal_signal},
{"getsignal", signal_getsignal},
{NULL, NULL} /* sentinel */
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 3fc875535f..32f22db827 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -30,7 +30,7 @@ This module provides an interface to Berkeley socket IPC.
Limitations:
- only AF_INET and AF_UNIX address families are supported
-- no asynchronous I/O (but read polling: avail)
+- no asynchronous I/O (but you can use select() on sockets)
- no read/write operations (use send/recv or makefile instead)
- setsockopt() and getsockopt() only support integer options
@@ -51,7 +51,6 @@ Interface:
Socket methods:
- s.accept() --> new socket object, sockaddr
-- s.avail() --> boolean
- s.setsockopt(level, optname, flag) --> None
- s.getsockopt(level, optname) --> flag
- s.bind(sockaddr) --> None
@@ -62,8 +61,8 @@ Socket methods:
- s.makefile(mode) --> file object
- s.recv(nbytes [,flags]) --> string
- s.recvfrom(nbytes [,flags]) --> string, sockaddr
-- s.send(string [,flags]) --> None
-- s.sendto(string, [flags,] sockaddr) --> None
+- s.send(string [,flags]) --> nbytes
+- s.sendto(string, [flags,] sockaddr) --> nbytes
- s.shutdown(how) --> None
- s.close() --> None
@@ -73,17 +72,17 @@ Socket methods:
#include "modsupport.h"
#include "ceval.h"
-#include "myselect.h" /* Implies <sys/types.h>, <sys/time.h>, <sys/param.h> */
+#include <sys/types.h>
+#include "mytime.h"
#include <signal.h>
+#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
-#include <netdb.h>
-
-#ifdef i860
-/* Cray APP doesn't have getpeername() */
-#define NO_GETPEERNAME
+#else
+#undef AF_UNIX
#endif
@@ -121,7 +120,7 @@ typedef struct {
some of which call newsocobject(), which uses Socktype, so
there has to be a circular reference. */
-extern typeobject Socktype; /* Forward */
+staticforward typeobject Socktype;
/* Create a new socket object.
@@ -233,11 +232,13 @@ makesockaddr(addr, addrlen)
return ret;
}
+#ifdef AF_UNIX
case AF_UNIX:
{
struct sockaddr_un *a = (struct sockaddr_un *) addr;
return newstringobject(a->sun_path);
}
+#endif /* AF_UNIX */
/* More cases here... */
@@ -263,6 +264,7 @@ getsockaddrarg(s, args, addr_ret, len_ret)
{
switch (s->sock_family) {
+#ifdef AF_UNIX
case AF_UNIX:
{
static struct sockaddr_un addr;
@@ -280,6 +282,7 @@ getsockaddrarg(s, args, addr_ret, len_ret)
*len_ret = len + sizeof addr.sun_family;
return 1;
}
+#endif /* AF_UNIX */
case AF_INET:
{
@@ -318,11 +321,13 @@ getsockaddrlen(s, len_ret)
{
switch (s->sock_family) {
+#ifdef AF_UNIX
case AF_UNIX:
{
*len_ret = sizeof (struct sockaddr_un);
return 1;
}
+#endif /* AF_UNIX */
case AF_INET:
{
@@ -477,29 +482,6 @@ sock_getsockopt(s, args)
}
-/* s.avail() method */
-
-static object *
-sock_avail(s, args)
- sockobject *s;
- object *args;
-{
- struct timeval timeout;
- fd_set readers;
- int n;
- if (!getnoarg(args))
- return NULL;
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
- FD_ZERO(&readers);
- FD_SET(s->sock_fd, &readers);
- n = select(s->sock_fd+1, &readers, (fd_set *)0, (fd_set *)0, &timeout);
- if (n < 0)
- return socket_error();
- return newintobject((long) (n != 0));
-}
-
-
/* s.bind(sockaddr) method */
static object *
@@ -599,7 +581,7 @@ sock_getsockname(s, args)
}
-#ifndef NO_GETPEERNAME
+#ifdef HAVE_GETPEERNAME /* Cray APP doesn't have this :-( */
/* s.getpeername() method */
static object *
@@ -620,7 +602,7 @@ sock_getpeername(s, args)
return socket_error();
return makesockaddr((struct sockaddr *) addrbuf, addrlen);
}
-#endif
+#endif /* HAVE_GETPEERNAME */
/* s.listen(n) method */
@@ -635,6 +617,8 @@ sock_listen(s, args)
if (!getintarg(args, &backlog))
return NULL;
BGN_SAVE
+ if (backlog < 1)
+ backlog = 1;
res = listen(s->sock_fd, backlog);
END_SAVE
if (res < 0)
@@ -755,8 +739,7 @@ sock_send(s, args)
END_SAVE
if (n < 0)
return socket_error();
- INCREF(None);
- return None;
+ return newintobject((long)n);
}
@@ -784,8 +767,7 @@ sock_sendto(s, args)
END_SAVE
if (n < 0)
return socket_error();
- INCREF(None);
- return None;
+ return newintobject((long)n);
}
@@ -813,27 +795,26 @@ sock_shutdown(s, args)
/* List of methods for socket objects */
static struct methodlist sock_methods[] = {
- {"accept", sock_accept},
- {"avail", sock_avail},
- {"allowbroadcast", sock_allowbroadcast},
- {"setsockopt", sock_setsockopt},
- {"getsockopt", sock_getsockopt},
- {"bind", sock_bind},
- {"close", sock_close},
- {"connect", sock_connect},
- {"fileno", sock_fileno},
- {"getsockname", sock_getsockname},
-#ifndef NO_GETPEERNAME
- {"getpeername", sock_getpeername},
+ {"accept", (method)sock_accept},
+ {"allowbroadcast", (method)sock_allowbroadcast},
+ {"setsockopt", (method)sock_setsockopt},
+ {"getsockopt", (method)sock_getsockopt},
+ {"bind", (method)sock_bind},
+ {"close", (method)sock_close},
+ {"connect", (method)sock_connect},
+ {"fileno", (method)sock_fileno},
+ {"getsockname", (method)sock_getsockname},
+#ifdef HAVE_GETPEERNAME
+ {"getpeername", (method)sock_getpeername},
#endif
- {"listen", sock_listen},
- {"makefile", sock_makefile},
- {"recv", sock_recv},
- {"recvfrom", sock_recvfrom},
- {"send", sock_send},
- {"sendto", sock_sendto},
- {"shutdown", sock_shutdown},
- {NULL, NULL} /* sentinel */
+ {"listen", (method)sock_listen},
+ {"makefile", (method)sock_makefile},
+ {"recv", (method)sock_recv},
+ {"recvfrom", (method)sock_recvfrom},
+ {"send", (method)sock_send},
+ {"sendto", (method)sock_sendto},
+ {"shutdown", (method)sock_shutdown},
+ {NULL, NULL} /* sentinel */
};
@@ -860,19 +841,17 @@ sock_getattr(s, name)
}
-/* Type object for socket objects.
- XXX This should be static, but some compilers don't grok the
- XXX forward reference to it in that case... */
+/* Type object for socket objects. */
-typeobject Socktype = {
+static typeobject Socktype = {
OB_HEAD_INIT(&Typetype)
0,
"socket",
sizeof(sockobject),
0,
- sock_dealloc, /*tp_dealloc*/
+ (destructor)sock_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- sock_getattr, /*tp_getattr*/
+ (getattrfunc)sock_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
@@ -1061,7 +1040,9 @@ initsocket()
if (SocketError == NULL || dictinsert(d, "error", SocketError) != 0)
fatal("can't define socket.error");
insint(d, "AF_INET", AF_INET);
+#ifdef AF_UNIX
insint(d, "AF_UNIX", AF_UNIX);
+#endif /* AF_UNIX */
insint(d, "SOCK_STREAM", SOCK_STREAM);
insint(d, "SOCK_DGRAM", SOCK_DGRAM);
insint(d, "SOCK_RAW", SOCK_RAW);
diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c
index fc81cffded..2342527635 100644
--- a/Modules/stdwinmodule.c
+++ b/Modules/stdwinmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -75,7 +75,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define HAVE_BITMAPS
#endif /* !macintosh */
-#ifdef USE_THREAD
+#ifdef WITH_THREAD
#include "thread.h"
@@ -113,7 +113,7 @@ typedef struct {
object *w_attr; /* Attributes dictionary */
} windowobject;
-extern typeobject Windowtype; /* Really static, forward */
+staticforward typeobject Windowtype;
#define is_windowobject(wp) ((wp)->ob_type == &Windowtype)
@@ -124,7 +124,7 @@ typedef struct {
object *m_attr; /* Attributes dictionary */
} menuobject;
-extern typeobject Menutype; /* Really static, forward */
+staticforward typeobject Menutype;
#define is_menuobject(mp) ((mp)->ob_type == &Menutype)
@@ -134,7 +134,7 @@ typedef struct {
object *b_attr; /* Attributes dictionary */
} bitmapobject;
-extern typeobject Bitmaptype; /* Really static, forward */
+staticforward typeobject Bitmaptype;
#define is_bitmapobject(mp) ((mp)->ob_type == &Bitmaptype)
@@ -730,44 +730,44 @@ drawing_bitmap(self, args)
static struct methodlist drawing_methods[] = {
#ifdef HAVE_BITMAPS
- {"bitmap", drawing_bitmap},
+ {"bitmap", (method)drawing_bitmap},
#endif
- {"box", drawing_box},
- {"circle", drawing_circle},
- {"cliprect", drawing_cliprect},
- {"close", drawing_close},
- {"elarc", drawing_elarc},
- {"enddrawing", drawing_close},
- {"erase", drawing_erase},
- {"fillcircle", drawing_fillcircle},
- {"fillelarc", drawing_fillelarc},
- {"fillpoly", drawing_fillpoly},
- {"invert", drawing_invert},
- {"line", drawing_line},
- {"noclip", drawing_noclip},
- {"paint", drawing_paint},
- {"poly", drawing_poly},
- {"shade", drawing_shade},
- {"text", drawing_text},
- {"xorcircle", drawing_xorcircle},
- {"xorelarc", drawing_xorelarc},
- {"xorline", drawing_xorline},
- {"xorpoly", drawing_xorpoly},
+ {"box", (method)drawing_box},
+ {"circle", (method)drawing_circle},
+ {"cliprect", (method)drawing_cliprect},
+ {"close", (method)drawing_close},
+ {"elarc", (method)drawing_elarc},
+ {"enddrawing", (method)drawing_close},
+ {"erase", (method)drawing_erase},
+ {"fillcircle", (method)drawing_fillcircle},
+ {"fillelarc", (method)drawing_fillelarc},
+ {"fillpoly", (method)drawing_fillpoly},
+ {"invert", (method)drawing_invert},
+ {"line", (method)drawing_line},
+ {"noclip", (method)drawing_noclip},
+ {"paint", (method)drawing_paint},
+ {"poly", (method)drawing_poly},
+ {"shade", (method)drawing_shade},
+ {"text", (method)drawing_text},
+ {"xorcircle", (method)drawing_xorcircle},
+ {"xorelarc", (method)drawing_xorelarc},
+ {"xorline", (method)drawing_xorline},
+ {"xorpoly", (method)drawing_xorpoly},
/* Text measuring methods: */
- {"baseline", drawing_baseline},
- {"lineheight", drawing_lineheight},
- {"textbreak", drawing_textbreak},
- {"textwidth", drawing_textwidth},
+ {"baseline", (method)drawing_baseline},
+ {"lineheight", (method)drawing_lineheight},
+ {"textbreak", (method)drawing_textbreak},
+ {"textwidth", (method)drawing_textwidth},
/* Font setting methods: */
- {"setfont", drawing_setfont},
+ {"setfont", (method)drawing_setfont},
/* Color methods: */
- {"getbgcolor", drawing_getbgcolor},
- {"getfgcolor", drawing_getfgcolor},
- {"setbgcolor", drawing_setbgcolor},
- {"setfgcolor", drawing_setfgcolor},
+ {"getbgcolor", (method)drawing_getbgcolor},
+ {"getfgcolor", (method)drawing_getfgcolor},
+ {"setbgcolor", (method)drawing_setbgcolor},
+ {"setfgcolor", (method)drawing_setfgcolor},
{NULL, NULL} /* sentinel */
};
@@ -791,9 +791,9 @@ typeobject Drawingtype = {
sizeof(drawingobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- drawing_dealloc, /*tp_dealloc*/
+ (destructor)drawing_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- drawing_getattr, /*tp_getattr*/
+ (getattrfunc)drawing_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
@@ -809,7 +809,7 @@ typedef struct {
object *t_attr; /* Attributes dictionary */
} textobject;
-extern typeobject Texttype; /* Really static, forward */
+staticforward typeobject Texttype;
static textobject *
newtextobject(wp, left, top, right, bottom)
@@ -1073,20 +1073,20 @@ text_setview(self, args)
}
static struct methodlist text_methods[] = {
- {"arrow", text_arrow},
- {"close", text_close},
- {"draw", text_draw},
- {"event", text_event},
- {"getfocus", text_getfocus},
- {"getfocustext",text_getfocustext},
- {"getrect", text_getrect},
- {"gettext", text_gettext},
- {"move", text_move},
- {"replace", text_replace},
- {"setactive", text_setactive},
- {"setfocus", text_setfocus},
- {"settext", text_settext},
- {"setview", text_setview},
+ {"arrow", (method)text_arrow},
+ {"close", (method)text_close},
+ {"draw", (method)text_draw},
+ {"event", (method)text_event},
+ {"getfocus", (method)text_getfocus},
+ {"getfocustext",(method)text_getfocustext},
+ {"getrect", (method)text_getrect},
+ {"gettext", (method)text_gettext},
+ {"move", (method)text_move},
+ {"replace", (method)text_replace},
+ {"setactive", (method)text_setactive},
+ {"setfocus", (method)text_setfocus},
+ {"settext", (method)text_settext},
+ {"setview", (method)text_setview},
{NULL, NULL} /* sentinel */
};
@@ -1137,17 +1137,17 @@ text_setattr(tp, name, v)
return dictinsert(tp->t_attr, name, v);
}
-typeobject Texttype = {
+static typeobject Texttype = {
OB_HEAD_INIT(&Typetype)
0, /*ob_size*/
"textedit", /*tp_name*/
sizeof(textobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- text_dealloc, /*tp_dealloc*/
+ (destructor)text_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- text_getattr, /*tp_getattr*/
- text_setattr, /*tp_setattr*/
+ (getattrfunc)text_getattr, /*tp_getattr*/
+ (setattrfunc)text_setattr, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
};
@@ -1289,11 +1289,11 @@ menu_check(self, args)
}
static struct methodlist menu_methods[] = {
- {"additem", menu_additem},
- {"setitem", menu_setitem},
- {"enable", menu_enable},
- {"check", menu_check},
- {"close", menu_close},
+ {"additem", (method)menu_additem},
+ {"setitem", (method)menu_setitem},
+ {"enable", (method)menu_enable},
+ {"check", (method)menu_check},
+ {"close", (method)menu_close},
{NULL, NULL} /* sentinel */
};
@@ -1344,17 +1344,17 @@ menu_setattr(mp, name, v)
return dictinsert(mp->m_attr, name, v);
}
-typeobject Menutype = {
+static typeobject Menutype = {
OB_HEAD_INIT(&Typetype)
0, /*ob_size*/
"menu", /*tp_name*/
sizeof(menuobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- menu_dealloc, /*tp_dealloc*/
+ (destructor)menu_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- menu_getattr, /*tp_getattr*/
- menu_setattr, /*tp_setattr*/
+ (getattrfunc)menu_getattr, /*tp_getattr*/
+ (setattrfunc)menu_setattr, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
};
@@ -1447,10 +1447,10 @@ bitmap_getsize(self, args)
}
static struct methodlist bitmap_methods[] = {
- {"close", bitmap_close},
- {"getsize", bitmap_getsize},
- {"getbit", bitmap_getbit},
- {"setbit", bitmap_setbit},
+ {"close", (method)bitmap_close},
+ {"getsize", (method)bitmap_getsize},
+ {"getbit", (method)bitmap_getbit},
+ {"setbit", (method)bitmap_setbit},
{NULL, NULL} /* sentinel */
};
@@ -1501,17 +1501,17 @@ bitmap_setattr(bp, name, v)
return dictinsert(bp->b_attr, name, v);
}
-typeobject Bitmaptype = {
+static typeobject Bitmaptype = {
OB_HEAD_INIT(&Typetype)
0, /*ob_size*/
"bitmap", /*tp_name*/
sizeof(bitmapobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- bitmap_dealloc, /*tp_dealloc*/
+ (destructor)bitmap_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- bitmap_getattr, /*tp_getattr*/
- bitmap_setattr, /*tp_setattr*/
+ (getattrfunc)bitmap_getattr, /*tp_getattr*/
+ (setattrfunc)bitmap_setattr, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
};
@@ -1852,29 +1852,29 @@ window_getxwindowid(self, args)
#endif
static struct methodlist window_methods[] = {
- {"begindrawing",window_begindrawing},
- {"change", window_change},
- {"close", window_close},
- {"getdocsize", window_getdocsize},
- {"getorigin", window_getorigin},
- {"gettitle", window_gettitle},
- {"getwinpos", window_getwinpos},
- {"getwinsize", window_getwinsize},
- {"menucreate", window_menucreate},
- {"scroll", window_scroll},
- {"setactive", window_setactive},
- {"setdocsize", window_setdocsize},
- {"setorigin", window_setorigin},
- {"setselection",window_setselection},
- {"settimer", window_settimer},
- {"settitle", window_settitle},
- {"setwincursor",window_setwincursor},
- {"setwinpos", window_setwinpos},
- {"setwinsize", window_setwinsize},
- {"show", window_show},
- {"textcreate", window_textcreate},
+ {"begindrawing",(method)window_begindrawing},
+ {"change", (method)window_change},
+ {"close", (method)window_close},
+ {"getdocsize", (method)window_getdocsize},
+ {"getorigin", (method)window_getorigin},
+ {"gettitle", (method)window_gettitle},
+ {"getwinpos", (method)window_getwinpos},
+ {"getwinsize", (method)window_getwinsize},
+ {"menucreate", (method)window_menucreate},
+ {"scroll", (method)window_scroll},
+ {"setactive", (method)window_setactive},
+ {"setdocsize", (method)window_setdocsize},
+ {"setorigin", (method)window_setorigin},
+ {"setselection",(method)window_setselection},
+ {"settimer", (method)window_settimer},
+ {"settitle", (method)window_settitle},
+ {"setwincursor",(method)window_setwincursor},
+ {"setwinpos", (method)window_setwinpos},
+ {"setwinsize", (method)window_setwinsize},
+ {"show", (method)window_show},
+ {"textcreate", (method)window_textcreate},
#ifdef CWI_HACKS
- {"getxwindowid",window_getxwindowid},
+ {"getxwindowid",(method)window_getxwindowid},
#endif
{NULL, NULL} /* sentinel */
};
@@ -1926,17 +1926,17 @@ window_setattr(wp, name, v)
return dictinsert(wp->w_attr, name, v);
}
-typeobject Windowtype = {
+static typeobject Windowtype = {
OB_HEAD_INIT(&Typetype)
0, /*ob_size*/
"window", /*tp_name*/
sizeof(windowobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- window_dealloc, /*tp_dealloc*/
+ (destructor)window_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- window_getattr, /*tp_getattr*/
- window_setattr, /*tp_setattr*/
+ (getattrfunc)window_getattr, /*tp_getattr*/
+ (setattrfunc)window_setattr, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
};
@@ -2515,23 +2515,24 @@ static struct methodlist stdwin_methods[] = {
{"setdefwinsize", stdwin_setdefwinsize},
/* Text measuring methods borrow code from drawing objects: */
- {"baseline", drawing_baseline},
- {"lineheight", drawing_lineheight},
- {"textbreak", drawing_textbreak},
- {"textwidth", drawing_textwidth},
+ {"baseline", (method)drawing_baseline},
+ {"lineheight", (method)drawing_lineheight},
+ {"textbreak", (method)drawing_textbreak},
+ {"textwidth", (method)drawing_textwidth},
/* Same for font setting methods: */
- {"setfont", drawing_setfont},
+ {"setfont", (method)drawing_setfont},
/* Same for color setting/getting methods: */
- {"getbgcolor", drawing_getbgcolor},
- {"getfgcolor", drawing_getfgcolor},
- {"setbgcolor", drawing_setbgcolor},
- {"setfgcolor", drawing_setfgcolor},
+ {"getbgcolor", (method)drawing_getbgcolor},
+ {"getfgcolor", (method)drawing_getfgcolor},
+ {"setbgcolor", (method)drawing_setbgcolor},
+ {"setfgcolor", (method)drawing_setfgcolor},
{NULL, NULL} /* sentinel */
};
+#ifndef macintosh
static int
checkstringlist(args, ps, pn)
object *args;
@@ -2592,6 +2593,7 @@ putbackstringlist(list, s, n)
DECREF(newlist);
return 1;
}
+#endif /* macintosh */
void
initstdwin()
@@ -2601,6 +2603,9 @@ initstdwin()
char buf[1000];
if (!inited) {
+#ifdef macintosh
+ winit();
+#else
int argc = 0;
char **argv = NULL;
object *sys_argv = sysget("argv");
@@ -2625,6 +2630,7 @@ initstdwin()
if (!putbackstringlist(sys_argv, argv, argc))
err_clear();
}
+#endif
inited = 1;
}
m = initmodule("stdwin", stdwin_methods);
@@ -2634,7 +2640,7 @@ initstdwin()
StdwinError = newstringobject("stdwin.error");
if (StdwinError == NULL || dictinsert(d, "error", StdwinError) != 0)
fatal("can't define stdwin.error");
-#ifdef USE_THREAD
+#ifdef WITH_THREAD
StdwinLock = allocate_lock();
if (StdwinLock == NULL)
fatal("can't allocate stdwin lock");
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index fe67ca09c3..c980272795 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -31,6 +31,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* XXX This file assumes that the <ctype.h> is*() functions
XXX are defined for all 8-bit characters! */
+#include <errno.h>
+
static object *
strop_split(self, args)
@@ -236,7 +238,7 @@ strop_rindex(self, args)
object *args;
{
char *s, *sub;
- int len, n, i;
+ int len, n, i, j;
if (getargs(args, "(s#s#i)", &s, &len, &sub, &n, &i)) {
if (i < 0)
@@ -250,16 +252,16 @@ strop_rindex(self, args)
err_clear();
if (!getargs(args, "(s#s#)", &s, &len, &sub, &n))
return NULL;
- i = len;
+ i = 0;
}
if (n == 0)
return newintobject((long)i);
- for (i -= n; i >= 0; --i)
- if (s[i] == sub[0] &&
- (n == 1 || strncmp(&s[i+1], &sub[1], n-1) == 0))
- return newintobject((long)i);
+ for (j = len-n; j >= i; --j)
+ if (s[j] == sub[0] &&
+ (n == 1 || strncmp(&s[j+1], &sub[1], n-1) == 0))
+ return newintobject((long)j);
err_setstr(ValueError, "substring not found");
return NULL;
@@ -408,9 +410,108 @@ strop_swapcase(self, args)
}
+static object *
+strop_atoi(self, args)
+ object *self; /* Not used */
+ object *args;
+{
+ extern long mystrtol PROTO((const char *, char **, int));
+ extern unsigned long mystrtoul PROTO((const char *, char **, int));
+ char *s, *end;
+ int base = 10;
+ long x;
+
+ if (args != NULL && is_tupleobject(args)) {
+ if (!getargs(args, "(si)", &s, &base))
+ return NULL;
+ if (base != 0 && base < 2 || base > 36) {
+ err_setstr(ValueError, "invalid base for atoi()");
+ return NULL;
+ }
+ }
+ else if (!getargs(args, "s", &s))
+ return NULL;
+ errno = 0;
+ if (base == 0 && s[0] == '0')
+ x = (long) mystrtoul(s, &end, base);
+ else
+ x = mystrtol(s, &end, base);
+ if (*end != '\0') {
+ err_setstr(ValueError, "invalid literal for atoi()");
+ return NULL;
+ }
+ else if (errno != 0) {
+ err_setstr(OverflowError, "atoi() literal too large");
+ return NULL;
+ }
+ return newintobject(x);
+}
+
+
+static object *
+strop_atol(self, args)
+ object *self; /* Not used */
+ object *args;
+{
+ char *s, *end;
+ int base = 10;
+ object *x;
+
+ if (args != NULL && is_tupleobject(args)) {
+ if (!getargs(args, "(si)", &s, &base))
+ return NULL;
+ if (base != 0 && base < 2 || base > 36) {
+ err_setstr(ValueError, "invalid base for atol()");
+ return NULL;
+ }
+ }
+ else if (!getargs(args, "s", &s))
+ return NULL;
+ x = long_escan(s, &end, base);
+ if (x == NULL)
+ return NULL;
+ if (base == 0 && (*end == 'l' || *end == 'L'))
+ end++;
+ if (*end != '\0') {
+ err_setstr(ValueError, "invalid literal for atol()");
+ DECREF(x);
+ return NULL;
+ }
+ return x;
+}
+
+
+static object *
+strop_atof(self, args)
+ object *self; /* Not used */
+ object *args;
+{
+ extern double strtod PROTO((const char *, char **));
+ char *s, *end;
+ double x;
+
+ if (!getargs(args, "s", &s))
+ return NULL;
+ errno = 0;
+ x = strtod(s, &end);
+ if (*end != '\0') {
+ err_setstr(ValueError, "invalid literal for atof()");
+ return NULL;
+ }
+ else if (errno != 0) {
+ err_setstr(OverflowError, "atof() literal too large");
+ return NULL;
+ }
+ return newfloatobject(x);
+}
+
+
/* List of functions defined in the module */
static struct methodlist strop_methods[] = {
+ {"atof", strop_atof},
+ {"atoi", strop_atoi},
+ {"atol", strop_atol},
{"index", strop_index},
{"joinfields", strop_joinfields},
{"lower", strop_lower},
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index 03e8f18291..7d8815e260 100644
--- a/Modules/structmodule.c
+++ b/Modules/structmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
diff --git a/Modules/sunaudiodev.c b/Modules/sunaudiodev.c
index 5bd7249e6b..a2f3869d85 100644
--- a/Modules/sunaudiodev.c
+++ b/Modules/sunaudiodev.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -28,10 +28,14 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h"
#include "structmember.h"
+#ifdef HAVE_SYS_AUDIOIO_H
+#define SOLARIS
+#endif
+
#include <stropts.h>
#include <sys/ioctl.h>
#ifdef SOLARIS
-#include <multimedia/libaudio.h>
+#include <sys/audioio.h>
#else
#include <sun/audioio.h>
#endif
@@ -52,8 +56,8 @@ typedef struct {
audio_info_t ai;
} sadstatusobject;
-extern typeobject Sadtype; /* Really static, forward */
-extern typeobject Sadstatustype; /* Really static, forward */
+staticforward typeobject Sadtype;
+staticforward typeobject Sadstatustype;
static sadstatusobject *sads_alloc(); /* Forward */
static object *SunAudioError;
@@ -427,17 +431,17 @@ sads_setattr(xp, name, v)
static typeobject Sadtype = {
OB_HEAD_INIT(&Typetype)
- 0, /*ob_size*/
- "sun_audio_device", /*tp_name*/
- sizeof(sadobject), /*tp_size*/
- 0, /*tp_itemsize*/
+ 0, /*ob_size*/
+ "sun_audio_device", /*tp_name*/
+ sizeof(sadobject), /*tp_size*/
+ 0, /*tp_itemsize*/
/* methods */
- sad_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- sad_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
+ (destructor)sad_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)sad_getattr, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
};
static typeobject Sadstatustype = {
@@ -447,12 +451,12 @@ static typeobject Sadstatustype = {
sizeof(sadstatusobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- sads_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- sads_getattr, /*tp_getattr*/
- sads_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
+ (destructor)sads_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)sads_getattr, /*tp_getattr*/
+ (setattrfunc)sads_setattr, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
};
/* ------------------------------------------------------------------- */
diff --git a/Modules/svmodule.c b/Modules/svmodule.c
index d3fda30f54..dad2414f18 100644
--- a/Modules/svmodule.c
+++ b/Modules/svmodule.c
@@ -1,5 +1,5 @@
/**********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -227,7 +227,7 @@ svc_lrectwrite(self, args)
#endif
static object *
-writefile(self, args)
+svc_writefile(self, args)
captureobject *self;
object *args;
{
@@ -276,19 +276,19 @@ svc_FindVisibleRegion(self, args)
}
static struct methodlist capture_methods[] = {
- {"YUVtoRGB", svc_YUVtoRGB},
- {"RGB8toRGB32", svc_RGB8toRGB32},
- {"InterleaveFields", svc_InterleaveFields},
- {"UnlockCaptureData", svc_UnlockCaptureData},
- {"FindVisibleRegion", svc_FindVisibleRegion},
- {"GetFields", svc_GetFields},
- {"YUVtoYUV422DC", svc_YUVtoYUV422DC},
- {"YUVtoYUV422DC_quarter",svc_YUVtoYUV422DC_quarter},
- {"YUVtoYUV422DC_sixteenth",svc_YUVtoYUV422DC_sixteenth},
+ {"YUVtoRGB", (method)svc_YUVtoRGB},
+ {"RGB8toRGB32", (method)svc_RGB8toRGB32},
+ {"InterleaveFields", (method)svc_InterleaveFields},
+ {"UnlockCaptureData", (method)svc_UnlockCaptureData},
+ {"FindVisibleRegion", (method)svc_FindVisibleRegion},
+ {"GetFields", (method)svc_GetFields},
+ {"YUVtoYUV422DC", (method)svc_YUVtoYUV422DC},
+ {"YUVtoYUV422DC_quarter",(method)svc_YUVtoYUV422DC_quarter},
+ {"YUVtoYUV422DC_sixteenth",(method)svc_YUVtoYUV422DC_sixteenth},
#ifdef USE_GL
- {"lrectwrite", svc_lrectwrite},
+ {"lrectwrite", (method)svc_lrectwrite},
#endif
- {"writefile", writefile},
+ {"writefile", (method)svc_writefile},
{NULL, NULL} /* sentinel */
};
@@ -316,17 +316,17 @@ capture_getattr(self, name)
typeobject Capturetype = {
OB_HEAD_INIT(&Typetype)
- 0, /*ob_size*/
- "capture", /*tp_name*/
- sizeof(captureobject), /*tp_size*/
- 0, /*tp_itemsize*/
+ 0, /*ob_size*/
+ "capture", /*tp_name*/
+ sizeof(captureobject), /*tp_size*/
+ 0, /*tp_itemsize*/
/* methods */
- capture_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- capture_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
+ (destructor)capture_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)capture_getattr, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
};
static object *
@@ -835,25 +835,25 @@ sv_SetParam(self, args)
}
static struct methodlist svideo_methods[] = {
- {"BindGLWindow", sv_BindGLWindow},
- {"EndContinuousCapture",sv_EndContinuousCapture},
- {"IsVideoDisplayed", sv_IsVideoDisplayed},
- {"OutputOffset", sv_OutputOffset},
- {"PutFrame", sv_PutFrame},
- {"QuerySize", sv_QuerySize},
- {"SetSize", sv_SetSize},
- {"SetStdDefaults", sv_SetStdDefaults},
- {"UseExclusive", sv_UseExclusive},
- {"WindowOffset", sv_WindowOffset},
- {"InitContinuousCapture",sv_InitContinuousCapture},
- {"CaptureBurst", sv_CaptureBurst},
- {"CaptureOneFrame", sv_CaptureOneFrame},
- {"GetCaptureData", sv_GetCaptureData},
- {"CloseVideo", sv_CloseVideo},
- {"LoadMap", sv_LoadMap},
- {"GetParam", sv_GetParam},
- {"GetParamRange", sv_GetParamRange},
- {"SetParam", sv_SetParam},
+ {"BindGLWindow", (method)sv_BindGLWindow},
+ {"EndContinuousCapture",(method)sv_EndContinuousCapture},
+ {"IsVideoDisplayed", (method)sv_IsVideoDisplayed},
+ {"OutputOffset", (method)sv_OutputOffset},
+ {"PutFrame", (method)sv_PutFrame},
+ {"QuerySize", (method)sv_QuerySize},
+ {"SetSize", (method)sv_SetSize},
+ {"SetStdDefaults", (method)sv_SetStdDefaults},
+ {"UseExclusive", (method)sv_UseExclusive},
+ {"WindowOffset", (method)sv_WindowOffset},
+ {"InitContinuousCapture",(method)sv_InitContinuousCapture},
+ {"CaptureBurst", (method)sv_CaptureBurst},
+ {"CaptureOneFrame", (method)sv_CaptureOneFrame},
+ {"GetCaptureData", (method)sv_GetCaptureData},
+ {"CloseVideo", (method)sv_CloseVideo},
+ {"LoadMap", (method)sv_LoadMap},
+ {"GetParam", (method)sv_GetParam},
+ {"GetParamRange", (method)sv_GetParamRange},
+ {"SetParam", (method)sv_SetParam},
{NULL, NULL} /* sentinel */
};
@@ -930,9 +930,9 @@ typeobject Svtype = {
sizeof(svobject), /*tp_size*/
0, /*tp_itemsize*/
/* methods */
- svideo_dealloc, /*tp_dealloc*/
+ (destructor)svideo_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- svideo_getattr, /*tp_getattr*/
+ (getattrfunc)svideo_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
@@ -973,10 +973,10 @@ sv_OpenVideo(self, args)
}
static struct methodlist sv_methods[] = {
- {"InterleaveFields", sv_InterleaveFields},
- {"RGB8toRGB32", sv_RGB8toRGB32},
- {"YUVtoRGB", sv_YUVtoRGB},
- {"OpenVideo", sv_OpenVideo},
+ {"InterleaveFields", (method)sv_InterleaveFields},
+ {"RGB8toRGB32", (method)sv_RGB8toRGB32},
+ {"YUVtoRGB", (method)sv_YUVtoRGB},
+ {"OpenVideo", (method)sv_OpenVideo},
{NULL, NULL} /* Sentinel */
};
diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c
index 40169a3a4f..301f060ec8 100644
--- a/Modules/threadmodule.c
+++ b/Modules/threadmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -29,9 +29,14 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h"
#include "ceval.h"
+#ifndef WITH_THREAD
+Error! The rest of Python is not compiled with thread support.
+Rerun configure, adding a --with-thread option.
+#endif
+
#include "thread.h"
-int threads_started = 0;
+extern int threads_started;
static object *ThreadError;
@@ -43,7 +48,7 @@ typedef struct {
type_lock lock_lock;
} lockobject;
-extern typeobject Locktype; /* Really static, forward */
+staticforward typeobject Locktype;
#define is_lockobject(v) ((v)->ob_type == &Locktype)
@@ -147,12 +152,12 @@ lock_locked_lock(self, args)
}
static struct methodlist lock_methods[] = {
- {"acquire_lock", lock_acquire_lock},
- {"acquire", lock_acquire_lock},
- {"release_lock", lock_release_lock},
- {"release", lock_release_lock},
- {"locked_lock", lock_locked_lock},
- {"locked", lock_locked_lock},
+ {"acquire_lock", (method)lock_acquire_lock},
+ {"acquire", (method)lock_acquire_lock},
+ {"release_lock", (method)lock_release_lock},
+ {"release", (method)lock_release_lock},
+ {"locked_lock", (method)lock_locked_lock},
+ {"locked", (method)lock_locked_lock},
{NULL, NULL} /* sentinel */
};
@@ -166,17 +171,17 @@ lock_getattr(self, name)
static typeobject Locktype = {
OB_HEAD_INIT(&Typetype)
- 0, /*ob_size*/
- "lock", /*tp_name*/
- sizeof(lockobject), /*tp_size*/
- 0, /*tp_itemsize*/
+ 0, /*ob_size*/
+ "lock", /*tp_name*/
+ sizeof(lockobject), /*tp_size*/
+ 0, /*tp_itemsize*/
/* methods */
- lock_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- lock_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
+ (destructor)lock_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)lock_getattr, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
};
@@ -238,6 +243,7 @@ thread_exit_thread(self, args)
for (;;) { } /* Should not be reached */
}
+#ifndef NO_EXIT_PROG
static object *
thread_exit_prog(self, args)
object *self; /* Not used */
@@ -249,6 +255,7 @@ thread_exit_prog(self, args)
goaway(sts); /* Calls exit_prog(sts) or _exit_prog(sts) */
for (;;) { } /* Should not be reached */
}
+#endif
static object *
thread_allocate_lock(self, args)
@@ -260,14 +267,33 @@ thread_allocate_lock(self, args)
return (object *) newlockobject();
}
+static object *
+thread_get_ident(self, args)
+ object *self; /* Not used */
+ object *args;
+{
+ long ident;
+ if (!getnoarg(args))
+ return NULL;
+ ident = get_thread_ident();
+ if (ident == -1) {
+ err_setstr(ThreadError, "no current thread ident");
+ return NULL;
+ }
+ return newintobject(ident);
+}
+
static struct methodlist thread_methods[] = {
- {"start_new_thread", thread_start_new_thread},
- {"start_new", thread_start_new_thread},
- {"allocate_lock", thread_allocate_lock},
- {"allocate", thread_allocate_lock},
- {"exit_thread", thread_exit_thread},
- {"exit", thread_exit_thread},
- {"exit_prog", thread_exit_prog},
+ {"start_new_thread", (method)thread_start_new_thread},
+ {"start_new", (method)thread_start_new_thread},
+ {"allocate_lock", (method)thread_allocate_lock},
+ {"allocate", (method)thread_allocate_lock},
+ {"exit_thread", (method)thread_exit_thread},
+ {"exit", (method)thread_exit_thread},
+ {"get_ident", (method)thread_get_ident},
+#ifndef NO_EXIT_PROG
+ {"exit_prog", (method)thread_exit_prog},
+#endif
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 5406907d67..d35eba8d33 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -28,210 +28,94 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "modsupport.h"
#include "ceval.h"
-#include "sigtype.h"
-
-#include <signal.h>
-#include <setjmp.h>
-
-#ifdef BSD_TIME
-#define HAVE_GETTIMEOFDAY
-#include "myselect.h" /* Implies <sys/types.h>, <sys/time.h>, <sys/param.h> */
+#ifdef macintosh
+#include <time.h>
+#else
+#include <sys/types.h>
#endif
-#ifdef macintosh
-#define NO_UNISTD
+#ifdef QUICKWIN
+#include <io.h>
#endif
-#ifndef NO_UNISTD
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-/* What happens here is not trivial.
- The BSD_TIME code needs <sys/time.h> (for struct timeval).
- The rest of the code needs only time_t, except some MS-DOS
- code which needs clock_t as well.
- Standard C says that time_t is defined in <time.h>, and
- does not have <sys/types.h>; THINK C agrees (MS-DOS too?).
- What's worse, in pure 4.3 BSD, older SunOS versions, and
- probably everything derived from BSD, you can't #include
- both <time.h> and <sys/time.h> in the same file, since
- <sys/time.h> includes <time.h> without any protection,
- and <time.h> contains a typedef, which can't be parsed twice!
- So on traditional UNIX systems we include <sys/types.h>
- and <sys/time.h> and hope this implies <time.h> and time_t,
- while on other systems, including conforming Standard C
- systems (where 'unix' can't be defined), we rely on <time.h>.
- Still one problem: BSD_TIME won't work with strict Standard C...
-*/
-
-#ifdef unix
-#include <sys/types.h>
-#include <sys/time.h> /* Implies <time.h> everywhere, as far as I know */
-#else /* !unix */
-#include <time.h>
-#endif /* !unix */
-
-#ifdef SYSV
-#if defined(sun) && defined(__STDC__)
-/* Temporary hack for Solaris 2. */
-#define _timezone timezone
-#define _altzone altzone
-#define _daylight daylight
-#define _tzname tzname
+#ifdef HAVE_SELECT
+#include "myselect.h"
+#else
+#include "mytime.h"
#endif
-/* Access timezone stuff */
-#ifdef OLDTZ /* ANSI prepends underscore to these */
-#define _timezone timezone /* seconds to be added to GMT */
-#define _altzone 0 /* _timezone if daylight saving time */
-#define _daylight 0 /* if zero, _altzone is not available*/
-#define _tzname tzname /* Name of timezone and altzone */
+
+#ifdef HAVE_FTIME
+#include <sys/timeb.h>
#endif
-#ifdef NOALTTZ /* if system doesn't support alt tz */
-#undef _daylight
-#undef _altzone
-#define _daylight 0
-#define _altzone 0
+
+#ifdef _M_IX86
+#include <windows.h>
+#define timezone _timezone
#endif
-#endif /* SYSV */
/* Forward declarations */
-static void floatsleep PROTO((double));
-static long millitimer PROTO((void));
-
-/* Time methods */
+static int floatsleep PROTO((double));
+static double floattime PROTO(());
static object *
time_time(self, args)
object *self;
object *args;
{
-#ifdef HAVE_GETTIMEOFDAY
- struct timeval t;
- struct timezone tz;
+ double secs;
if (!getnoarg(args))
return NULL;
- if (gettimeofday(&t, &tz) != 0) {
+ secs = floattime();
+ if (secs == 0.0) {
err_errno(IOError);
return NULL;
}
- return newfloatobject(t.tv_sec*1.0 + t.tv_usec*0.000001);
-#else /* !HAVE_GETTIMEOFDAY */
- time_t secs;
- if (!getnoarg(args))
- return NULL;
- time(&secs);
-#ifdef macintosh
-/* The Mac epoch is 1904, while UNIX uses 1970; Python prefers 1970 */
-/* Moreover, the Mac returns local time. This we cannot fix... */
-#define TIMEDIFF ((time_t) \
- (((1970-1904)*365L + (1970-1904)/4) * 24 * 3600))
- secs -= TIMEDIFF;
-#endif
- return newfloatobject((double)secs);
-#endif /* !HAVE_GETTIMEOFDAY */
+ return newfloatobject(secs);
}
-static jmp_buf sleep_intr;
+#ifdef HAVE_CLOCK
-/* ARGSUSED */
-static void
-sleep_catcher(sig)
- int sig; /* Not used but required by interface */
-{
- longjmp(sleep_intr, 1);
-}
+#ifndef CLOCKS_PER_SEC
+#define CLOCKS_PER_SEC 1000000
+#endif
static object *
-time_sleep(self, args)
+time_clock(self, args)
object *self;
object *args;
{
- double secs;
- SIGTYPE (*sigsave)() = 0; /* Initialized to shut lint up */
- if (!getargs(args, "d", &secs))
- return NULL;
- BGN_SAVE
- if (setjmp(sleep_intr)) {
- RET_SAVE
- signal(SIGINT, sigsave);
- err_set(KeyboardInterrupt);
+ if (!getnoarg(args))
return NULL;
- }
- sigsave = signal(SIGINT, SIG_IGN);
- if (sigsave != (SIGTYPE (*)()) SIG_IGN)
- signal(SIGINT, sleep_catcher);
- floatsleep(secs);
- END_SAVE
- signal(SIGINT, sigsave);
- INCREF(None);
- return None;
+ return newfloatobject(((double)clock()) / CLOCKS_PER_SEC);
}
-
-#ifdef macintosh
-#define DO_MILLI
-#endif
-
-#ifdef AMOEBA
-#define DO_MILLI
-extern long sys_milli();
-#define millitimer sys_milli
-#endif /* AMOEBA */
-
-#ifdef BSD_TIME
-#define DO_MILLI
-#endif /* BSD_TIME */
-
-#ifdef MSDOS
-#define DO_MILLI
-#endif
-
-#ifdef DO_MILLI
+#endif /* HAVE_CLOCK */
static object *
-time_millisleep(self, args)
+time_sleep(self, args)
object *self;
object *args;
{
- long msecs;
- SIGTYPE (*sigsave)();
- if (!getlongarg(args, &msecs))
+ double secs;
+ if (!getargs(args, "d", &secs))
return NULL;
BGN_SAVE
- if (setjmp(sleep_intr)) {
+ if (floatsleep(secs) != 0) {
RET_SAVE
- signal(SIGINT, sigsave);
- err_set(KeyboardInterrupt);
return NULL;
}
- sigsave = signal(SIGINT, SIG_IGN);
- if (sigsave != (SIGTYPE (*)()) SIG_IGN)
- signal(SIGINT, sleep_catcher);
- floatsleep(msecs / 1000.0);
END_SAVE
- signal(SIGINT, sigsave);
INCREF(None);
return None;
}
static object *
-time_millitimer(self, args)
- object *self;
- object *args;
-{
- long msecs;
- if (!getnoarg(args))
- return NULL;
- msecs = millitimer();
- return newintobject(msecs);
-}
-
-#endif /* DO_MILLI */
-
-
-static object *
time_convert(when, function)
time_t when;
- struct tm * (*function) PROTO((time_t *));
+ struct tm * (*function) PROTO((const time_t *));
{
struct tm *p = function(&when);
return mkvalue("(iiiiiiiii)",
@@ -324,8 +208,6 @@ time_ctime(self, args)
return newstringobject(p);
}
-/* Some very old systems may not have mktime(). Comment it out then! */
-
static object *
time_mktime(self, args)
object *self;
@@ -338,12 +220,11 @@ time_mktime(self, args)
}
static struct methodlist time_methods[] = {
-#ifdef DO_MILLI
- {"millisleep", time_millisleep},
- {"millitimer", time_millitimer},
-#endif /* DO_MILLI */
- {"sleep", time_sleep},
{"time", time_time},
+#ifdef HAVE_CLOCK
+ {"clock", time_clock},
+#endif
+ {"sleep", time_sleep},
{"gmtime", time_gmtime},
{"localtime", time_localtime},
{"asctime", time_asctime},
@@ -352,26 +233,32 @@ static struct methodlist time_methods[] = {
{NULL, NULL} /* sentinel */
};
-
void
inittime()
{
object *m, *d;
m = initmodule("time", time_methods);
d = getmoduledict(m);
-#ifdef SYSV
+#ifdef HAVE_TZNAME
tzset();
- dictinsert(d, "timezone", newintobject((long)_timezone));
- dictinsert(d, "altzone", newintobject((long)_altzone));
- dictinsert(d, "daylight", newintobject((long)_daylight));
- dictinsert(d, "tzname", mkvalue("(zz)", _tzname[0], _tzname[1]));
-#else /* !SYSV */
+ dictinsert(d, "timezone", newintobject((long)timezone));
+#ifdef HAVE_ALTZONE
+ dictinsert(d, "altzone", newintobject((long)altzone));
+#else
+ dictinsert(d, "altzone", newintobject((long)timezone-3600));
+#endif
+ dictinsert(d, "daylight", newintobject((long)daylight));
+ dictinsert(d, "tzname", mkvalue("(zz)", tzname[0], tzname[1]));
+#else /* !HAVE_TZNAME */
+#if HAVE_TM_ZONE
{
#define YEAR ((time_t)((365 * 24 + 6) * 3600))
time_t t;
struct tm *p;
long winterzone, summerzone;
char wintername[10], summername[10];
+ /* XXX This won't work on the southern hemisphere.
+ XXX Anybody got a better idea? */
t = (time((time_t *)0) / YEAR) * YEAR;
p = localtime(&t);
winterzone = -p->tm_gmtoff;
@@ -389,68 +276,54 @@ inittime()
dictinsert(d, "tzname",
mkvalue("(zz)", wintername, summername));
}
-#endif /* !SYSV */
+#endif /* HAVE_TM_ZONE */
+#endif /* !HAVE_TZNAME */
}
-#ifdef macintosh
-
-#define MacTicks (* (long *)0x16A)
+/* Implement floattime() for various platforms */
-#ifdef THINK_C_3_0
-sleep(secs)
- int secs;
+static double
+floattime()
{
- register long deadline;
-
- deadline = MacTicks + mecs * 60;
- while (MacTicks < deadline) {
- if (intrcheck())
- sleep_catcher(SIGINT);
- }
-}
-#endif
-
-static void
-floatsleep(secs)
- double secs;
-{
- register long deadline;
-
- deadline = MacTicks + (long)(secs * 60.0);
- while (MacTicks < deadline) {
- if (intrcheck())
- sleep_catcher(SIGINT);
- }
-}
-
-static long
-millitimer()
-{
- return MacTicks * 50 / 3; /* MacTicks * 1000 / 60 */
+ /* There are three ways to get the time:
+ (1) gettimeofday() -- resolution in microseconds
+ (2) ftime() -- resolution in milliseconds
+ (3) time() -- resolution in seconds
+ In all cases the return value is a float in seconds.
+ Since on some systems (e.g. SCO ODT 3.0) gettimeofday() may
+ fail, so we fall back on ftime() or time().
+ Note: clock resolution does not imply clock accuracy! */
+#ifdef HAVE_GETTIMEOFDAY
+ {
+ struct timeval t;
+ if (gettimeofday(&t, (struct timezone *)NULL) == 0)
+ return (double)t.tv_sec + t.tv_usec*0.000001;
+ }
+#endif /* !HAVE_GETTIMEOFDAY */
+ {
+#ifdef HAVE_FTIME
+ struct timeb t;
+ ftime(&t);
+ return (double)t.time + t.millitm*0.001;
+#else /* !HAVE_FTIME */
+ time_t secs;
+ time(&secs);
+ return (double)secs;
+#endif /* !HAVE_FTIME */
+ }
}
-#endif /* macintosh */
+/* Implement floatsleep() for various platforms.
+ When interrupted (or when another error occurs), return -1 and
+ set an exception; else return 0. */
-#ifdef unix
-
-#ifdef BSD_TIME
-
-static long
-millitimer()
-{
- struct timeval t;
- struct timezone tz;
- if (gettimeofday(&t, &tz) != 0)
- return -1;
- return t.tv_sec*1000 + t.tv_usec/1000;
-}
-
-static void
+static int
floatsleep(secs)
double secs;
{
+#ifdef HAVE_SELECT
struct timeval t;
double frac;
extern double fmod PROTO((double, double));
@@ -459,51 +332,57 @@ floatsleep(secs)
secs = floor(secs);
t.tv_sec = (long)secs;
t.tv_usec = (long)(frac*1000000.0);
- (void) select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t);
-}
-
-#else /* !BSD_TIME */
-
-static void
-floatsleep(secs)
- double secs;
-{
- sleep((int)secs);
-}
-
-#endif /* !BSD_TIME */
-
-#endif /* unix */
-
-
+ if (select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t) != 0) {
+ err_errno(IOError);
+ return -1;
+ }
+#else /* !HAVE_SELECT */
+#ifdef macintosh
+#define MacTicks (* (long *)0x16A)
+ long deadline;
+ deadline = MacTicks + (long)(secs * 60.0);
+ while (MacTicks < deadline) {
+ if (sigcheck())
+ return -1;
+ }
+#else /* !macintosh */
#ifdef MSDOS
-
-#ifndef CLOCKS_PER_SEC
-#define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */
+ struct timeb t1, t2;
+ double frac;
+ extern double fmod PROTO((double, double));
+ extern double floor PROTO((double));
+ if (secs <= 0.0)
+ return;
+ frac = fmod(secs, 1.0);
+ secs = floor(secs);
+ ftime(&t1);
+ t2.time = t1.time + (int)secs;
+ t2.millitm = t1.millitm + (int)(frac*1000.0);
+ while (t2.millitm >= 1000) {
+ t2.time++;
+ t2.millitm -= 1000;
+ }
+ for (;;) {
+#ifdef QUICKWIN
+ _wyield();
#endif
-
-static void
-floatsleep(secs)
- double secs;
-{
- delay(long(secs/1000.0));
-}
-
-static long
-millitimer()
-{
- clock_t ticks;
-
- ticks = clock(); /* ticks since program start */
- return ticks * CLOCKS_PER_SEC;/* XXX shouldn't this be different? */
-}
-
-floatsleep(secs)
- double secs;
-{
- clock_t t= clock( );
- while( (clock()-t)/CLOCKS_PER_SEC<secs )
- ;
+ if (sigcheck())
+ return -1;
+ ftime(&t1);
+ if (t1.time > t2.time ||
+ t1.time == t2.time && t1.millitm >= t2.millitm)
+ break;
+ }
+#else /* !MSDOS */
+#ifdef _M_IX86
+ /* XXX Can't interrupt this sleep */
+ Sleep((int)(secs*1000));
+#else /* _M_IX86 */
+ /* XXX Can't interrupt this sleep */
+ sleep((int)secs);
+#endif /* _M_IX86 */
+#endif /* !MSDOS */
+#endif /* !macintosh */
+#endif /* !HAVE_SELECT */
+ return 0;
}
-
-#endif /* MSDOS */
diff --git a/Modules/version.c b/Modules/version.c
deleted file mode 100644
index d71b59fa83..0000000000
--- a/Modules/version.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
-Amsterdam, The Netherlands.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the names of Stichting Mathematisch
-Centrum or CWI not be used in advertising or publicity pertaining to
-distribution of the software without specific, written prior permission.
-
-STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
-THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
-FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-******************************************************************/
-
-/* Python version information */
-
-/* Return the version string. This is constructed from the official
- version number, the patch level, and the current date (if known to
- the compiler, else a manually inserted date). */
-
-#define VERSION "1.0.%d ALPHA (%s)"
-
-#ifdef __DATE__
-#define DATE __DATE__
-#else
-#define DATE ">= 21 Dec 1993"
-#endif
-
-char *
-getversion()
-{
- static char version[80];
- sprintf(version, VERSION, PATCHLEVEL, DATE);
- return version;
-}
-
-
-/* Return the copyright string. This is updated manually. */
-
-char *
-getcopyright()
-{
- return
-"Copyright 1990, 1991, 1992, 1993 Stichting Mathematisch Centrum, Amsterdam";
-}
-
-
-/* Return the initial python search path. This is called once from
- initsys() to initialize sys.path.
- The environment variable PYTHONPATH is fetched and the default path
- appended. (The Mac has no environment variables, so there the
- default path is always returned.) The default path may be passed
- to the preprocessor; if not, a system-dependent default is used. */
-
-#ifndef PYTHONPATH
-#ifdef macintosh
-#define PYTHONPATH ": :lib :demo"
-#endif /* macintosh */
-#endif /* !PYTHONPATH */
-
-#ifndef PYTHONPATH
-#ifdef MSDOS
-#define PYTHONPATH ".;..\\lib;\\python\\lib"
-#endif /* MSDOS */
-#endif /* !PYTHONPATH */
-
-#ifndef PYTHONPATH
-#define PYTHONPATH ".:/usr/local/lib/python"
-#endif /* !PYTHONPATH */
-
-extern char *getenv();
-
-char *
-getpythonpath()
-{
-#ifdef macintosh
- return PYTHONPATH;
-#else /* !macintosh */
- char *path = getenv("PYTHONPATH");
- char *defpath = PYTHONPATH;
- char *buf;
- char *p;
- int n;
-
- if (path == 0 || *path == '\0')
- return defpath;
- n = strlen(path) + strlen(defpath) + 2;
- buf = malloc(n);
- if (buf == NULL)
- return path; /* XXX too bad -- but not likely */
- strcpy(buf, path);
- p = buf + strlen(buf);
- *p++ = DELIM;
- strcpy(p, defpath);
- return buf;
-#endif /* !macintosh */
-}
-
-
-/* Table of built-in modules.
- These are initialized when first imported.
- Note: selection of optional extensions is now generally done by the
- mkext.py script in ../Extensions, but for non-UNIX systems most
- well-known extensions are still listed here. */
-
-/* Standard modules */
-
-#ifdef USE_AL
-extern void inital();
-#endif
-#ifdef USE_AMOEBA
-extern void initamoeba();
-#endif
-#ifdef USE_AUDIO
-extern void initaudio();
-#endif
-#ifdef USE_AUDIOOP
-extern void initaudioop();
-#endif
-#ifdef USE_CD
-extern void initcd();
-#endif
-#ifdef USE_CL
-extern void initcl();
-#endif
-#ifdef USE_DBM
-extern void initdbm();
-#endif
-#ifdef USE_FCNTL
-extern void initfcntl();
-#endif
-#ifdef USE_FL
-extern void initfl();
-#endif
-#ifdef USE_FM
-extern void initfm();
-#endif
-#ifdef USE_GL
-extern void initgl();
-#endif
-#ifdef USE_GRP
-extern void initgrp();
-#endif
-#ifdef USE_IMGFILE
-extern void initimgfile();
-#endif
-#ifdef USE_JPEG
-extern void initjpeg();
-#endif
-#ifdef USE_MAC
-extern void initmac();
-#endif
-#ifdef USE_MARSHAL
-extern void initmarshal();
-#endif
-#ifdef USE_MATH
-extern void initmath();
-#endif
-#ifdef USE_NIS
-extern void initnis();
-#endif
-#ifdef USE_PANEL
-extern void initpanel();
-#endif
-#ifdef USE_POSIX
-extern void initposix();
-#endif
-#ifdef USE_PWD
-extern void initpwd();
-#endif
-#ifdef USE_REGEX
-extern void initregex();
-#endif
-#ifdef USE_ROTOR
-extern void initrotor();
-#endif
-#ifdef USE_SELECT
-extern void initselect();
-#endif
-#ifdef USE_SGI
-extern void initsgi();
-#endif
-#ifdef USE_SOCKET
-extern void initsocket();
-#endif
-#ifdef USE_STDWIN
-extern void initstdwin();
-#endif
-#ifdef USE_STROP
-extern void initstrop();
-#endif
-#ifdef USE_STRUCT
-extern void initstruct();
-#endif
-#ifdef USE_SUNAUDIODEV
-extern void initsunaudiodev();
-#endif
-#ifdef USE_SV
-extern void initsv();
-#endif
-#ifdef USE_TIME
-extern void inittime();
-#endif
-#ifdef USE_IMAGEOP
-extern void initimageop();
-#endif
-#ifdef USE_MPZ
-extern void initmpz();
-#endif
-#ifdef USE_MD5
-extern void initmd5();
-#endif
-#ifdef USE_ARRAY
-extern void initarray();
-#endif
-#ifdef USE_XT
-extern void initXt();
-#endif
-#ifdef USE_XAW
-extern void initXaw();
-#endif
-#ifdef USE_XM
-extern void initXm();
-#endif
-#ifdef USE_GLX
-extern void initGlx();
-#endif
-#ifdef USE_HTML
-extern void initHTML();
-#endif
-#ifdef USE_XLIB
-extern void initXlib();
-#endif
-#ifdef USE_PARSER
-extern void initparser();
-#endif
-/* -- ADDMODULE MARKER 1 -- */
-
-struct {
- char *name;
- void (*initfunc)();
-} inittab[] = {
-
-#ifdef USE_AL
- {"al", inital},
-#endif
-
-#ifdef USE_AMOEBA
- {"amoeba", initamoeba},
-#endif
-
-#ifdef USE_AUDIO
- {"audio", initaudio},
-#endif
-
-#ifdef USE_AUDIOOP
- {"audioop", initaudioop},
-#endif
-
-#ifdef USE_CD
- {"cd", initcd},
-#endif
-
-#ifdef USE_CL
- {"cl", initcl},
-#endif
-
-#ifdef USE_DBM
- {"dbm", initdbm},
-#endif
-
-#ifdef USE_FCNTL
- {"fcntl", initfcntl},
-#endif
-
-#ifdef USE_FL
- {"fl", initfl},
-#endif
-
-#ifdef USE_FM
- {"fm", initfm},
-#endif
-
-#ifdef USE_GL
- {"gl", initgl},
-#endif
-
-#ifdef USE_GRP
- {"grp", initgrp},
-#endif
-
-#ifdef USE_IMGFILE
- {"imgfile", initimgfile},
-#endif
-
-#ifdef USE_JPEG
- {"jpeg", initjpeg},
-#endif
-
-#ifdef USE_MAC
- {"mac", initmac},
-#endif
-
-#ifdef USE_MARSHAL
- {"marshal", initmarshal},
-#endif
-
-#ifdef USE_MATH
- {"math", initmath},
-#endif
-
-#ifdef USE_NIS
- {"nis", initnis},
-#endif
-
-#ifdef USE_PANEL
- {"pnl", initpanel},
-#endif
-
-#ifdef USE_POSIX
- {"posix", initposix},
-#endif
-
-#ifdef USE_PWD
- {"pwd", initpwd},
-#endif
-
-#ifdef USE_REGEX
- {"regex", initregex},
-#endif
-
-#ifdef USE_ROTOR
- {"rotor", initrotor},
-#endif
-
-#ifdef USE_SELECT
- {"select", initselect},
-#endif
-
-#ifdef USE_SGI
- {"sgi", initsgi},
-#endif
-
-#ifdef USE_SOCKET
- {"socket", initsocket},
-#endif
-
-#ifdef USE_STDWIN
- {"stdwin", initstdwin},
-#endif
-
-#ifdef USE_STROP
- {"strop", initstrop},
-#endif
-
-#ifdef USE_STRUCT
- {"struct", initstruct},
-#endif
-
-#ifdef USE_SUNAUDIODEV
- {"sunaudiodev", initsunaudiodev},
-#endif
-
-#ifdef USE_SV
- {"sv", initsv},
-#endif
-
-#ifdef USE_TIME
- {"time", inittime},
-#endif
-
-#ifdef USE_IMAGEOP
- {"imageop", initimageop},
-#endif
-
-#ifdef USE_MPZ
- {"mpz", initmpz},
-#endif
-
-#ifdef USE_MD5
- {"md5", initmd5},
-#endif
-
-#ifdef USE_ARRAY
- {"array", initarray},
-#endif
diff --git a/Modules/yuv.h b/Modules/yuv.h
index 4046df6146..60b6287316 100644
--- a/Modules/yuv.h
+++ b/Modules/yuv.h
@@ -1,3 +1,27 @@
+/***********************************************************
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
+Amsterdam, The Netherlands.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Stichting Mathematisch
+Centrum or CWI not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+
+STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
+FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+******************************************************************/
+
#ifndef Py_YUV_H
#define Py_YUV_H
#ifdef __cplusplus
diff --git a/Modules/yuvconvert.c b/Modules/yuvconvert.c
index 1b0ea63b66..69ec47c0fe 100644
--- a/Modules/yuvconvert.c
+++ b/Modules/yuvconvert.c
@@ -1,3 +1,27 @@
+/***********************************************************
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
+Amsterdam, The Netherlands.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Stichting Mathematisch
+Centrum or CWI not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+
+STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
+FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+******************************************************************/
+
#include "yuv.h"
void