diff --git a/Include/cgensupport.h b/Include/cgensupport.h index 5c2cbd4cfa5..43818bc4108 100644 --- a/Include/cgensupport.h +++ b/Include/cgensupport.h @@ -29,8 +29,7 @@ typedef char *string; #define mknewlongobject(x) newintobject(x) #define mknewshortobject(x) newintobject((long)x) #define mknewfloatobject(x) newfloatobject(x) - -extern object *mknewcharobject PROTO((int c)); +#define mknewcharobject(c) mkvalue("c", c) 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/Include/listobject.h b/Include/listobject.h index 519776a23b1..f18877f9801 100644 --- a/Include/listobject.h +++ b/Include/listobject.h @@ -53,6 +53,8 @@ extern object *getlistitem PROTO((object *, int)); extern int setlistitem PROTO((object *, int, object *)); extern int inslistitem PROTO((object *, int, object *)); 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 *)); /* Macro, trading safety for speed */ diff --git a/Include/modsupport.h b/Include/modsupport.h index bb809c76bd8..5c1bdf509fa 100644 --- a/Include/modsupport.h +++ b/Include/modsupport.h @@ -40,29 +40,8 @@ extern int vgetargs PROTO((object *, char *, va_list)); extern object *mkvalue PROTO((char *, ...)); extern object *vmkvalue PROTO((char *, va_list)); +/* The following are obsolete -- use getargs directly! */ #define getnoarg(v) getargs(v, "") #define getintarg(v, a) getargs(v, "i", a) -#define getintintarg(v, a, b) getargs(v, "(ii)", a, b) -#define getintintintarg(v, a, b, c) getargs(v, "(iii)", a, b, c) #define getlongarg(v, a) getargs(v, "l", a) -#define getlonglongarg(v, a, b) getargs(v, "(ll)", a, b) -#define getlonglongobjectarg(v, a, b, c) getargs(v, "(llO)", a, b, c) -#define getStrarg(v, a) getargs(v, "S", a) #define getstrarg(v, a) getargs(v, "s", a) -#define getstrstrarg(v, a, b) getargs(v, "(ss)", a, b) -#define getStrStrarg(v, a, b) getargs(v, "(SS)", a, b) -#define getstrstrintarg(v, a, b, c) getargs(v, "(ssi)", a, b, c) -#define getStrintarg(v, a, b) getargs(v, "(Si)", a, b) -#define getstrintarg(v, a, b) getargs(v, "(si)", a, b) -#define getintstrarg(v, a, b) getargs(v, "(is)", a, b) -#define getpointarg(v, a) getargs(v, "(ii)", a, (a)+1) -#define get3pointarg(v, a) getargs(v, "((ii)(ii)(ii))", \ - a, a+1, a+2, a+3, a+4, a+5) -#define getrectarg(v, a) getargs(v, "((ii)(ii))", a, a+1, a+2, a+3) -#define getrectintarg(v, a) getargs(v, "(((ii)(ii))i)", a, a+1, a+2, a+3, a+4) -#define getpointintarg(v, a) getargs(v, "((ii)i)", a, a+1, a+2) -#define getpointstrarg(v, a, b) getargs(v, "((ii)s)", a, a+1, b) -#define getrectpointarg(v, a) getargs(v, "(((ii)(ii))(ii))", \ - a, a+1, a+2, a+3, a+4, a+5) -#define getdoublearg(v, a) getargs(v, "d", a) -#define get2doublearg(v, a, b) getargs(v, "(dd)", a, b) diff --git a/Include/pythonrun.h b/Include/pythonrun.h index 6c6117bfe49..c3c3aca24aa 100644 --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -28,6 +28,7 @@ void initall PROTO((void)); int run PROTO((FILE *, char *)); +int run_command PROTO((char *)); int run_script PROTO((FILE *, char *)); int run_tty_1 PROTO((FILE *, char *)); int run_tty_loop PROTO((FILE *, char *)); diff --git a/Modules/almodule.c b/Modules/almodule.c index d986d3445e4..26bf38f0888 100644 --- a/Modules/almodule.c +++ b/Modules/almodule.c @@ -568,7 +568,7 @@ al_openport (self, args) } size = gettuplesize(args); if (size == 2) { - if (!getstrstrarg (args, &name, &dir)) + if (!getargs (args, "(ss)", &name, &dir)) return NULL; } else if (size == 3) { diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index e5bf46a1e9c..b5a2cfa0b4f 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -209,7 +209,7 @@ d_setitem(ap, i, v) } /* Description of types */ -struct arraydescr descriptors[] = { +static struct arraydescr descriptors[] = { {'c', sizeof(char), c_getitem, c_setitem}, {'b', sizeof(char), b_getitem, b_setitem}, {'h', sizeof(short), h_getitem, h_setitem}, diff --git a/Modules/cdmodule.c b/Modules/cdmodule.c index 27cf35c43a9..b5d0defd593 100644 --- a/Modules/cdmodule.c +++ b/Modules/cdmodule.c @@ -725,12 +725,12 @@ CD_addcallback(self, args) object *args; { int type; - object *funcobject, *funcargobject; + object *func, *funcarg; CheckParser(self); /* XXX - more work here */ - if (!getargs(args, "(iOO)", &type, &funcobject, &funcargobject)) + if (!getargs(args, "(iOO)", &type, &func, &funcarg)) return NULL; if (type < 0 || type >= NCALLBACKS) { @@ -744,11 +744,11 @@ CD_addcallback(self, args) CDsetcallback(self->ob_cdparser, (CDDATATYPES) type, CD_callback, (void *) self); #endif XDECREF(self->ob_cdcallbacks[type].ob_cdcallback); - INCREF(funcobject); - self->ob_cdcallbacks[type].ob_cdcallback = funcobject; + INCREF(func); + self->ob_cdcallbacks[type].ob_cdcallback = func; XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg); - INCREF(funcargobject); - self->ob_cdcallbacks[type].ob_cdcallbackarg = funcargobject; + INCREF(funcarg); + self->ob_cdcallbacks[type].ob_cdcallbackarg = funcarg; INCREF(None); return None; diff --git a/Modules/cgensupport.c b/Modules/cgensupport.c index 5dcac867c75..87fcfabe687 100644 --- a/Modules/cgensupport.c +++ b/Modules/cgensupport.c @@ -28,17 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "cgensupport.h" -/* Functions to construct return values */ - -object * -mknewcharobject(c) - int c; -{ - char ch[1]; - ch[0] = c; - return newsizedstringobject(ch, 1); -} - /* Functions to extract arguments. These needs to know the total number of arguments supplied, since the argument list is a tuple only of there is more than diff --git a/Modules/cgensupport.h b/Modules/cgensupport.h index 5c2cbd4cfa5..43818bc4108 100644 --- a/Modules/cgensupport.h +++ b/Modules/cgensupport.h @@ -29,8 +29,7 @@ typedef char *string; #define mknewlongobject(x) newintobject(x) #define mknewshortobject(x) newintobject((long)x) #define mknewfloatobject(x) newfloatobject(x) - -extern object *mknewcharobject PROTO((int c)); +#define mknewcharobject(c) mkvalue("c", c) 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/flmodule.c b/Modules/flmodule.c index 3d424d1fe66..0cc08da5c52 100644 --- a/Modules/flmodule.c +++ b/Modules/flmodule.c @@ -528,7 +528,7 @@ call_forms_INiINstr (func, obj, args) char *b; int a; - if (!getintstrarg(args, &a, &b)) return NULL; + if (!getargs(args, "(is)", &a, &b)) return NULL; (*func) (obj, a, b); @@ -546,7 +546,7 @@ call_forms_INiINi (func, obj, args) { int par1, par2; - if (!getintintarg(args, &par1, &par2)) return NULL; + if (!getargs(args, "(ii)", &par1, &par2)) return NULL; (*func) (obj, par1, par2); @@ -1048,7 +1048,7 @@ get_default(g, args) c = fl_get_default (g->ob_generic); - return ((object *) mknewcharobject (c)); /* in cgensupport.c */ + return mkvalue("c", c); } static struct methodlist default_methods[] = { @@ -1479,7 +1479,7 @@ form_call_INiINi(func, f, args) { int a, b; - if (!getintintarg(args, &a, &b)) return NULL; + if (!getargs(args, "(ii)", &a, &b)) return NULL; (*func)(f, a, b); @@ -2144,7 +2144,7 @@ forms_set_graphics_mode(dummy, args) { int rgbmode, doublebuf; - if (!getintintarg(args, &rgbmode, &doublebuf)) + if (!getargs(args, "(ii)", &rgbmode, &doublebuf)) return NULL; fl_set_graphics_mode(rgbmode,doublebuf); INCREF(None); @@ -2441,7 +2441,7 @@ forms_show_input(f, args) char *str; char *a, *b; - if (!getstrstrarg(args, &a, &b)) return NULL; + if (!getargs(args, "(ss)", &a, &b)) return NULL; BGN_SAVE str = fl_show_input(a, b); diff --git a/Modules/fmmodule.c b/Modules/fmmodule.c index 8d54d97140f..aa49be36a2f 100644 --- a/Modules/fmmodule.c +++ b/Modules/fmmodule.c @@ -68,7 +68,7 @@ fh_scalefont(self, args) object *args; { double size; - if (!getdoublearg(args, &size)) + if (!getargs(args, "d", &size)) return NULL; return newfhobject(fmscalefont(self->fh_fh, size)); } diff --git a/Modules/imgfile.c b/Modules/imgfile.c index a6db0266d2a..93f5ef3cfd2 100644 --- a/Modules/imgfile.c +++ b/Modules/imgfile.c @@ -162,9 +162,9 @@ imgfile_read(self, args) return rv; } -IMAGE *glob_image; -long *glob_datap; -int glob_width, glob_z; +static IMAGE *glob_image; +static long *glob_datap; +static int glob_width, glob_z; static xs_get(buf, y) diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 979155e481b..8b1bccf8dad 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -33,6 +33,9 @@ extern int errno; #include "modsupport.h" +#define getdoublearg(v, a) getargs(v, "d", a) +#define get2doublearg(v, a, b) getargs(v, "(dd)", a, b) + #include #ifdef i860 diff --git a/Modules/nismodule.c b/Modules/nismodule.c index eb97dee85cf..92341273c58 100644 --- a/Modules/nismodule.c +++ b/Modules/nismodule.c @@ -87,7 +87,7 @@ nis_match (self, args) int err; object *res; - if (!getstrstrarg(args, &key, &map)) + if (!getargs(args, "(ss)", &key, &map)) return NULL; if ((err = yp_get_default_domain(&domain)) != 0) return nis_error(err); diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 2e800de7973..88861c66e09 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -166,7 +166,7 @@ posix_2str(args, func) { char *path1, *path2; int res; - if (!getstrstrarg(args, &path1, &path2)) + if (!getargs(args, "(ss)", &path1, &path2)) return NULL; BGN_SAVE res = (*func)(path1, path2); @@ -185,7 +185,7 @@ posix_strint(args, func) char *path; int i; int res; - if (!getstrintarg(args, &path, &i)) + if (!getargs(args, "(si)", &path, &i)) return NULL; BGN_SAVE res = (*func)(path, i); @@ -691,7 +691,7 @@ posix_kill(self, args) object *args; { int pid, sig; - if (!getintintarg(args, &pid, &sig)) + if (!getargs(args, "(ii)", &pid, &sig)) return NULL; if (kill(pid, sig) == -1) return posix_error(); @@ -891,7 +891,7 @@ posix_tcsetpgrp(self, args) /* Functions acting on file descriptors */ -object * +static object * posix_open(self, args) object *self; object *args; @@ -913,7 +913,7 @@ posix_open(self, args) return newintobject((long)fd); } -object * +static object * posix_close(self, args) object *self; object *args; @@ -930,7 +930,7 @@ posix_close(self, args) return None; } -object * +static object * posix_dup(self, args) object *self; object *args; @@ -946,7 +946,7 @@ posix_dup(self, args) return newintobject((long)fd); } -object * +static object * posix_dup2(self, args) object *self; object *args; @@ -963,7 +963,7 @@ posix_dup2(self, args) return None; } -object * +static object * posix_lseek(self, args) object *self; object *args; @@ -988,7 +988,7 @@ posix_lseek(self, args) return newintobject(res); } -object * +static object * posix_read(self, args) object *self; object *args; @@ -1011,7 +1011,7 @@ posix_read(self, args) return buffer; } -object * +static object * posix_write(self, args) object *self; object *args; @@ -1028,7 +1028,7 @@ posix_write(self, args) return newintobject((long)size); } -object * +static object * posix_fstat(self, args) object *self; object *args; @@ -1079,7 +1079,7 @@ posix_fdopen(self, args) } #ifndef MSDOS -object * +static object * posix_pipe(self, args) object *self; object *args; diff --git a/Modules/rotormodule.c b/Modules/rotormodule.c index 4e9afd8deb1..71bac909a68 100644 --- a/Modules/rotormodule.c +++ b/Modules/rotormodule.c @@ -763,8 +763,10 @@ static typeobject Rotortype = { }; -object *rotor_rotor(self, args) -object *args; +static object * +rotor_rotor(self, args) + object *self; + object *args; { char *string; rotorobject *r; diff --git a/Modules/sgimodule.c b/Modules/sgimodule.c index b3733846a0d..418609de5aa 100644 --- a/Modules/sgimodule.c +++ b/Modules/sgimodule.c @@ -57,4 +57,4 @@ initsgi() initmodule("sgi", sgi_methods); } -int dummy; /* $%#@!& dl wants at least a byte of bss */ +static int dummy; /* $%#@!& dl wants at least a byte of bss */ diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 160c292d865..dfdf97ba21d 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -744,9 +744,9 @@ sock_send(s, args) char *buf; int len, n, flags; flags = 0; - if (!getargs(args, "(s#)", &buf, &len)) { + if (!getargs(args, "s#", &buf, &len)) { err_clear(); - if (!getargs(args, "s#", &buf, &len, &flags)) + if (!getargs(args, "(s#i)", &buf, &len, &flags)) return NULL; } BGN_SAVE diff --git a/Modules/stdwinmodule.c b/Modules/stdwinmodule.c index 02f7bcbd9bf..6e666a61b56 100644 --- a/Modules/stdwinmodule.c +++ b/Modules/stdwinmodule.c @@ -91,6 +91,15 @@ static type_lock StdwinLock; /* Lock held when interpreter not locked */ #endif +#define getpointarg(v, a) getargs(v, "(ii)", a, (a)+1) +#define get3pointarg(v, a) getargs(v, "((ii)(ii)(ii))", \ + a, a+1, a+2, a+3, a+4, a+5) +#define getrectarg(v, a) getargs(v, "((ii)(ii))", a, a+1, a+2, a+3) +#define getrectintarg(v, a) getargs(v, "(((ii)(ii))i)", a, a+1, a+2, a+3, a+4) +#define getpointintarg(v, a) getargs(v, "((ii)i)", a, a+1, a+2) +#define getrectpointarg(v, a) getargs(v, "(((ii)(ii))(ii))", \ + a, a+1, a+2, a+3, a+4, a+5) + static object *StdwinError; /* Exception stdwin.error */ /* Window and menu object types declared here because of forward references */ @@ -1236,7 +1245,7 @@ menu_setitem(self, args) { int index; char *text; - if (!getintstrarg(args, &index, &text)) + if (!getargs(args, "(is)", &index, &text)) return NULL; wmenusetitem(self->m_menu, index, text); INCREF(None); @@ -1250,7 +1259,7 @@ menu_enable(self, args) { int index; int flag; - if (!getintintarg(args, &index, &flag)) + if (!getargs(args, "(ii)", &index, &flag)) return NULL; wmenuenable(self->m_menu, index, flag); INCREF(None); @@ -1264,7 +1273,7 @@ menu_check(self, args) { int index; int flag; - if (!getintintarg(args, &index, &flag)) + if (!getargs(args, "(ii)", &index, &flag)) return NULL; wmenucheck(self->m_menu, index, flag); INCREF(None); @@ -1705,7 +1714,7 @@ window_settitle(wp, args) object *args; { object *title; - if (!getStrarg(args, &title)) + if (!getargs(args, "S", &title)) return NULL; DECREF(wp->w_title); INCREF(title); @@ -1930,7 +1939,7 @@ stdwin_open(sw, args) int tag; object *title; windowobject *wp; - if (!getStrarg(args, &title)) + if (!getargs(args, "S", &title)) return NULL; for (tag = 0; tag < MAXNWIN; tag++) { if (windowlist[tag] == NULL) @@ -2180,7 +2189,7 @@ stdwin_askfile(self, args) char *prompt, *dflt; int new, ret; char buf[256]; - if (!getstrstrintarg(args, &prompt, &dflt, &new)) + if (!getargs(args, "(ssi)", &prompt, &dflt, &new)) return NULL; strncpy(buf, dflt, sizeof buf); buf[sizeof buf - 1] = '\0'; @@ -2201,7 +2210,7 @@ stdwin_askync(self, args) { char *prompt; int new, ret; - if (!getstrintarg(args, &prompt, &new)) + if (!getargs(args, "(si)", &prompt, &new)) return NULL; BGN_STDWIN ret = waskync(prompt, new); @@ -2221,7 +2230,7 @@ stdwin_askstr(self, args) char *prompt, *dflt; int ret; char buf[256]; - if (!getstrstrarg(args, &prompt, &dflt)) + if (!getargs(args, "(ss)", &prompt, &dflt)) return NULL; strncpy(buf, dflt, sizeof buf); buf[sizeof buf - 1] = '\0'; diff --git a/Modules/sunaudiodev.c b/Modules/sunaudiodev.c index b4470dd85df..4e6312362d8 100644 --- a/Modules/sunaudiodev.c +++ b/Modules/sunaudiodev.c @@ -28,6 +28,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "modsupport.h" #include "structmember.h" +#include #include #include @@ -255,6 +256,38 @@ sad_drain(self, args) return None; } +static object * +sad_flush(self, args) + sadobject *self; + object *args; +{ + + if ( !getargs(args, "") ) + return 0; + if ( ioctl(self->x_fd, I_FLUSH, FLUSHW) < 0 ) { + err_errno(SunAudioError); + return NULL; + } + INCREF(None); + return None; +} + +static object * +sad_close(self, args) + sadobject *self; + object *args; +{ + + if ( !getargs(args, "") ) + return 0; + if ( self->x_fd >= 0 ) { + close(self->x_fd); + self->x_fd = -1; + } + INCREF(None); + return None; +} + static struct methodlist sad_methods[] = { { "read", sad_read }, { "write", sad_write }, @@ -264,6 +297,8 @@ static struct methodlist sad_methods[] = { { "getinfo", sad_getinfo }, { "setinfo", sad_setinfo }, { "drain", sad_drain }, + { "flush", sad_flush }, + { "close", sad_close }, {NULL, NULL} /* sentinel */ }; diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c index 7a5f29d4f44..f22aa8c4ce8 100644 --- a/Modules/threadmodule.c +++ b/Modules/threadmodule.c @@ -33,7 +33,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. int threads_started = 0; -object *ThreadError; +static object *ThreadError; /* Lock objects */ diff --git a/Modules/timemodule.c b/Modules/timemodule.c index b8b22e34c2e..3df088513eb 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -78,6 +78,26 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #endif +#ifdef SYSV +/* 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 */ +#endif +#ifdef NOALTTZ /* if system doesn't support alt tz */ +#undef _daylight +#undef _altzone +#define _daylight 0 +#define _altzone 0 +#endif +#endif /* SYSV */ + +/* Forward declarations */ +static void floatsleep PROTO((double)); +static long millitimer PROTO((void)); + /* Time methods */ static object * @@ -199,7 +219,6 @@ time_millitimer(self, args) object *args; { long msecs; - extern long millitimer(); if (!getnoarg(args)) return NULL; msecs = millitimer(); @@ -225,7 +244,7 @@ time_times(self, args) err_errno(IOError); return NULL; } - return mkvalue("dddd", + return mkvalue("(dddd)", (double)t.tms_utime / HZ, (double)t.tms_stime / HZ, (double)t.tms_cutime / HZ, @@ -235,6 +254,71 @@ time_times(self, args) #endif +static object * +time_convert(when, function) + time_t when; + struct tm * (*function) PROTO((time_t *)); +{ + struct tm *p = function(&when); + return mkvalue("(iiiiiiiii)", + p->tm_year + 1900, + p->tm_mon + 1, /* Want January == 1 */ + p->tm_mday, + p->tm_hour, + p->tm_min, + p->tm_sec, + (p->tm_wday + 6) % 7, /* Want Monday == 0 */ + p->tm_yday, + p->tm_isdst); +} + +static object * +time_gmtime(self, args) + object *self; + object *args; +{ + double when; + if (!getargs(args, "d", &when)) + return NULL; + return time_convert((time_t)when, gmtime); +} + +static object * +time_localtime(self, args) + object *self; + object *args; +{ + double when; + if (!getargs(args, "d", &when)) + return NULL; + return time_convert((time_t)when, localtime); +} + +/* Some very old systems may not have mktime(). Comment it out then! */ + +static object * +time_mktime(self, args) + object *self; + object *args; +{ + struct tm buf; + if (!getargs(args, "(iiiiiiiii)", + &buf.tm_year, + &buf.tm_mon, + &buf.tm_mday, + &buf.tm_hour, + &buf.tm_min, + &buf.tm_sec, + &buf.tm_wday, + &buf.tm_yday, + &buf.tm_isdst)) + return NULL; + if (buf.tm_year >= 1900) + buf.tm_year -= 1900; + buf.tm_mon--; + return newintobject((long)mktime(&buf)); +} + static struct methodlist time_methods[] = { #ifdef DO_MILLI {"millisleep", time_millisleep}, @@ -245,6 +329,9 @@ static struct methodlist time_methods[] = { #endif {"sleep", time_sleep}, {"time", time_time}, + {"gmtime", time_gmtime}, + {"localtime", time_localtime}, + {"mktime", time_mktime}, {NULL, NULL} /* sentinel */ }; @@ -252,7 +339,40 @@ static struct methodlist time_methods[] = { void inittime() { - initmodule("time", time_methods); + object *m, *d; + m = initmodule("time", time_methods); + d = getmoduledict(m); +#ifdef SYSV + 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 */ + { +#define YEAR ((time_t)((365 * 24 + 6) * 3600)) + time_t t; + struct tm *p; + long winterzone, summerzone; + char wintername[10], summername[10]; + t = (time((time_t *)0) / YEAR) * YEAR; + p = localtime(&t); + winterzone = -p->tm_gmtoff; + strncpy(wintername, p->tm_zone ? p->tm_zone : " ", 9); + wintername[9] = '\0'; + t += YEAR/2; + p = localtime(&t); + summerzone = -p->tm_gmtoff; + strncpy(summername, p->tm_zone ? p->tm_zone : " ", 9); + summername[9] = '\0'; + dictinsert(d, "timezone", newintobject(winterzone)); + dictinsert(d, "altzone", newintobject(summerzone)); + dictinsert(d, "daylight", + newintobject((long)(winterzone != summerzone))); + dictinsert(d, "tzname", + mkvalue("(zz)", wintername, summername)); + } +#endif /* !SYSV */ } @@ -274,6 +394,7 @@ sleep(secs) } #endif +static void floatsleep(secs) double secs; { @@ -286,7 +407,7 @@ floatsleep(secs) } } -long +static long millitimer() { return MacTicks * 50 / 3; /* MacTicks * 1000 / 60 */ @@ -299,7 +420,7 @@ millitimer() #ifdef BSD_TIME -long +static long millitimer() { struct timeval t; @@ -309,6 +430,7 @@ millitimer() return t.tv_sec*1000 + t.tv_usec/1000; } +static void floatsleep(secs) double secs; { @@ -325,6 +447,7 @@ floatsleep(secs) #else /* !BSD_TIME */ +static void floatsleep(secs) double secs; { @@ -342,13 +465,14 @@ floatsleep(secs) #define CLOCKS_PER_SEC 55 /* 54.945 msec per tick (18.2 HZ clock) */ #endif +static void floatsleep(secs) double secs; { delay(long(secs/1000.0)); } -long +static long millitimer() { clock_t ticks; diff --git a/Objects/accessobject.c b/Objects/accessobject.c index 1275ebab72c..c9b7ce385b6 100644 --- a/Objects/accessobject.c +++ b/Objects/accessobject.c @@ -24,6 +24,13 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* Access object implementation */ +/* XXX TO DO LIST + - need a "super user" mechanism for debugger etc. + - __init__ and __del__ (and all other similar methods) + should be usable even when private, not ignored + - "from foo import bar" should check access of bar +*/ + #include "allobjects.h" #include "structmember.h" diff --git a/Objects/fileobject.c b/Objects/fileobject.c index faf7e861414..15263d3f959 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -328,7 +328,7 @@ file_read(f, args) < 0: strip trailing '\n', raise EOFError if EOF reached immediately */ -object * +static object * getline(f, n) fileobject *f; int n; diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 6a95ebf82f9..25ae6d89916 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -70,7 +70,7 @@ newfloatobject(fval) return (object *) op; } -void +static void float_dealloc(op) object *op; { @@ -329,7 +329,7 @@ float_nonzero(v) return v->ob_fval != 0.0; } -int +static int float_coerce(pv, pw) object **pv; object **pw; diff --git a/Objects/listobject.c b/Objects/listobject.c index 9a1fe2329a0..b51e3d83dfa 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -207,7 +207,7 @@ list_print(op, fp, flags) return 0; } -object * +static object * list_repr(v) listobject *v; { @@ -291,6 +291,18 @@ list_slice(a, ilow, ihigh) return (object *)np; } +object * +getlistslice(a, ilow, ihigh) + object *a; + int ilow, ihigh; +{ + if (!is_listobject(a)) { + err_badcall(); + return NULL; + } + return list_slice((listobject *)a, ilow, ihigh); +} + static object * list_concat(a, bb) listobject *a; @@ -422,6 +434,19 @@ list_ass_slice(a, ilow, ihigh, v) #undef b } +int +setlistslice(a, ilow, ihigh, v) + object *a; + int ilow, ihigh; + object *v; +{ + if (!is_listobject(a)) { + err_badcall(); + return NULL; + } + return list_ass_slice((listobject *)a, ilow, ihigh, v); +} + static int list_ass_item(a, i, v) listobject *a; diff --git a/Objects/longobject.c b/Objects/longobject.c index fb82a1fc88b..8c0b6c1c80b 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -261,7 +261,7 @@ divrem1(a, n, prem) If base is 8 or 16, add the proper prefix '0' or '0x'. External linkage: used in bltinmodule.c by hex() and oct(). */ -object * +static object * long_format(aa, base) object *aa; int base; @@ -1275,7 +1275,7 @@ long_or(a, b) return long_bitwise(a, '|', b); } -int +static int long_coerce(pv, pw) object **pv; object **pw; diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 33fe48502f6..cba8c920db1 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -60,7 +60,7 @@ newstringobject(str) return (object *) op; } -void +static void string_dealloc(op) object *op; { @@ -676,6 +676,8 @@ formatstring(format, args) "unsupported format character"); goto error; } + /* XXX There's a bug somewhere here so that + XXX '%4d'%-1 yields '- 1' ... */ if (sign) { if (*buf == '-' || *buf == '+') { sign = *buf++; diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 9eb332b3011..faf46d52cc6 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -136,7 +136,7 @@ tupleprint(op, fp, flags) return 0; } -object * +static object * tuplerepr(v) tupleobject *v; { diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index c2c29662b6b..dc65ffb117c 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -28,7 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "node.h" #include "graminit.h" -#include "errcode.h" #include "sysmodule.h" #include "bltinmodule.h" #include "import.h" diff --git a/Python/ceval.c b/Python/ceval.c index 8698e8591cd..1c12d9cbc23 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1964,6 +1964,8 @@ not(v) INCREF(w); return w; } + + /* External interface to call any callable object. The arg may be NULL. */ object * diff --git a/Python/cgensupport.c b/Python/cgensupport.c index 5dcac867c75..87fcfabe687 100644 --- a/Python/cgensupport.c +++ b/Python/cgensupport.c @@ -28,17 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "cgensupport.h" -/* Functions to construct return values */ - -object * -mknewcharobject(c) - int c; -{ - char ch[1]; - ch[0] = c; - return newsizedstringobject(ch, 1); -} - /* Functions to extract arguments. These needs to know the total number of arguments supplied, since the argument list is a tuple only of there is more than diff --git a/Python/graminit.c b/Python/graminit.c index 530ddf3f09a..3b78d0c000b 100644 --- a/Python/graminit.c +++ b/Python/graminit.c @@ -393,26 +393,35 @@ static state states_22[3] = { static arc arcs_23_0[1] = { {51, 1}, }; -static arc arcs_23_1[1] = { - {13, 2}, +static arc arcs_23_1[2] = { + {22, 2}, + {13, 3}, }; -static arc arcs_23_2[2] = { - {21, 1}, - {15, 3}, +static arc arcs_23_2[1] = { + {15, 4}, }; -static arc arcs_23_3[1] = { - {52, 4}, +static arc arcs_23_3[2] = { + {21, 5}, + {15, 4}, }; -static arc arcs_23_4[2] = { - {21, 3}, - {0, 4}, +static arc arcs_23_4[1] = { + {52, 6}, }; -static state states_23[5] = { +static arc arcs_23_5[1] = { + {13, 3}, +}; +static arc arcs_23_6[2] = { + {21, 4}, + {0, 6}, +}; +static state states_23[7] = { {1, arcs_23_0}, - {1, arcs_23_1}, - {2, arcs_23_2}, - {1, arcs_23_3}, - {2, arcs_23_4}, + {2, arcs_23_1}, + {1, arcs_23_2}, + {2, arcs_23_3}, + {1, arcs_23_4}, + {1, arcs_23_5}, + {2, arcs_23_6}, }; static arc arcs_24_0[1] = { {13, 1}, @@ -1057,7 +1066,7 @@ static dfa dfas[51] = { "\000\000\000\000\000\000\003\000\000\000\000\000\000\000\000"}, {278, "global_stmt", 0, 3, states_22, "\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"}, - {279, "access_stmt", 0, 5, states_23, + {279, "access_stmt", 0, 7, states_23, "\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"}, {280, "accesstype", 0, 2, states_24, "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"},