Merge alpha100 branch back to main trunk

This commit is contained in:
Guido van Rossum 1994-08-01 11:34:53 +00:00
parent 2979b01ff8
commit b6775db241
176 changed files with 5302 additions and 3668 deletions

View file

@ -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

View file

@ -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
@ -30,6 +30,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* "allobjects.c" -- Source for precompiled header "allobjects.h" */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef THINK_C
#define macintosh
#endif
@ -37,7 +41,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdio.h>
#include <string.h>
#include "PROTO.h"
#include "myproto.h"
#include "object.h"
#include "objimpl.h"

View file

@ -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
@ -28,7 +28,13 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
#ifdef MPW /* This is for MPW's File command */
#define assert(e) { if (!(e)) { printf("### Python: Assertion failed:\n\
File %s; Line %d\n", __FILE__, __LINE__); abort(); } }
#else
#define assert(e) { if (!(e)) { printf("Assertion failed\n"); abort(); } }
#endif
#ifdef __cplusplus
}

View file

@ -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

View file

@ -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
@ -31,6 +31,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Built-in module interface */
extern object *getbuiltin PROTO((object *));
extern int setbuiltin PROTO((char *, object *));
#ifdef __cplusplus
}

View file

@ -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,6 +35,7 @@ object *call_object PROTO((object *, object *));
object *getglobals PROTO((void));
object *getlocals PROTO((void));
object *getowner PROTO((void));
object *getframe PROTO((void));
void printtraceback PROTO((object *));
void flushline PROTO((void));
@ -87,7 +88,7 @@ extern void init_save_thread PROTO((void));
extern object *save_thread PROTO((void));
extern void restore_thread PROTO((object *));
#ifdef USE_THREAD
#ifdef WITH_THREAD
#define BGN_SAVE { \
object *_save; \
@ -97,14 +98,14 @@ extern void restore_thread PROTO((object *));
#define END_SAVE restore_thread(_save); \
}
#else /* !USE_THREAD */
#else /* !WITH_THREAD */
#define BGN_SAVE {
#define RET_SAVE
#define RES_SAVE
#define END_SAVE }
#endif /* !USE_THREAD */
#endif /* !WITH_THREAD */
#ifdef __cplusplus
}

View file

@ -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));

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
@ -29,11 +29,15 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* Error codes passed around between file input, tokenizer, parser and
interpreter. This was necessary so we can turn them into Python
exceptions at a higher level. */
interpreter. This is necessary so we can turn them into Python
exceptions at a higher level. Note that some errors have a
slightly different meaning when passed from the tokenizer to the
parser than when passed from the parser to the interpreter; e.g.
the parser only returns E_EOF when it hits EOF immediately, and it
never returns E_OK. */
#define E_OK 10 /* No error */
#define E_EOF 11 /* (Unexpected) EOF read */
#define E_EOF 11 /* End Of File */
#define E_INTR 12 /* Interrupted */
#define E_TOKEN 13 /* Bad token */
#define E_SYNTAX 14 /* Syntax error */

View file

@ -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
@ -33,7 +33,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
void err_set PROTO((object *));
void err_setval PROTO((object *, object *));
void err_setstr PROTO((object *, char *));
int err_occurred PROTO((void));
object *err_occurred PROTO((void));
void err_get PROTO((object **, object **));
void err_clear PROTO((void));
@ -64,12 +64,13 @@ extern object *ZeroDivisionError;
extern int err_badarg PROTO((void));
extern object *err_nomem PROTO((void));
extern object *err_errno PROTO((object *));
extern void err_input PROTO((int));
extern void err_badcall PROTO((void));
extern object *err_getexc PROTO((void));
extern int sigcheck PROTO((void)); /* In sigcheck.c or signalmodule.c */
#ifdef __cplusplus
}
#endif

View file

@ -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

View file

@ -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,6 +35,7 @@ extern typeobject Filetype;
#define is_fileobject(op) ((op)->ob_type == &Filetype)
extern object *newfileobject PROTO((char *, char *));
extern void setfilebufsize PROTO((object *, int));
extern object *newopenfileobject
PROTO((FILE *, char *, char *, int (*)FPROTO((FILE *))));
extern FILE *getfilefile PROTO((object *));

View file

@ -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

View file

@ -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
@ -52,6 +52,7 @@ typedef struct _frame {
int f_iblock; /* index in f_blockstack */
int f_lasti; /* Last instruction if called */
int f_lineno; /* Current line number */
object *f_trace; /* Trace function */
} frameobject;
@ -70,11 +71,11 @@ frameobject * newframeobject PROTO(
/* List access macros */
#ifdef NDEBUG
#define GETITEM(v, i) GETLISTITEM((listobject *)(v), (i))
#define GETITEM(v, i) GETTUPLEITEM((tupleobject *)(v), (i))
#define GETITEMNAME(v, i) GETSTRINGVALUE((stringobject *)GETITEM((v), (i)))
#else
#define GETITEM(v, i) getlistitem((v), (i))
#define GETITEMNAME(v, i) getstringvalue(getlistitem((v), (i)))
#define GETITEM(v, i) gettupleitem((v), (i))
#define GETITEMNAME(v, i) getstringvalue(GETITEM(v, i))
#endif
#define GETUSTRINGVALUE(s) ((unsigned char *)GETSTRINGVALUE(s))
@ -95,6 +96,11 @@ block *pop_block PROTO((frameobject *));
object **extend_stack PROTO((frameobject *, int, int));
/* Conversions between "fast locals" and locals in dictionary */
void locals_2_fast PROTO((frameobject *, int));
void fast_2_locals PROTO((frameobject *));
#ifdef __cplusplus
}
#endif

View file

@ -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,6 +35,8 @@ typedef struct {
object *func_code;
object *func_globals;
object *func_name;
int func_argcount;
object *func_argdefs;
} funcobject;
extern typeobject Functype;
@ -44,6 +46,8 @@ extern typeobject Functype;
extern object *newfuncobject PROTO((object *, object *));
extern object *getfunccode PROTO((object *));
extern object *getfuncglobals PROTO((object *));
extern object *getfuncargstuff PROTO((object *, int *));
extern int setfuncargstuff PROTO((object *, int, object *));
#ifdef __cplusplus
}

View file

@ -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
@ -34,7 +34,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* A label of an arc */
typedef struct _label {
typedef struct {
int lb_type;
char *lb_str;
} label;
@ -43,21 +43,21 @@ typedef struct _label {
/* A list of labels */
typedef struct _labellist {
typedef struct {
int ll_nlabels;
label *ll_label;
} labellist;
/* An arc from one state to another */
typedef struct _arc {
typedef struct {
short a_lbl; /* Label of this arc */
short a_arrow; /* State where this arc goes to */
} arc;
/* A state in a DFA */
typedef struct _state {
typedef struct {
int s_narcs;
arc *s_arc; /* Array of arcs */
@ -70,7 +70,7 @@ typedef struct _state {
/* A DFA */
typedef struct _dfa {
typedef struct {
int d_type; /* Non-terminal this represents */
char *d_name; /* For printing */
int d_initial; /* Initial state */
@ -81,7 +81,7 @@ typedef struct _dfa {
/* A grammar */
typedef struct _grammar {
typedef struct {
int g_ndfas;
dfa *g_dfa; /* Array of DFAs */
labellist g_ll;

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
@ -62,6 +62,7 @@ extern int addlistitem PROTO((object *, object *));
extern object *getlistslice PROTO((object *, int, int));
extern int setlistslice PROTO((object *, int, int, object *));
extern int sortlist PROTO((object *));
extern object *listtuple PROTO((object *));
/* Macro, trading safety for speed */
#define GETLISTITEM(op, i) ((op)->ob_item[i])

View file

@ -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

View file

@ -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
@ -42,6 +42,7 @@ extern long getlongvalue PROTO((object *));
extern double dgetlongvalue PROTO((object *));
object *long_scan PROTO((char *, int));
object *long_escan PROTO((char *, char **, int));
#ifdef __cplusplus
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
@ -30,21 +30,28 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Module support interface */
#ifdef HAVE_PROTOTYPES
#define USE_STDARG
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
extern int getargs PROTO((object *, char *, ...));
extern object *mkvalue PROTO((char *, ...));
#else
#include <varargs.h>
/* Better to have no prototypes at all for varargs functions in this case */
extern int getargs();
extern object *mkvalue();
#endif
#ifdef USE_STDARG
#include <stdarg.h>
#else
#include <varargs.h>
#endif
extern int vgetargs PROTO((object *, char *, va_list));
extern object *vmkvalue PROTO((char *, va_list));
extern object *initmodule PROTO((char *, struct methodlist *));
extern int getargs PROTO((object *, char *, ...));
extern int vgetargs PROTO((object *, char *, va_list));
extern object *mkvalue PROTO((char *, ...));
extern object *vmkvalue PROTO((char *, va_list));
extern object *initmodule2 PROTO((char *, struct methodlist *, object *));
/* The following are obsolete -- use getargs directly! */
#define getnoarg(v) getargs(v, "")

View file

@ -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

View file

@ -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
@ -32,41 +32,35 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef macintosh
#define ANY void
#ifndef THINK_C_3_0
#define HAVE_STDLIB
#endif
#endif
#ifdef sun
/* Maybe not for very old versions of SunOS ? */
#define HAVE_STDLIB
#endif
#ifdef sgi
#define HAVE_STDLIB
#endif
#ifdef __STDC__
#define ANY void
#define HAVE_STDLIB
#endif
#ifdef __TURBOC__
#define ANY void
#define HAVE_STDLIB
#endif
#ifdef __GNUC__
#define ANY void
#define HAVE_STDLIB
#endif
#ifndef ANY
#define ANY char
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#else /* !HAVE_STDLIB */
extern ANY *malloc PROTO((size_t));
extern ANY *calloc PROTO((size_t, size_t));
extern ANY *realloc PROTO((ANY *, size_t));
extern void free PROTO((ANY *)); /* XXX sometimes int on Unix old systems */
#endif /* !HAVE_STDLIB */
#ifndef NULL
#define NULL 0
#define NULL ((ANY *)0)
#endif
/* XXX Always allocate one extra byte, since some malloc's return NULL
@ -80,17 +74,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define DEL(p) free((ANY *)p)
#define XDEL(p) if ((p) == NULL) ; else DEL(p)
#ifdef HAVE_STDLIB
#include <stdlib.h>
#define MALLARG size_t
#else
#define MALLARG size_t
extern ANY *malloc PROTO((MALLARG));
extern ANY *calloc PROTO((MALLARG, MALLARG));
extern ANY *realloc PROTO((ANY *, MALLARG));
extern void free PROTO((ANY *)); /* XXX sometimes int on Unix old systems */
#endif
#ifdef __cplusplus
}
#endif

View file

@ -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

View file

@ -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
@ -28,38 +28,28 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* Common definitions for files that use the BSD select system call.
This is so complicated because every UNIX variant requires that
you include a different set of headers. Customizing this one file
should be easier than patching each of the files using select()... */
/* Include file for users of select() */
/* NB caller must include <sys/types.h> */
/* XXX You may have to include some of these only if not already included */
#include <sys/types.h>
#include <sys/time.h> /* Implies <time.h> everywhere, as far as I know */
#include <sys/param.h>
#ifdef HAVE_SYS_SELECT_H
/* Hacks for various systems that need hand-holding... */
#ifdef _SEQUENT_
#include <sys/select.h>
/* Sequent doesn't seem to define struct timezone anywhere?!?! */
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
#endif
#ifdef _AIX /* I *think* this works */
/* AIX defines fd_set in a separate file. Sigh... */
#include <sys/select.h>
#endif
#ifdef SYS_SELECT_WITH_SYS_TIME
#include "mytime.h"
#else /* !SYS_SELECT_WITH_SYS_TIME */
#include <time.h>
#endif /* !SYS_SELECT_WITH_SYS_TIME */
#else /* !HAVE_SYS_SELECT_H */
#include "mytime.h"
/* (Very) old versions of BSD don't define the FD_* set of macros.
The following will usually do... */
#endif /* !HAVE_SYS_SELECT_H */
/* If the fd manipulation macros aren't defined,
here is a set that should do the job */
#ifndef FD_SETSIZE
#define FD_SETSIZE 256
@ -67,12 +57,12 @@ struct timezone {
#ifndef FD_SET
typedef long fd_mask;
typedef long fd_mask;
#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
#endif
#endif /* howmany */
typedef struct fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];

View file

@ -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

View file

@ -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

View file

@ -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
@ -133,48 +133,66 @@ NB: the methods for certain type groups are now contained in separate
method blocks.
*/
typedef object * (*unaryfunc) PROTO((object *));
typedef object * (*binaryfunc) PROTO((object *, object *));
typedef int (*inquiry) PROTO((object *));
typedef int (*coercion) PROTO((object **, object **));
typedef object *(*intargfunc) PROTO((object *, int));
typedef object *(*intintargfunc) PROTO((object *, int, int));
typedef int(*intobjargproc) PROTO((object *, int, object *));
typedef int(*intintobjargproc) PROTO((object *, int, int, object *));
typedef int(*objobjargproc) PROTO((object *, object *, object *));
typedef struct {
object *(*nb_add) FPROTO((object *, object *));
object *(*nb_subtract) FPROTO((object *, object *));
object *(*nb_multiply) FPROTO((object *, object *));
object *(*nb_divide) FPROTO((object *, object *));
object *(*nb_remainder) FPROTO((object *, object *));
object *(*nb_divmod) FPROTO((object *, object *));
object *(*nb_power) FPROTO((object *, object *));
object *(*nb_negative) FPROTO((object *));
object *(*nb_positive) FPROTO((object *));
object *(*nb_absolute) FPROTO((object *));
int (*nb_nonzero) FPROTO((object *));
object *(*nb_invert) FPROTO((object *));
object *(*nb_lshift) FPROTO((object *, object *));
object *(*nb_rshift) FPROTO((object *, object *));
object *(*nb_and) FPROTO((object *, object *));
object *(*nb_xor) FPROTO((object *, object *));
object *(*nb_or) FPROTO((object *, object *));
int (*nb_coerce) FPROTO((object **, object **));
object *(*nb_int) FPROTO((object *));
object *(*nb_long) FPROTO((object *));
object *(*nb_float) FPROTO((object *));
object *(*nb_oct) FPROTO((object *));
object *(*nb_hex) FPROTO((object *));
binaryfunc nb_add;
binaryfunc nb_subtract;
binaryfunc nb_multiply;
binaryfunc nb_divide;
binaryfunc nb_remainder;
binaryfunc nb_divmod;
binaryfunc nb_power;
unaryfunc nb_negative;
unaryfunc nb_positive;
unaryfunc nb_absolute;
inquiry nb_nonzero;
unaryfunc nb_invert;
binaryfunc nb_lshift;
binaryfunc nb_rshift;
binaryfunc nb_and;
binaryfunc nb_xor;
binaryfunc nb_or;
coercion nb_coerce;
unaryfunc nb_int;
unaryfunc nb_long;
unaryfunc nb_float;
unaryfunc nb_oct;
unaryfunc nb_hex;
} number_methods;
typedef struct {
int (*sq_length) FPROTO((object *));
object *(*sq_concat) FPROTO((object *, object *));
object *(*sq_repeat) FPROTO((object *, int));
object *(*sq_item) FPROTO((object *, int));
object *(*sq_slice) FPROTO((object *, int, int));
int (*sq_ass_item) FPROTO((object *, int, object *));
int (*sq_ass_slice) FPROTO((object *, int, int, object *));
inquiry sq_length;
binaryfunc sq_concat;
intargfunc sq_repeat;
intargfunc sq_item;
intintargfunc sq_slice;
intobjargproc sq_ass_item;
intintobjargproc sq_ass_slice;
} sequence_methods;
typedef struct {
int (*mp_length) FPROTO((object *));
object *(*mp_subscript) FPROTO((object *, object *));
int (*mp_ass_subscript) FPROTO((object *, object *, object *));
inquiry mp_length;
binaryfunc mp_subscript;
objobjargproc mp_ass_subscript;
} mapping_methods;
typedef void (*destructor) PROTO((object *));
typedef int (*printfunc) PROTO((object *, FILE *, int));
typedef object *(*getattrfunc) PROTO((object *, char *));
typedef int (*setattrfunc) PROTO((object *, char *, object *));
typedef int (*cmpfunc) PROTO((object *, object *));
typedef object *(*reprfunc) PROTO((object *));
typedef long (*hashfunc) PROTO((object *));
typedef struct _typeobject {
OB_VARHEAD
char *tp_name; /* For printing */
@ -182,12 +200,12 @@ typedef struct _typeobject {
/* Methods to implement standard operations */
void (*tp_dealloc) FPROTO((object *));
int (*tp_print) FPROTO((object *, FILE *, int));
object *(*tp_getattr) FPROTO((object *, char *));
int (*tp_setattr) FPROTO((object *, char *, object *));
int (*tp_compare) FPROTO((object *, object *));
object *(*tp_repr) FPROTO((object *));
destructor tp_dealloc;
printfunc tp_print;
getattrfunc tp_getattr;
setattrfunc tp_setattr;
cmpfunc tp_compare;
reprfunc tp_repr;
/* Method suites for standard classes */
@ -197,7 +215,8 @@ typedef struct _typeobject {
/* More standard operations (at end for binary compatibility) */
long (*tp_hash) FPROTO((object *));
hashfunc tp_hash;
binaryfunc tp_call;
#ifdef COUNT_ALLOCS
/* these must be last */
int tp_alloc;
@ -326,6 +345,29 @@ extern object NoObject; /* Don't use this directly */
#define None (&NoObject)
/*
A common programming style in Python requires the forward declaration
of static, initialized structures, e.g. for a typeobject that is used
by the functions whose address must be used in the initializer.
Some compilers (notably SCO ODT 3.0, I seem to remember early AIX as
well) botch this if you use the static keyword for both declarations
(they allocate two objects, and use the first, uninitialized one until
the second declaration is encountered). Therefore, the forward
declaration should use the 'forwardstatic' keyword. This expands to
static on most systems, but to extern on a few. The actual storage
and name will still be static because the second declaration is
static, so no linker visible symbols will be generated. (Standard C
compilers take offense to the extern forward declaration of a static
object, so I can't just put extern in all cases. :-( )
*/
#ifdef BAD_STATIC_FORWARD
#define staticforward extern
#else
#define staticforward static
#endif /* BAD_STATIC_FORWARD */
/*
123456789-123456789-123456789-123456789-123456789-123456789-123456789-12

View file

@ -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

View file

@ -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
@ -119,6 +119,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define LOAD_LOCAL 115 /* Index in name list */
#define LOAD_GLOBAL 116 /* Index in name list */
#define SET_FUNC_ARGS 117 /* Argcount */
#define SETUP_LOOP 120 /* Target address (absolute) */
#define SETUP_EXCEPT 121 /* "" */
#define SETUP_FINALLY 122 /* "" */

View file

@ -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
@ -36,7 +36,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define DELIM ' '
#endif
#ifdef MSDOS
#if defined(MSDOS) || defined(NT)
#define SEP '\\'
#define MAXPATHLEN 256
#define DELIM ';'

View file

@ -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
@ -30,9 +30,17 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Parser-tokenizer link interface */
extern int parsestring PROTO((char *, grammar *, int, node **_ret));
extern int parsefile PROTO((FILE *, char *, grammar *, int,
char *, char *, node **));
typedef struct {
int error;
char *filename;
int lineno;
int offset;
char *text;
} perrdetail;
extern node *parsestring PROTO((char *, grammar *, int, perrdetail *));
extern node *parsefile PROTO((FILE *, char *, grammar *, int,
char *, char *, perrdetail *));
#ifdef __cplusplus
}

View file

@ -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
@ -31,9 +31,12 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Include files and extern declarations used by most of the parser.
This is a precompiled header for THINK C. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef THINK_C
#define macintosh
/* #define THINK_C_3_0 /*** TURN THIS ON FOR THINK C 3.0 ***/
#endif
#include <stdio.h>
@ -44,17 +47,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#undef label
#endif
#ifdef THINK_C_3_0
#include <proto.h>
#endif
#ifdef macintosh
#ifndef THINK_C_3_0
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#endif
#include "PROTO.h"
#include "myproto.h"
#include "mymalloc.h"
extern void fatal PROTO((char *));

View file

@ -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
@ -33,7 +33,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
void err_set PROTO((object *));
void err_setval PROTO((object *, object *));
void err_setstr PROTO((object *, char *));
int err_occurred PROTO((void));
object *err_occurred PROTO((void));
void err_get PROTO((object **, object **));
void err_clear PROTO((void));
@ -64,12 +64,13 @@ extern object *ZeroDivisionError;
extern int err_badarg PROTO((void));
extern object *err_nomem PROTO((void));
extern object *err_errno PROTO((object *));
extern void err_input PROTO((int));
extern void err_badcall PROTO((void));
extern object *err_getexc PROTO((void));
extern int sigcheck PROTO((void)); /* In sigcheck.c or signalmodule.c */
#ifdef __cplusplus
}
#endif

View file

@ -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
@ -39,8 +39,8 @@ int run_script PROTO((FILE *, char *));
int run_tty_1 PROTO((FILE *, char *));
int run_tty_loop PROTO((FILE *, char *));
int parse_string PROTO((char *, int, struct _node **));
int parse_file PROTO((FILE *, char *, int, struct _node **));
struct _node *parse_string PROTO((char *, int));
struct _node *parse_file PROTO((FILE *, char *, int));
object *run_string PROTO((char *, int, object *, object *));
object *run_file PROTO((FILE *, char *, int, object *, object *));
@ -51,6 +51,8 @@ void print_error PROTO((void));
void goaway PROTO((int));
void cleanup PROTO((void));
#ifdef __cplusplus
}
#endif

View file

@ -1,6 +1,9 @@
#ifndef _THREAD_H_included
#define _THREAD_H_included
#define NO_EXIT_PROG /* don't define exit_prog() */
/* (the result is no use of signals on SGI) */
#ifndef PROTO
#if defined(__STDC__) || defined(__cplusplus)
#define PROTO(args) args
@ -20,6 +23,7 @@ void init_thread PROTO((void));
int start_new_thread PROTO((void (*)(void *), void *));
void exit_thread PROTO((void));
void _exit_thread PROTO((void));
long get_thread_ident PROTO((void));
type_lock allocate_lock PROTO((void));
void free_lock PROTO((type_lock));
@ -33,8 +37,10 @@ void free_sema PROTO((type_sema));
void down_sema PROTO((type_sema));
void up_sema PROTO((type_sema));
#ifndef NO_EXIT_PROG
void exit_prog PROTO((int));
void _exit_prog PROTO((int));
#endif
#ifdef __cplusplus
}

View file

@ -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

View file

@ -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

View file

@ -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
@ -66,6 +66,7 @@ extern object *newstringobject PROTO((char *));
extern unsigned int getstringsize PROTO((object *));
extern char *getstringvalue PROTO((object *));
extern void joinstring PROTO((object **, object *));
extern void joinstring_decref PROTO((object **, object *));
extern int resizestring PROTO((object **, int));
extern object *formatstring PROTO((object *, object *));

View file

@ -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

View file

@ -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

View file

@ -1,6 +1,9 @@
#ifndef _THREAD_H_included
#define _THREAD_H_included
#define NO_EXIT_PROG /* don't define exit_prog() */
/* (the result is no use of signals on SGI) */
#ifndef PROTO
#if defined(__STDC__) || defined(__cplusplus)
#define PROTO(args) args
@ -20,6 +23,7 @@ void init_thread PROTO((void));
int start_new_thread PROTO((void (*)(void *), void *));
void exit_thread PROTO((void));
void _exit_thread PROTO((void));
long get_thread_ident PROTO((void));
type_lock allocate_lock PROTO((void));
void free_lock PROTO((type_lock));
@ -33,8 +37,10 @@ void free_sema PROTO((type_sema));
void down_sema PROTO((type_sema));
void up_sema PROTO((type_sema));
#ifndef NO_EXIT_PROG
void exit_prog PROTO((int));
void _exit_prog PROTO((int));
#endif
#ifdef __cplusplus
}

View file

@ -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

View file

@ -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

View file

@ -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