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 /Python/modsupport.c | |
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 'Python/modsupport.c')
-rw-r--r-- | Python/modsupport.c | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c index b464c8e..d998ad8 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -28,17 +28,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "modsupport.h" #include "import.h" -#ifdef HAVE_PROTOTYPES -#define USE_STDARG -#endif - -#ifdef USE_STDARG -#include <stdarg.h> -#else -#include <varargs.h> -#endif - - object * initmodule(name, methods) char *name; @@ -454,7 +443,7 @@ do_mkvalue(p_format, p_va) case '(': return do_mktuple(p_format, p_va, ')', countformat(*p_format, ')')); - + case 'b': case 'h': case 'i': @@ -466,7 +455,7 @@ do_mkvalue(p_format, p_va) case 'f': case 'd': return newfloatobject((double)va_arg(*p_va, double)); - + case 'c': { char p[1]; @@ -532,32 +521,34 @@ object *mkvalue(char *format, ...) object *mkvalue(va_alist) va_dcl #endif { - int n; - char *f; va_list va; object* retval; #ifdef USE_STDARG va_start(va, format); #else char *format; - va_start(va); format = va_arg(va, char *); #endif - f = format; - n = countformat(f, '\0'); - if (n < 0) - retval = NULL; /* Error in the format */ - else if (n == 0) { - retval = None; - INCREF(retval); - } - else if (n == 1) - retval = do_mkvalue(&f, &va); - else - retval = do_mktuple(&f, &va, '\0', n); + retval = vmkvalue(format, va); va_end(va); - if (retval == NULL) - fprintf(stderr, "format \"%s\", f \"%s\"\n", format, f); return retval; } + +object * +vmkvalue(format, va) + char *format; + va_list va; +{ + char *f = format; + int n = countformat(f, '\0'); + if (n < 0) + return NULL; + if (n == 0) { + INCREF(None); + return None; + } + if (n == 1) + return do_mkvalue(&f, &va); + return do_mktuple(&f, &va, '\0', n); +} |