diff options
author | Guido van Rossum <guido@python.org> | 1993-03-16 12:15:04 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-03-16 12:15:04 (GMT) |
commit | e537240c252ff678d49451ee6f80fa934653a724 (patch) | |
tree | b3dcbdb870e90f5843ac66f26a102ea4da444ff5 /Modules | |
parent | f48b419a075dc237eb145e1b71cec12afdb7aff4 (diff) | |
download | cpython-e537240c252ff678d49451ee6f80fa934653a724.zip cpython-e537240c252ff678d49451ee6f80fa934653a724.tar.gz cpython-e537240c252ff678d49451ee6f80fa934653a724.tar.bz2 |
* Changed many files to use mkvalue() instead of newtupleobject().
* Fixcprt.py: added [-y file] option, do only files younger than file.
* modsupport.[ch]: added vmkvalue().
* intobject.c: use mkvalue().
* stringobject.c: added "formatstring"; renamed string* to string_*;
ceval.c: call formatstring for string % value.
* longobject.c: close memory leak in divmod.
* parsetok.c: set result node to NULL when returning an error.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/almodule.c | 4 | ||||
-rw-r--r-- | Modules/clmodule.c | 4 | ||||
-rw-r--r-- | Modules/flmodule.c | 70 | ||||
-rw-r--r-- | Modules/fmmodule.c | 29 | ||||
-rw-r--r-- | Modules/mathmodule.c | 28 | ||||
-rw-r--r-- | Modules/posixmodule.c | 52 | ||||
-rw-r--r-- | Modules/pwdmodule.c | 53 | ||||
-rw-r--r-- | Modules/selectmodule.c | 4 | ||||
-rw-r--r-- | Modules/socketmodule.c | 4 |
9 files changed, 72 insertions, 176 deletions
diff --git a/Modules/almodule.c b/Modules/almodule.c index aef2eee..d986d34 100644 --- a/Modules/almodule.c +++ b/Modules/almodule.c @@ -1,6 +1,6 @@ /********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/clmodule.c b/Modules/clmodule.c index 8220862..a9a378e 100644 --- a/Modules/clmodule.c +++ b/Modules/clmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/flmodule.c b/Modules/flmodule.c index dca39ad..00cf12c 100644 --- a/Modules/flmodule.c +++ b/Modules/flmodule.c @@ -1,6 +1,6 @@ /********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -614,18 +614,12 @@ call_forms_OUTfOUTf (func, obj, args) object *args; { float f1, f2; - object *arg; if (!getnoarg(args)) return NULL; (*func) (obj, &f1, &f2); - - arg = newtupleobject (2); - if (arg == NULL) return NULL; - settupleitem (arg, 0, newfloatobject (f1)); - settupleitem (arg, 1, newfloatobject (f2)); - return arg; + return mkvalue("(ff)", f1, f2); } #ifdef UNUSED @@ -966,20 +960,13 @@ get_clock(g, args) object *args; { int i0, i1, i2; - object *arg; if (!getnoarg(args)) return NULL; fl_get_clock (g->ob_generic, &i0, &i1, &i2); - arg = newtupleobject (3); - if (arg == NULL) return NULL; - - settupleitem (arg, 0, newintobject (i0)); - settupleitem (arg, 1, newintobject (i1)); - settupleitem (arg, 2, newintobject (i2)); - return arg; + return mkvalue("(iii)", i0, i1, i2); } static struct methodlist clock_methods[] = { @@ -2064,11 +2051,9 @@ forms_do_or_check_forms(dummy, args, func) if (my_event_callback == NULL) return newintobject(-1L); dev = fl_qread(&val); - arg = newtupleobject(2); + arg = mkvalue("(ih)", dev, val); if (arg == NULL) return NULL; - settupleitem(arg, 0, newintobject((long)dev)); - settupleitem(arg, 1, newintobject((long)val)); res = call_object(my_event_callback, arg); XDECREF(res); DECREF(arg); @@ -2085,11 +2070,9 @@ forms_do_or_check_forms(dummy, args, func) INCREF(g); return ((object *) g); } - arg = newtupleobject(2); - INCREF(g); - settupleitem(arg, 0, (object *)g); - INCREF(g->ob_callback_arg); - settupleitem(arg, 1, g->ob_callback_arg); + arg = mkvalue("(OO)", (object *)g, g->ob_callback_arg); + if (arg == NULL) + return NULL; res = call_object(g->ob_callback, arg); XDECREF(res); DECREF(arg); @@ -2259,18 +2242,12 @@ forms_qread(self, args) object *self; object *args; { - long retval; - short arg1; + int dev; + short val; BGN_SAVE - retval = fl_qread(&arg1); + dev = fl_qread(&val); END_SAVE - { - object *v = newtupleobject(2); - if (v == NULL) return NULL; - settupleitem(v, 0, newintobject(retval)); - settupleitem(v, 1, newintobject((long)arg1)); - return v; - } + return mkvalue("(ih)", dev, val); } static object * @@ -2336,21 +2313,12 @@ forms_getmcolor(self, args) { int arg; short r, g, b; - object *v; if (!getintarg(args, &arg)) return NULL; fl_getmcolor(arg, &r, &g, &b); - v = newtupleobject(3); - - if (v == NULL) return NULL; - - settupleitem(v, 0, newintobject((long)r)); - settupleitem(v, 1, newintobject((long)g)); - settupleitem(v, 2, newintobject((long)b)); - - return v; + return mkvalue("(hhh)", r, g, b); } static object * @@ -2358,21 +2326,13 @@ forms_get_mouse(self, args) object *self; object *args; { - float x, y ; - object *v; + float x, y; if (!getnoarg(args)) return NULL; fl_get_mouse(&x, &y); - v = newtupleobject(2); - - if (v == NULL) return NULL; - - settupleitem(v, 0, newfloatobject(x)); - settupleitem(v, 1, newfloatobject(y)); - - return v; + return mkvalue("(ff)", x, y); } static object * diff --git a/Modules/fmmodule.c b/Modules/fmmodule.c index f3df6ce..8d54d97 100644 --- a/Modules/fmmodule.c +++ b/Modules/fmmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -134,22 +134,15 @@ fh_getfontinfo(self, args) err_setstr(RuntimeError, "error in fmgetfontinfo"); return NULL; } - v = newtupleobject(8); - if (v == NULL) - return NULL; -#define SET(i, member) settupleitem(v, i, newintobject(info.member)) - SET(0, printermatched); - SET(1, fixed_width); - SET(2, xorig); - SET(3, yorig); - SET(4, xsize); - SET(5, ysize); - SET(6, height); - SET(7, nglyphs); -#undef SET - if (err_occurred()) - return NULL; - return v; + return mkvalue("(llllllll)", + info.printermatched, + info.fixed_width, + info.xorig, + info.yorig, + info.xsize, + info.ysize, + info.height, + info.nglyphs); } #if 0 diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 00aa5eb..1521133 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -136,7 +136,6 @@ math_frexp(self, args) object *self; object *args; { - object *v; double x; int i; if (!getdoublearg(args, &x)) @@ -146,16 +145,7 @@ math_frexp(self, args) CHECK(x); if (errno != 0) return math_error(); - v = newtupleobject(2); - if (v != NULL) { - settupleitem(v, 0, newfloatobject(x)); - settupleitem(v, 1, newintobject((long)i)); - if (err_occurred()) { - DECREF(v); - v = NULL; - } - } - return v; + return mkvalue("(di)", x, i); } static object * @@ -181,7 +171,6 @@ math_modf(self, args) object *self; object *args; { - object *v; double x, y; if (!getdoublearg(args, &x)) return NULL; @@ -190,16 +179,7 @@ math_modf(self, args) CHECK(x); if (errno != 0) return math_error(); - v = newtupleobject(2); - if (v != NULL) { - settupleitem(v, 0, newfloatobject(x)); - settupleitem(v, 1, newfloatobject(y)); - if (err_occurred()) { - DECREF(v); - v = NULL; - } - } - return v; + return mkvalue("(dd)", x, y); } static struct methodlist math_methods[] = { diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index a600115..4e84407 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -216,26 +216,17 @@ posix_do_stat(self, args, statfunc) END_SAVE if (res != 0) return posix_error(); - v = newtupleobject(10); - if (v == NULL) - return NULL; -#define SET(i, st_member) settupleitem(v, i, newintobject((long)st.st_member)) - SET(0, st_mode); - SET(1, st_ino); - SET(2, st_dev); - SET(3, st_nlink); - SET(4, st_uid); - SET(5, st_gid); - SET(6, st_size); - SET(7, st_atime); - SET(8, st_mtime); - SET(9, st_ctime); -#undef SET - if (err_occurred()) { - DECREF(v); - return NULL; - } - return v; + v = mkvalue("(llllllllll)", + (long)st.st_mode, + (long)st.st_ino, + (long)st.st_dev, + (long)st.st_nlink, + (long)st.st_uid, + (long)st.st_gid, + (long)st.st_size, + (long)st.st_atime, + (long)st.st_mtime, + (long)st.st_ctime); } @@ -477,21 +468,12 @@ posix_uname(self, args) END_SAVE if (res < 0) return posix_error(); - v = newtupleobject(5); - if (v == NULL) - return NULL; -#define SET(i, member) settupleitem(v, i, newstringobject(u.member)) - SET(0, sysname); - SET(1, nodename); - SET(2, release); - SET(3, version); - SET(4, machine); -#undef SET - if (err_occurred()) { - DECREF(v); - return NULL; - } - return v; + return mkvalue("(sssss)", + u.sysname, + u.nodename, + u.release, + u.version, + u.machine); } #endif /* NO_UNAME */ diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c index 4d787ba..eb7a1cc 100644 --- a/Modules/pwdmodule.c +++ b/Modules/pwdmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -38,25 +38,14 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static object *mkpwent(p) struct passwd *p; { - object *v; - if ((v = newtupleobject(7)) == NULL) - return NULL; -#define ISET(i, member) settupleitem(v, i, newintobject((long)p->member)) -#define SSET(i, member) settupleitem(v, i, newstringobject(p->member)) - SSET(0, pw_name); - SSET(1, pw_passwd); - ISET(2, pw_uid); - ISET(3, pw_gid); - SSET(4, pw_gecos); - SSET(5, pw_dir); - SSET(6, pw_shell); -#undef SSET -#undef ISET - if (err_occurred()) { - DECREF(v); - return NULL; - } - return v; + return mkvalue("(ssllsss)", + p->pw_name, + p->pw_passwd, + (long)p->pw_uid, + (long)p->pw_gid, + p->pw_gecos, + p->pw_dir, + p->pw_shell); } static object *pwd_getpwuid(self, args) @@ -130,32 +119,24 @@ static object *mkgrent(p) { object *v, *w; char **member; - if ((v = newtupleobject(4)) == NULL) - return NULL; -#define ISET(i, member) settupleitem(v, i, newintobject((long)p->member)) -#define SSET(i, member) settupleitem(v, i, newstringobject(p->member)) - SSET(0, gr_name); - SSET(1, gr_passwd); - ISET(2, gr_gid); -#undef SSET -#undef ISET - if (err_occurred()) { - DECREF(v); - return NULL; - } if ((w = newlistobject(0)) == NULL) { DECREF(v); return NULL; } - (void) settupleitem(v, 3, w); /* Cannot fail; eats refcnt */ for (member = p->gr_mem; *member != NULL; member++) { object *x = newstringobject(*member); if (x == NULL || addlistitem(w, x) != 0) { XDECREF(x); - DECREF(v); + DECREF(w); return NULL; } } + v = mkvalue("(sslO)", + p->gr_name, + p->gr_passwd, + (long)p->gr_gid, + w); + DECREF(w); return v; } diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 99a9213..de80b82 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 2a0e291..0e20307 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved |