mirror of https://github.com/python/cpython
Issue #2443: Added a new macro, Py_VA_COPY, which is equivalent to C99
va_copy, but available on all python platforms. Untabified a few unrelated files.
This commit is contained in:
parent
3a879e8a27
commit
f0f45142d5
|
@ -822,4 +822,14 @@ extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
|
||||||
#define Py_ULL(x) Py_LL(x##U)
|
#define Py_ULL(x) Py_LL(x##U)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef VA_LIST_IS_ARRAY
|
||||||
|
#define Py_VA_COPY(x, y) Py_MEMCPY((x), (y), sizeof(va_list))
|
||||||
|
#else
|
||||||
|
#ifdef __va_copy
|
||||||
|
#define Py_VA_COPY __va_copy
|
||||||
|
#else
|
||||||
|
#define Py_VA_COPY(x, y) (x) = (y)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* Py_PYPORT_H */
|
#endif /* Py_PYPORT_H */
|
||||||
|
|
|
@ -583,6 +583,10 @@ Core and Builtins
|
||||||
C-API
|
C-API
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Issue #2443: A new macro, `Py_VA_COPY`, copies the state of the
|
||||||
|
variable argument list. `Py_VA_COPY` is equivalent to C99
|
||||||
|
`va_copy`, but available on all python platforms.
|
||||||
|
|
||||||
- PySlice_GetIndicesEx now clips the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX]
|
- PySlice_GetIndicesEx now clips the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX]
|
||||||
instead of [-PY_SSIZE_T_MAX-1, PY_SSIZE_T_MAX]. This makes it safe to do
|
instead of [-PY_SSIZE_T_MAX-1, PY_SSIZE_T_MAX]. This makes it safe to do
|
||||||
"step = -step" when reversing a slice.
|
"step = -step" when reversing a slice.
|
||||||
|
|
|
@ -2311,15 +2311,7 @@ objargs_mktuple(va_list va)
|
||||||
va_list countva;
|
va_list countva;
|
||||||
PyObject *result, *tmp;
|
PyObject *result, *tmp;
|
||||||
|
|
||||||
#ifdef VA_LIST_IS_ARRAY
|
Py_VA_COPY(countva, va);
|
||||||
memcpy(countva, va, sizeof(va_list));
|
|
||||||
#else
|
|
||||||
#ifdef __va_copy
|
|
||||||
__va_copy(countva, va);
|
|
||||||
#else
|
|
||||||
countva = va;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (((PyObject *)va_arg(countva, PyObject *)) != NULL)
|
while (((PyObject *)va_arg(countva, PyObject *)) != NULL)
|
||||||
++n;
|
++n;
|
||||||
|
|
|
@ -173,15 +173,7 @@ PyBytes_FromFormatV(const char *format, va_list vargs)
|
||||||
char *s;
|
char *s;
|
||||||
PyObject* string;
|
PyObject* string;
|
||||||
|
|
||||||
#ifdef VA_LIST_IS_ARRAY
|
Py_VA_COPY(count, vargs);
|
||||||
Py_MEMCPY(count, vargs, sizeof(va_list));
|
|
||||||
#else
|
|
||||||
#ifdef __va_copy
|
|
||||||
__va_copy(count, vargs);
|
|
||||||
#else
|
|
||||||
count = vargs;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/* step 1: figure out how large a buffer we need */
|
/* step 1: figure out how large a buffer we need */
|
||||||
for (f = format; *f; f++) {
|
for (f = format; *f; f++) {
|
||||||
if (*f == '%') {
|
if (*f == '%') {
|
||||||
|
|
|
@ -755,15 +755,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
|
||||||
char fmt[61]; /* should be enough for %0width.precisionlld */
|
char fmt[61]; /* should be enough for %0width.precisionlld */
|
||||||
const char *copy;
|
const char *copy;
|
||||||
|
|
||||||
#ifdef VA_LIST_IS_ARRAY
|
Py_VA_COPY(count, vargs);
|
||||||
Py_MEMCPY(count, vargs, sizeof(va_list));
|
|
||||||
#else
|
|
||||||
#ifdef __va_copy
|
|
||||||
__va_copy(count, vargs);
|
|
||||||
#else
|
|
||||||
count = vargs;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/* step 1: count the number of %S/%R/%A/%s format specifications
|
/* step 1: count the number of %S/%R/%A/%s format specifications
|
||||||
* (we call PyObject_Str()/PyObject_Repr()/PyObject_ASCII()/
|
* (we call PyObject_Str()/PyObject_Repr()/PyObject_ASCII()/
|
||||||
* PyUnicode_DecodeUTF8() for these objects once during step 3 and put the
|
* PyUnicode_DecodeUTF8() for these objects once during step 3 and put the
|
||||||
|
|
|
@ -105,15 +105,7 @@ PyArg_VaParse(PyObject *args, const char *format, va_list va)
|
||||||
{
|
{
|
||||||
va_list lva;
|
va_list lva;
|
||||||
|
|
||||||
#ifdef VA_LIST_IS_ARRAY
|
Py_VA_COPY(lva, va);
|
||||||
memcpy(lva, va, sizeof(va_list));
|
|
||||||
#else
|
|
||||||
#ifdef __va_copy
|
|
||||||
__va_copy(lva, va);
|
|
||||||
#else
|
|
||||||
lva = va;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return vgetargs1(args, format, &lva, 0);
|
return vgetargs1(args, format, &lva, 0);
|
||||||
}
|
}
|
||||||
|
@ -123,15 +115,7 @@ _PyArg_VaParse_SizeT(PyObject *args, char *format, va_list va)
|
||||||
{
|
{
|
||||||
va_list lva;
|
va_list lva;
|
||||||
|
|
||||||
#ifdef VA_LIST_IS_ARRAY
|
Py_VA_COPY(lva, va);
|
||||||
memcpy(lva, va, sizeof(va_list));
|
|
||||||
#else
|
|
||||||
#ifdef __va_copy
|
|
||||||
__va_copy(lva, va);
|
|
||||||
#else
|
|
||||||
lva = va;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return vgetargs1(args, format, &lva, FLAG_SIZE_T);
|
return vgetargs1(args, format, &lva, FLAG_SIZE_T);
|
||||||
}
|
}
|
||||||
|
@ -1376,15 +1360,7 @@ PyArg_VaParseTupleAndKeywords(PyObject *args,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VA_LIST_IS_ARRAY
|
Py_VA_COPY(lva, va);
|
||||||
memcpy(lva, va, sizeof(va_list));
|
|
||||||
#else
|
|
||||||
#ifdef __va_copy
|
|
||||||
__va_copy(lva, va);
|
|
||||||
#else
|
|
||||||
lva = va;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
retval = vgetargskeywords(args, keywords, format, kwlist, &lva, 0);
|
retval = vgetargskeywords(args, keywords, format, kwlist, &lva, 0);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1408,15 +1384,7 @@ _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *args,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VA_LIST_IS_ARRAY
|
Py_VA_COPY(lva, va);
|
||||||
memcpy(lva, va, sizeof(va_list));
|
|
||||||
#else
|
|
||||||
#ifdef __va_copy
|
|
||||||
__va_copy(lva, va);
|
|
||||||
#else
|
|
||||||
lva = va;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
retval = vgetargskeywords(args, keywords, format,
|
retval = vgetargskeywords(args, keywords, format,
|
||||||
kwlist, &lva, FLAG_SIZE_T);
|
kwlist, &lva, FLAG_SIZE_T);
|
||||||
|
|
|
@ -456,15 +456,7 @@ va_build_value(const char *format, va_list va, int flags)
|
||||||
int n = countformat(f, '\0');
|
int n = countformat(f, '\0');
|
||||||
va_list lva;
|
va_list lva;
|
||||||
|
|
||||||
#ifdef VA_LIST_IS_ARRAY
|
Py_VA_COPY(lva, va);
|
||||||
memcpy(lva, va, sizeof(va_list));
|
|
||||||
#else
|
|
||||||
#ifdef __va_copy
|
|
||||||
__va_copy(lva, va);
|
|
||||||
#else
|
|
||||||
lva = va;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue