Mercurial > cpython-lru_cache-weakref
annotate Python/modsupport.c @ 1181:950cd37fcddc legacy-trunk
* Makefile: use cp -r to install the library
* ceval.c: use #ifdef COMPAT_HACKS instead of #if 0
* Makefile: fix to make clmodule.c compile;
make config.o dependent on libpython.a (so date is always correct)
* timemodule.c: now sleep() also takes a float argument.
* posixmodule.c: added nice().
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sat, 09 Jan 1993 17:18:52 +0000 |
| parents | 533e36de1e4d |
| children | 2937897a7d8b |
| rev | line source |
|---|---|
| 145 | 1 /*********************************************************** |
|
795
0cd197947d81
Copyright for 1992 added
Guido van Rossum <guido@python.org>
parents:
733
diff
changeset
|
2 Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The |
| 145 | 3 Netherlands. |
| 4 | |
| 5 All Rights Reserved | |
| 6 | |
| 7 Permission to use, copy, modify, and distribute this software and its | |
| 8 documentation for any purpose and without fee is hereby granted, | |
| 9 provided that the above copyright notice appear in all copies and that | |
| 10 both that copyright notice and this permission notice appear in | |
| 11 supporting documentation, and that the names of Stichting Mathematisch | |
| 12 Centrum or CWI not be used in advertising or publicity pertaining to | |
| 13 distribution of the software without specific, written prior permission. | |
| 14 | |
| 15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO | |
| 16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE | |
| 18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| 19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| 20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
| 21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 22 | |
| 23 ******************************************************************/ | |
| 24 | |
| 6 | 25 /* Module support implementation */ |
| 26 | |
| 86 | 27 #include "allobjects.h" |
| 6 | 28 #include "modsupport.h" |
| 29 #include "import.h" | |
| 30 | |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
31 #ifdef HAVE_PROTOTYPES |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
32 #define USE_STDARG |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
33 #endif |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
34 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
35 #ifdef USE_STDARG |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
36 #include <stdarg.h> |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
37 #else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
38 #include <varargs.h> |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
39 #endif |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
40 |
| 6 | 41 |
| 42 object * | |
| 43 initmodule(name, methods) | |
| 44 char *name; | |
| 45 struct methodlist *methods; | |
| 46 { | |
| 47 object *m, *d, *v; | |
| 48 struct methodlist *ml; | |
|
1177
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
998
diff
changeset
|
49 char *namebuf; |
| 86 | 50 if ((m = add_module(name)) == NULL) { |
| 6 | 51 fprintf(stderr, "initializing module: %s\n", name); |
| 52 fatal("can't create a module"); | |
| 53 } | |
| 54 d = getmoduledict(m); | |
| 55 for (ml = methods; ml->ml_name != NULL; ml++) { | |
|
1177
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
998
diff
changeset
|
56 namebuf = NEW(char, strlen(name) + strlen(ml->ml_name) + 2); |
|
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
998
diff
changeset
|
57 if (namebuf == NULL) |
|
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
998
diff
changeset
|
58 fatal("out of mem for method name"); |
| 86 | 59 sprintf(namebuf, "%s.%s", name, ml->ml_name); |
|
1177
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
998
diff
changeset
|
60 v = newmethodobject(namebuf, ml->ml_meth, |
|
488
90f35fcf8ea0
Add "varargs" attribute.
Guido van Rossum <guido@python.org>
parents:
372
diff
changeset
|
61 (object *)NULL, ml->ml_varargs); |
|
1177
533e36de1e4d
* Configure.py: use #!/usr/local/bin/python
Guido van Rossum <guido@python.org>
parents:
998
diff
changeset
|
62 /* XXX The malloc'ed memory in namebuf is never freed */ |
| 6 | 63 if (v == NULL || dictinsert(d, ml->ml_name, v) != 0) { |
| 64 fprintf(stderr, "initializing module: %s\n", name); | |
| 65 fatal("can't initialize module"); | |
| 66 } | |
| 67 DECREF(v); | |
| 68 } | |
| 86 | 69 return m; |
| 6 | 70 } |
| 71 | |
| 72 | |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
73 /* Helper for getargs() and mkvalue() to scan the length of a format */ |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
74 |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
75 static int countformat PROTO((char *format, int endchar)); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
76 static int countformat(format, endchar) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
77 char *format; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
78 int endchar; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
79 { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
80 int count = 0; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
81 int level = 0; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
82 while (level > 0 || *format != endchar) { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
83 if (*format == '\0') { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
84 /* Premature end */ |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
85 err_setstr(SystemError, "unmatched paren in format"); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
86 return -1; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
87 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
88 else if (*format == '(') { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
89 if (level == 0) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
90 count++; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
91 level++; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
92 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
93 else if (*format == ')') |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
94 level--; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
95 else if (level == 0 && *format != '#') |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
96 count++; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
97 format++; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
98 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
99 return count; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
100 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
101 |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
102 |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
103 /* Generic argument list parser */ |
| 6 | 104 |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
105 static int do_arg PROTO((object *arg, char** p_format, va_list *p_va)); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
106 static int |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
107 do_arg(arg, p_format, p_va) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
108 object *arg; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
109 char** p_format; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
110 va_list *p_va; |
| 6 | 111 { |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
112 char *format = *p_format; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
113 va_list va = *p_va; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
114 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
115 if (arg == NULL) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
116 return 0; /* Incomplete tuple or list */ |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
117 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
118 switch (*format++) { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
119 |
|
998
09b48604855f
suppress unnecessary error message if too many arguments are passed
Guido van Rossum <guido@python.org>
parents:
957
diff
changeset
|
120 case '(': /* tuple, distributed over C parameters */ { |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
121 int i, n; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
122 if (!is_tupleobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
123 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
124 n = gettuplesize(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
125 for (i = 0; i < n; i++) { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
126 if (!do_arg(gettupleitem(arg, i), &format, &va)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
127 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
128 } |
|
998
09b48604855f
suppress unnecessary error message if too many arguments are passed
Guido van Rossum <guido@python.org>
parents:
957
diff
changeset
|
129 if (*format++ != ')') |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
130 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
131 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
132 } |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
133 |
|
998
09b48604855f
suppress unnecessary error message if too many arguments are passed
Guido van Rossum <guido@python.org>
parents:
957
diff
changeset
|
134 case ')': /* End of format -- too many arguments */ |
|
09b48604855f
suppress unnecessary error message if too many arguments are passed
Guido van Rossum <guido@python.org>
parents:
957
diff
changeset
|
135 return 0; |
|
09b48604855f
suppress unnecessary error message if too many arguments are passed
Guido van Rossum <guido@python.org>
parents:
957
diff
changeset
|
136 |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
137 case 'b': /* byte -- very short int */ { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
138 char *p = va_arg(va, char *); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
139 if (is_intobject(arg)) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
140 *p = getintvalue(arg); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
141 else |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
142 return 0; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
143 break; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
144 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
145 |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
146 case 'h': /* short int */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
147 short *p = va_arg(va, short *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
148 if (is_intobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
149 *p = getintvalue(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
150 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
151 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
152 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
153 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
154 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
155 case 'i': /* int */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
156 int *p = va_arg(va, int *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
157 if (is_intobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
158 *p = getintvalue(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
159 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
160 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
161 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
162 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
163 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
164 case 'l': /* long int */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
165 long *p = va_arg(va, long *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
166 if (is_intobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
167 *p = getintvalue(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
168 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
169 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
170 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
171 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
172 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
173 case 'f': /* float */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
174 float *p = va_arg(va, float *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
175 if (is_floatobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
176 *p = getfloatvalue(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
177 else if (is_intobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
178 *p = (float)getintvalue(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
179 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
180 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
181 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
182 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
183 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
184 case 'd': /* double */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
185 double *p = va_arg(va, double *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
186 if (is_floatobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
187 *p = getfloatvalue(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
188 else if (is_intobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
189 *p = (double)getintvalue(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
190 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
191 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
192 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
193 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
194 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
195 case 'c': /* char */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
196 char *p = va_arg(va, char *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
197 if (is_stringobject(arg) && getstringsize(arg) == 1) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
198 *p = getstringvalue(arg)[0]; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
199 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
200 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
201 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
202 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
203 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
204 case 's': /* string */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
205 char **p = va_arg(va, char **); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
206 if (is_stringobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
207 *p = getstringvalue(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
208 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
209 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
210 if (*format == '#') { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
211 int *q = va_arg(va, int *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
212 *q = getstringsize(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
213 format++; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
214 } |
|
957
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
215 else if (strlen(*p) != getstringsize(arg)) { |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
216 err_setstr(ValueError, "embedded '\\0' in string arg"); |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
217 return 0; |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
218 } |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
219 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
220 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
221 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
222 case 'z': /* string, may be NULL (None) */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
223 char **p = va_arg(va, char **); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
224 if (arg == None) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
225 *p = 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
226 else if (is_stringobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
227 *p = getstringvalue(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
228 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
229 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
230 if (*format == '#') { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
231 int *q = va_arg(va, int *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
232 if (arg == None) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
233 *q = 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
234 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
235 *q = getstringsize(arg); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
236 format++; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
237 } |
|
957
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
238 else if (*p != NULL && strlen(*p) != getstringsize(arg)) { |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
239 err_setstr(ValueError, "embedded '\\0' in string arg"); |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
240 return 0; |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
241 } |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
242 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
243 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
244 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
245 case 'S': /* string object */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
246 object **p = va_arg(va, object **); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
247 if (is_stringobject(arg)) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
248 *p = arg; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
249 else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
250 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
251 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
252 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
253 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
254 case 'O': /* object */ { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
255 object **p = va_arg(va, object **); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
256 *p = arg; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
257 break; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
258 } |
| 6 | 259 |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
260 default: |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
261 fprintf(stderr, "bad do_arg format: x%x '%c'\n", |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
262 format[-1], format[-1]); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
263 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
264 |
| 6 | 265 } |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
266 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
267 *p_va = va; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
268 *p_format = format; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
269 |
| 6 | 270 return 1; |
| 271 } | |
| 272 | |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
273 #ifdef USE_STDARG |
| 733 | 274 /* VARARGS2 */ |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
275 int getargs(object *arg, char *format, ...) |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
276 #else |
| 733 | 277 /* VARARGS */ |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
278 int getargs(va_alist) va_dcl |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
279 #endif |
| 6 | 280 { |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
281 char *f; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
282 int ok; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
283 va_list va; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
284 #ifdef USE_STDARG |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
285 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
286 va_start(va, format); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
287 #else |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
288 object *arg; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
289 char *format; |
| 6 | 290 |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
291 va_start(va); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
292 arg = va_arg(va, object *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
293 format = va_arg(va, char *); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
294 #endif |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
295 if (*format == '\0') { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
296 va_end(va); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
297 if (arg != NULL) { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
298 err_setstr(TypeError, "no arguments needed"); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
299 return 0; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
300 } |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
301 return 1; |
| 6 | 302 } |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
303 |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
304 f = format; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
305 ok = do_arg(arg, &f, &va) && *f == '\0'; |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
306 va_end(va); |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
307 if (!ok) { |
|
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
308 char buf[256]; |
|
957
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
309 if (!err_occurred()) { |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
310 sprintf(buf, "bad argument list (format '%s')", |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
311 format); |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
312 err_setstr(TypeError, buf); |
|
5c6cdb58a801
check for embedded \0 in strings for z and s formats
Guido van Rossum <guido@python.org>
parents:
860
diff
changeset
|
313 } |
| 6 | 314 } |
|
637
3cb686c48cdd
New getargs() function: a single varargs function,
Guido van Rossum <guido@python.org>
parents:
488
diff
changeset
|
315 return ok; |
| 6 | 316 } |
| 317 | |
| 318 int | |
| 319 getlongtuplearg(args, a, n) | |
| 320 object *args; | |
| 321 long *a; /* [n] */ | |
| 322 int n; | |
| 323 { | |
| 324 int i; | |
| 325 if (!is_tupleobject(args) || gettuplesize(args) != n) { | |
| 326 return err_badarg(); | |
| 327 } | |
| 328 for (i = 0; i < n; i++) { | |
| 329 object *v = gettupleitem(args, i); | |
| 330 if (!is_intobject(v)) { | |
| 331 return err_badarg(); | |
| 332 } | |
| 333 a[i] = getintvalue(v); | |
| 334 } | |
| 335 return 1; | |
| 336 } | |
| 337 | |
| 338 int | |
| 339 getshorttuplearg(args, a, n) | |
| 340 object *args; | |
| 341 short *a; /* [n] */ | |
| 342 int n; | |
| 343 { | |
| 344 int i; | |
| 345 if (!is_tupleobject(args) || gettuplesize(args) != n) { | |
| 346 return err_badarg(); | |
| 347 } | |
| 348 for (i = 0; i < n; i++) { | |
| 349 object *v = gettupleitem(args, i); | |
| 350 if (!is_intobject(v)) { | |
| 351 return err_badarg(); | |
| 352 } | |
| 353 a[i] = getintvalue(v); | |
| 354 } | |
| 355 return 1; | |
| 356 } | |
| 357 | |
| 358 int | |
| 359 getlonglistarg(args, a, n) | |
| 360 object *args; | |
| 361 long *a; /* [n] */ | |
| 362 int n; | |
| 363 { | |
| 364 int i; | |
| 365 if (!is_listobject(args) || getlistsize(args) != n) { | |
| 366 return err_badarg(); | |
| 367 } | |
| 368 for (i = 0; i < n; i++) { | |
| 369 object *v = getlistitem(args, i); | |
| 370 if (!is_intobject(v)) { | |
| 371 return err_badarg(); | |
| 372 } | |
| 373 a[i] = getintvalue(v); | |
| 374 } | |
| 375 return 1; | |
| 376 } | |
| 377 | |
| 378 int | |
| 379 getshortlistarg(args, a, n) | |
| 380 object *args; | |
| 381 short *a; /* [n] */ | |
| 382 int n; | |
| 383 { | |
| 384 int i; | |
| 385 if (!is_listobject(args) || getlistsize(args) != n) { | |
| 386 return err_badarg(); | |
| 387 } | |
| 388 for (i = 0; i < n; i++) { | |
| 389 object *v = getlistitem(args, i); | |
| 390 if (!is_intobject(v)) { | |
| 391 return err_badarg(); | |
| 392 } | |
| 393 a[i] = getintvalue(v); | |
| 394 } | |
| 395 return 1; | |
| 396 } | |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
397 |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
398 |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
399 /* Generic function to create a value -- the inverse of getargs() */ |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
400 /* After an original idea and first implementation by Steven Miale */ |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
401 |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
402 static object *do_mktuple PROTO((char**, va_list *, int, int)); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
403 static object *do_mkvalue PROTO((char**, va_list *)); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
404 |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
405 static object * |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
406 do_mktuple(p_format, p_va, endchar, n) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
407 char **p_format; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
408 va_list *p_va; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
409 int endchar; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
410 int n; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
411 { |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
412 object *v; |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
413 int i; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
414 if (n < 0) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
415 return NULL; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
416 if ((v = newtupleobject(n)) == NULL) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
417 return NULL; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
418 for (i = 0; i < n; i++) { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
419 object *w = do_mkvalue(p_format, p_va); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
420 if (w == NULL) { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
421 DECREF(v); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
422 return NULL; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
423 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
424 settupleitem(v, i, w); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
425 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
426 if (v != NULL && **p_format != endchar) { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
427 DECREF(v); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
428 v = NULL; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
429 err_setstr(SystemError, "Unmatched paren in format"); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
430 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
431 else if (endchar) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
432 ++*p_format; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
433 return v; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
434 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
435 |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
436 static object * |
|
860
39134c99c923
Added parameter decls to do_mkvalue for non-template machines
Guido van Rossum <guido@python.org>
parents:
817
diff
changeset
|
437 do_mkvalue(p_format, p_va) |
|
39134c99c923
Added parameter decls to do_mkvalue for non-template machines
Guido van Rossum <guido@python.org>
parents:
817
diff
changeset
|
438 char **p_format; |
|
39134c99c923
Added parameter decls to do_mkvalue for non-template machines
Guido van Rossum <guido@python.org>
parents:
817
diff
changeset
|
439 va_list *p_va; |
|
39134c99c923
Added parameter decls to do_mkvalue for non-template machines
Guido van Rossum <guido@python.org>
parents:
817
diff
changeset
|
440 { |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
441 |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
442 switch (*(*p_format)++) { |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
443 |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
444 case '(': |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
445 return do_mktuple(p_format, p_va, ')', |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
446 countformat(*p_format, ')')); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
447 |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
448 case 'b': |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
449 case 'h': |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
450 case 'i': |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
451 return newintobject((long)va_arg(*p_va, int)); |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
452 |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
453 case 'l': |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
454 return newintobject((long)va_arg(*p_va, long)); |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
455 |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
456 case 'f': |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
457 case 'd': |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
458 return newfloatobject((double)va_arg(*p_va, double)); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
459 |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
460 case 'c': |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
461 { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
462 char p[1]; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
463 p[0] = va_arg(*p_va, int); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
464 return newsizedstringobject(p, 1); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
465 } |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
466 |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
467 case 's': |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
468 case 'z': |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
469 { |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
470 object *v; |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
471 char *str = va_arg(*p_va, char *); |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
472 int n; |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
473 if (**p_format == '#') { |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
474 ++*p_format; |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
475 n = va_arg(*p_va, int); |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
476 } |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
477 else |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
478 n = -1; |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
479 if (str == NULL) { |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
480 v = None; |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
481 INCREF(v); |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
482 } |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
483 else { |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
484 if (n < 0) |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
485 n = strlen(str); |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
486 v = newsizedstringobject(str, n); |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
487 } |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
488 return v; |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
489 } |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
490 |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
491 case 'S': |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
492 case 'O': |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
493 { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
494 object *v; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
495 v = va_arg(*p_va, object *); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
496 if (v != NULL) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
497 INCREF(v); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
498 else if (!err_occurred()) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
499 /* If a NULL was passed because a call |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
500 that should have constructed a value |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
501 failed, that's OK, and we pass the error |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
502 on; but if no error occurred it's not |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
503 clear that the caller knew what she |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
504 was doing. */ |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
505 err_setstr(SystemError, |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
506 "NULL object passed to mkvalue"); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
507 return v; |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
508 } |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
509 |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
510 default: |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
511 err_setstr(SystemError, "bad format char passed to mkvalue"); |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
512 return NULL; |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
513 |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
514 } |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
515 } |
|
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
516 |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
517 #ifdef USE_STDARG |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
518 /* VARARGS 2 */ |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
519 object *mkvalue(char *format, ...) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
520 #else |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
521 /* VARARGS */ |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
522 object *mkvalue(va_alist) va_dcl |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
523 #endif |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
524 { |
|
817
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
525 int n; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
526 char *f; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
527 va_list va; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
528 object* retval; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
529 #ifdef USE_STDARG |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
530 va_start(va, format); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
531 #else |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
532 char *format; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
533 |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
534 va_start(va); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
535 format = va_arg(va, char *); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
536 #endif |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
537 f = format; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
538 n = countformat(f, '\0'); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
539 if (n < 0) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
540 retval = NULL; /* Error in the format */ |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
541 else if (n == 0) { |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
542 retval = None; |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
543 INCREF(retval); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
544 } |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
545 else if (n == 1) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
546 retval = do_mkvalue(&f, &va); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
547 else |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
548 retval = do_mktuple(&f, &va, '\0', n); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
549 va_end(va); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
550 if (retval == NULL) |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
551 fprintf(stderr, "format \"%s\", f \"%s\"\n", format, f); |
|
aa633f0defa6
Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents:
816
diff
changeset
|
552 return retval; |
|
816
e4a27d84ea36
Added mkvalue() function
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
553 } |
