mirror of https://github.com/python/cpython
ANSI-fication of the sources.
This commit is contained in:
parent
f5accf38ea
commit
a2f5511941
|
@ -34,7 +34,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
long
|
long
|
||||||
PyInt_GetMax()
|
PyInt_GetMax(void)
|
||||||
{
|
{
|
||||||
return LONG_MAX; /* To initialize sys.maxint */
|
return LONG_MAX; /* To initialize sys.maxint */
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,7 @@ PyIntObject _Py_TrueStruct = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
err_ovf(msg)
|
err_ovf(char *msg)
|
||||||
char *msg;
|
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_OverflowError, msg);
|
PyErr_SetString(PyExc_OverflowError, msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -84,7 +83,7 @@ static PyIntBlock *block_list = NULL;
|
||||||
static PyIntObject *free_list = NULL;
|
static PyIntObject *free_list = NULL;
|
||||||
|
|
||||||
static PyIntObject *
|
static PyIntObject *
|
||||||
fill_free_list()
|
fill_free_list(void)
|
||||||
{
|
{
|
||||||
PyIntObject *p, *q;
|
PyIntObject *p, *q;
|
||||||
/* XXX Int blocks escape the object heap. Use PyObject_MALLOC ??? */
|
/* XXX Int blocks escape the object heap. Use PyObject_MALLOC ??? */
|
||||||
|
@ -120,8 +119,7 @@ int quick_int_allocs, quick_neg_int_allocs;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyInt_FromLong(ival)
|
PyInt_FromLong(long ival)
|
||||||
long ival;
|
|
||||||
{
|
{
|
||||||
register PyIntObject *v;
|
register PyIntObject *v;
|
||||||
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
|
#if NSMALLNEGINTS + NSMALLPOSINTS > 0
|
||||||
|
@ -157,16 +155,14 @@ PyInt_FromLong(ival)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
int_dealloc(v)
|
int_dealloc(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
v->ob_type = (struct _typeobject *)free_list;
|
v->ob_type = (struct _typeobject *)free_list;
|
||||||
free_list = v;
|
free_list = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
PyInt_AsLong(op)
|
PyInt_AsLong(register PyObject *op)
|
||||||
register PyObject *op;
|
|
||||||
{
|
{
|
||||||
PyNumberMethods *nb;
|
PyNumberMethods *nb;
|
||||||
PyIntObject *io;
|
PyIntObject *io;
|
||||||
|
@ -197,10 +193,7 @@ PyInt_AsLong(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyInt_FromString(s, pend, base)
|
PyInt_FromString(char *s, char **pend, int base)
|
||||||
char *s;
|
|
||||||
char **pend;
|
|
||||||
int base;
|
|
||||||
{
|
{
|
||||||
char *end;
|
char *end;
|
||||||
long x;
|
long x;
|
||||||
|
@ -239,10 +232,7 @@ PyInt_FromString(s, pend, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyInt_FromUnicode(s, length, base)
|
PyInt_FromUnicode(Py_UNICODE *s, int length, int base)
|
||||||
Py_UNICODE *s;
|
|
||||||
int length;
|
|
||||||
int base;
|
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
|
@ -260,18 +250,15 @@ PyInt_FromUnicode(s, length, base)
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
static int
|
static int
|
||||||
int_print(v, fp, flags)
|
int_print(PyIntObject *v, FILE *fp, int flags)
|
||||||
PyIntObject *v;
|
/* flags -- not used but required by interface */
|
||||||
FILE *fp;
|
|
||||||
int flags; /* Not used but required by interface */
|
|
||||||
{
|
{
|
||||||
fprintf(fp, "%ld", v->ob_ival);
|
fprintf(fp, "%ld", v->ob_ival);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_repr(v)
|
int_repr(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
char buf[20];
|
char buf[20];
|
||||||
sprintf(buf, "%ld", v->ob_ival);
|
sprintf(buf, "%ld", v->ob_ival);
|
||||||
|
@ -279,8 +266,7 @@ int_repr(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
int_compare(v, w)
|
int_compare(PyIntObject *v, PyIntObject *w)
|
||||||
PyIntObject *v, *w;
|
|
||||||
{
|
{
|
||||||
register long i = v->ob_ival;
|
register long i = v->ob_ival;
|
||||||
register long j = w->ob_ival;
|
register long j = w->ob_ival;
|
||||||
|
@ -288,8 +274,7 @@ int_compare(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static long
|
static long
|
||||||
int_hash(v)
|
int_hash(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
/* XXX If this is changed, you also need to change the way
|
/* XXX If this is changed, you also need to change the way
|
||||||
Python's long, float and complex types are hashed. */
|
Python's long, float and complex types are hashed. */
|
||||||
|
@ -300,9 +285,7 @@ int_hash(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_add(v, w)
|
int_add(PyIntObject *v, PyIntObject *w)
|
||||||
PyIntObject *v;
|
|
||||||
PyIntObject *w;
|
|
||||||
{
|
{
|
||||||
register long a, b, x;
|
register long a, b, x;
|
||||||
a = v->ob_ival;
|
a = v->ob_ival;
|
||||||
|
@ -314,9 +297,7 @@ int_add(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_sub(v, w)
|
int_sub(PyIntObject *v, PyIntObject *w)
|
||||||
PyIntObject *v;
|
|
||||||
PyIntObject *w;
|
|
||||||
{
|
{
|
||||||
register long a, b, x;
|
register long a, b, x;
|
||||||
a = v->ob_ival;
|
a = v->ob_ival;
|
||||||
|
@ -357,9 +338,7 @@ guess the above is the preferred solution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_mul(v, w)
|
int_mul(PyIntObject *v, PyIntObject *w)
|
||||||
PyIntObject *v;
|
|
||||||
PyIntObject *w;
|
|
||||||
{
|
{
|
||||||
long a, b, ah, bh, x, y;
|
long a, b, ah, bh, x, y;
|
||||||
int s = 1;
|
int s = 1;
|
||||||
|
@ -458,9 +437,8 @@ int_mul(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
i_divmod(x, y, p_xdivy, p_xmody)
|
i_divmod(register PyIntObject *x, register PyIntObject *y,
|
||||||
register PyIntObject *x, *y;
|
long *p_xdivy, long *p_xmody)
|
||||||
long *p_xdivy, *p_xmody;
|
|
||||||
{
|
{
|
||||||
long xi = x->ob_ival;
|
long xi = x->ob_ival;
|
||||||
long yi = y->ob_ival;
|
long yi = y->ob_ival;
|
||||||
|
@ -500,9 +478,7 @@ i_divmod(x, y, p_xdivy, p_xmody)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_div(x, y)
|
int_div(PyIntObject *x, PyIntObject *y)
|
||||||
PyIntObject *x;
|
|
||||||
PyIntObject *y;
|
|
||||||
{
|
{
|
||||||
long d, m;
|
long d, m;
|
||||||
if (i_divmod(x, y, &d, &m) < 0)
|
if (i_divmod(x, y, &d, &m) < 0)
|
||||||
|
@ -511,9 +487,7 @@ int_div(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_mod(x, y)
|
int_mod(PyIntObject *x, PyIntObject *y)
|
||||||
PyIntObject *x;
|
|
||||||
PyIntObject *y;
|
|
||||||
{
|
{
|
||||||
long d, m;
|
long d, m;
|
||||||
if (i_divmod(x, y, &d, &m) < 0)
|
if (i_divmod(x, y, &d, &m) < 0)
|
||||||
|
@ -522,9 +496,7 @@ int_mod(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_divmod(x, y)
|
int_divmod(PyIntObject *x, PyIntObject *y)
|
||||||
PyIntObject *x;
|
|
||||||
PyIntObject *y;
|
|
||||||
{
|
{
|
||||||
long d, m;
|
long d, m;
|
||||||
if (i_divmod(x, y, &d, &m) < 0)
|
if (i_divmod(x, y, &d, &m) < 0)
|
||||||
|
@ -533,10 +505,7 @@ int_divmod(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_pow(v, w, z)
|
int_pow(PyIntObject *v, PyIntObject *w, PyIntObject *z)
|
||||||
PyIntObject *v;
|
|
||||||
PyIntObject *w;
|
|
||||||
PyIntObject *z;
|
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
register long iv, iw, iz=0, ix, temp, prev;
|
register long iv, iw, iz=0, ix, temp, prev;
|
||||||
|
@ -632,8 +601,7 @@ int_pow(v, w, z)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_neg(v)
|
int_neg(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
register long a, x;
|
register long a, x;
|
||||||
a = v->ob_ival;
|
a = v->ob_ival;
|
||||||
|
@ -644,16 +612,14 @@ int_neg(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_pos(v)
|
int_pos(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
return (PyObject *)v;
|
return (PyObject *)v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_abs(v)
|
int_abs(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
if (v->ob_ival >= 0)
|
if (v->ob_ival >= 0)
|
||||||
return int_pos(v);
|
return int_pos(v);
|
||||||
|
@ -662,23 +628,19 @@ int_abs(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
int_nonzero(v)
|
int_nonzero(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
return v->ob_ival != 0;
|
return v->ob_ival != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_invert(v)
|
int_invert(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
return PyInt_FromLong(~v->ob_ival);
|
return PyInt_FromLong(~v->ob_ival);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_lshift(v, w)
|
int_lshift(PyIntObject *v, PyIntObject *w)
|
||||||
PyIntObject *v;
|
|
||||||
PyIntObject *w;
|
|
||||||
{
|
{
|
||||||
register long a, b;
|
register long a, b;
|
||||||
a = v->ob_ival;
|
a = v->ob_ival;
|
||||||
|
@ -699,9 +661,7 @@ int_lshift(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_rshift(v, w)
|
int_rshift(PyIntObject *v, PyIntObject *w)
|
||||||
PyIntObject *v;
|
|
||||||
PyIntObject *w;
|
|
||||||
{
|
{
|
||||||
register long a, b;
|
register long a, b;
|
||||||
a = v->ob_ival;
|
a = v->ob_ival;
|
||||||
|
@ -727,9 +687,7 @@ int_rshift(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_and(v, w)
|
int_and(PyIntObject *v, PyIntObject *w)
|
||||||
PyIntObject *v;
|
|
||||||
PyIntObject *w;
|
|
||||||
{
|
{
|
||||||
register long a, b;
|
register long a, b;
|
||||||
a = v->ob_ival;
|
a = v->ob_ival;
|
||||||
|
@ -738,9 +696,7 @@ int_and(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_xor(v, w)
|
int_xor(PyIntObject *v, PyIntObject *w)
|
||||||
PyIntObject *v;
|
|
||||||
PyIntObject *w;
|
|
||||||
{
|
{
|
||||||
register long a, b;
|
register long a, b;
|
||||||
a = v->ob_ival;
|
a = v->ob_ival;
|
||||||
|
@ -749,9 +705,7 @@ int_xor(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_or(v, w)
|
int_or(PyIntObject *v, PyIntObject *w)
|
||||||
PyIntObject *v;
|
|
||||||
PyIntObject *w;
|
|
||||||
{
|
{
|
||||||
register long a, b;
|
register long a, b;
|
||||||
a = v->ob_ival;
|
a = v->ob_ival;
|
||||||
|
@ -760,30 +714,26 @@ int_or(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_int(v)
|
int_int(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
return (PyObject *)v;
|
return (PyObject *)v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_long(v)
|
int_long(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
return PyLong_FromLong((v -> ob_ival));
|
return PyLong_FromLong((v -> ob_ival));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_float(v)
|
int_float(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
return PyFloat_FromDouble((double)(v -> ob_ival));
|
return PyFloat_FromDouble((double)(v -> ob_ival));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_oct(v)
|
int_oct(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
long x = v -> ob_ival;
|
long x = v -> ob_ival;
|
||||||
|
@ -795,8 +745,7 @@ int_oct(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
int_hex(v)
|
int_hex(PyIntObject *v)
|
||||||
PyIntObject *v;
|
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
long x = v -> ob_ival;
|
long x = v -> ob_ival;
|
||||||
|
@ -849,7 +798,7 @@ PyTypeObject PyInt_Type = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
PyInt_Fini()
|
PyInt_Fini(void)
|
||||||
{
|
{
|
||||||
PyIntObject *p;
|
PyIntObject *p;
|
||||||
PyIntBlock *list, *next;
|
PyIntBlock *list, *next;
|
||||||
|
|
|
@ -22,8 +22,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
((((n)+(PyTryBlock)-1)/(PyTryBlock))*(PyTryBlock))
|
((((n)+(PyTryBlock)-1)/(PyTryBlock))*(PyTryBlock))
|
||||||
|
|
||||||
static int
|
static int
|
||||||
roundupsize(n)
|
roundupsize(int n)
|
||||||
int n;
|
|
||||||
{
|
{
|
||||||
if (n < 500)
|
if (n < 500)
|
||||||
return ROUNDUP(n, 10);
|
return ROUNDUP(n, 10);
|
||||||
|
@ -34,8 +33,7 @@ roundupsize(n)
|
||||||
#define NRESIZE(var, type, nitems) PyMem_RESIZE(var, type, roundupsize(nitems))
|
#define NRESIZE(var, type, nitems) PyMem_RESIZE(var, type, roundupsize(nitems))
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyList_New(size)
|
PyList_New(int size)
|
||||||
int size;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyListObject *op;
|
PyListObject *op;
|
||||||
|
@ -74,8 +72,7 @@ PyList_New(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyList_Size(op)
|
PyList_Size(PyObject *op)
|
||||||
PyObject *op;
|
|
||||||
{
|
{
|
||||||
if (!PyList_Check(op)) {
|
if (!PyList_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -88,9 +85,7 @@ PyList_Size(op)
|
||||||
static PyObject *indexerr;
|
static PyObject *indexerr;
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyList_GetItem(op, i)
|
PyList_GetItem(PyObject *op, int i)
|
||||||
PyObject *op;
|
|
||||||
int i;
|
|
||||||
{
|
{
|
||||||
if (!PyList_Check(op)) {
|
if (!PyList_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -107,10 +102,8 @@ PyList_GetItem(op, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyList_SetItem(op, i, newitem)
|
PyList_SetItem(register PyObject *op, register int i,
|
||||||
register PyObject *op;
|
register PyObject *newitem)
|
||||||
register int i;
|
|
||||||
register PyObject *newitem;
|
|
||||||
{
|
{
|
||||||
register PyObject *olditem;
|
register PyObject *olditem;
|
||||||
register PyObject **p;
|
register PyObject **p;
|
||||||
|
@ -133,10 +126,7 @@ PyList_SetItem(op, i, newitem)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ins1(self, where, v)
|
ins1(PyListObject *self, int where, PyObject *v)
|
||||||
PyListObject *self;
|
|
||||||
int where;
|
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyObject **items;
|
PyObject **items;
|
||||||
|
@ -164,10 +154,7 @@ ins1(self, where, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyList_Insert(op, where, newitem)
|
PyList_Insert(PyObject *op, int where, PyObject *newitem)
|
||||||
PyObject *op;
|
|
||||||
int where;
|
|
||||||
PyObject *newitem;
|
|
||||||
{
|
{
|
||||||
if (!PyList_Check(op)) {
|
if (!PyList_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -177,9 +164,7 @@ PyList_Insert(op, where, newitem)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyList_Append(op, newitem)
|
PyList_Append(PyObject *op, PyObject *newitem)
|
||||||
PyObject *op;
|
|
||||||
PyObject *newitem;
|
|
||||||
{
|
{
|
||||||
if (!PyList_Check(op)) {
|
if (!PyList_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -192,8 +177,7 @@ PyList_Append(op, newitem)
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
list_dealloc(op)
|
list_dealloc(PyListObject *op)
|
||||||
PyListObject *op;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Py_TRASHCAN_SAFE_BEGIN(op)
|
Py_TRASHCAN_SAFE_BEGIN(op)
|
||||||
|
@ -215,10 +199,7 @@ list_dealloc(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
list_print(op, fp, flags)
|
list_print(PyListObject *op, FILE *fp, int flags)
|
||||||
PyListObject *op;
|
|
||||||
FILE *fp;
|
|
||||||
int flags;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -244,8 +225,7 @@ list_print(op, fp, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
list_repr(v)
|
list_repr(PyListObject *v)
|
||||||
PyListObject *v;
|
|
||||||
{
|
{
|
||||||
PyObject *s, *comma;
|
PyObject *s, *comma;
|
||||||
int i;
|
int i;
|
||||||
|
@ -270,8 +250,7 @@ list_repr(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
list_compare(v, w)
|
list_compare(PyListObject *v, PyListObject *w)
|
||||||
PyListObject *v, *w;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < v->ob_size && i < w->ob_size; i++) {
|
for (i = 0; i < v->ob_size && i < w->ob_size; i++) {
|
||||||
|
@ -283,8 +262,7 @@ list_compare(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
list_length(a)
|
list_length(PyListObject *a)
|
||||||
PyListObject *a;
|
|
||||||
{
|
{
|
||||||
return a->ob_size;
|
return a->ob_size;
|
||||||
}
|
}
|
||||||
|
@ -292,9 +270,7 @@ list_length(a)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
list_contains(a, el)
|
list_contains(PyListObject *a, PyObject *el)
|
||||||
PyListObject *a;
|
|
||||||
PyObject *el;
|
|
||||||
{
|
{
|
||||||
int i, cmp;
|
int i, cmp;
|
||||||
|
|
||||||
|
@ -310,9 +286,7 @@ list_contains(a, el)
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
list_item(a, i)
|
list_item(PyListObject *a, int i)
|
||||||
PyListObject *a;
|
|
||||||
int i;
|
|
||||||
{
|
{
|
||||||
if (i < 0 || i >= a->ob_size) {
|
if (i < 0 || i >= a->ob_size) {
|
||||||
if (indexerr == NULL)
|
if (indexerr == NULL)
|
||||||
|
@ -326,9 +300,7 @@ list_item(a, i)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
list_slice(a, ilow, ihigh)
|
list_slice(PyListObject *a, int ilow, int ihigh)
|
||||||
PyListObject *a;
|
|
||||||
int ilow, ihigh;
|
|
||||||
{
|
{
|
||||||
PyListObject *np;
|
PyListObject *np;
|
||||||
int i;
|
int i;
|
||||||
|
@ -352,9 +324,7 @@ list_slice(a, ilow, ihigh)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyList_GetSlice(a, ilow, ihigh)
|
PyList_GetSlice(PyObject *a, int ilow, int ihigh)
|
||||||
PyObject *a;
|
|
||||||
int ilow, ihigh;
|
|
||||||
{
|
{
|
||||||
if (!PyList_Check(a)) {
|
if (!PyList_Check(a)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -364,9 +334,7 @@ PyList_GetSlice(a, ilow, ihigh)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
list_concat(a, bb)
|
list_concat(PyListObject *a, PyObject *bb)
|
||||||
PyListObject *a;
|
|
||||||
PyObject *bb;
|
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
int i;
|
int i;
|
||||||
|
@ -398,9 +366,7 @@ list_concat(a, bb)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
list_repeat(a, n)
|
list_repeat(PyListObject *a, int n)
|
||||||
PyListObject *a;
|
|
||||||
int n;
|
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int size;
|
int size;
|
||||||
|
@ -424,10 +390,7 @@ list_repeat(a, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
list_ass_slice(a, ilow, ihigh, v)
|
list_ass_slice(PyListObject *a, int ilow, int ihigh, PyObject *v)
|
||||||
PyListObject *a;
|
|
||||||
int ilow, ihigh;
|
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
/* Because [X]DECREF can recursively invoke list operations on
|
/* Because [X]DECREF can recursively invoke list operations on
|
||||||
this list, we must postpone all [X]DECREF activity until
|
this list, we must postpone all [X]DECREF activity until
|
||||||
|
@ -515,10 +478,7 @@ list_ass_slice(a, ilow, ihigh, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyList_SetSlice(a, ilow, ihigh, v)
|
PyList_SetSlice(PyObject *a, int ilow, int ihigh, PyObject *v)
|
||||||
PyObject *a;
|
|
||||||
int ilow, ihigh;
|
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
if (!PyList_Check(a)) {
|
if (!PyList_Check(a)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -528,10 +488,7 @@ PyList_SetSlice(a, ilow, ihigh, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
list_ass_item(a, i, v)
|
list_ass_item(PyListObject *a, int i, PyObject *v)
|
||||||
PyListObject *a;
|
|
||||||
int i;
|
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
PyObject *old_value;
|
PyObject *old_value;
|
||||||
if (i < 0 || i >= a->ob_size) {
|
if (i < 0 || i >= a->ob_size) {
|
||||||
|
@ -549,10 +506,7 @@ list_ass_item(a, i, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
ins(self, where, v)
|
ins(PyListObject *self, int where, PyObject *v)
|
||||||
PyListObject *self;
|
|
||||||
int where;
|
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
if (ins1(self, where, v) != 0)
|
if (ins1(self, where, v) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -561,9 +515,7 @@ ins(self, where, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listinsert(self, args)
|
listinsert(PyListObject *self, PyObject *args)
|
||||||
PyListObject *self;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
@ -587,9 +539,7 @@ listinsert(self, args)
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listappend(self, args)
|
listappend(PyListObject *self, PyObject *args)
|
||||||
PyListObject *self;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
if (!PyArg_ParseTuple_Compat1(args, "O:append", &v))
|
if (!PyArg_ParseTuple_Compat1(args, "O:append", &v))
|
||||||
|
@ -598,9 +548,7 @@ listappend(self, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listextend(self, args)
|
listextend(PyListObject *self, PyObject *args)
|
||||||
PyListObject *self;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
PyObject *b = NULL, *res = NULL;
|
PyObject *b = NULL, *res = NULL;
|
||||||
PyObject **items;
|
PyObject **items;
|
||||||
|
@ -664,9 +612,7 @@ listextend(self, args)
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listpop(self, args)
|
listpop(PyListObject *self, PyObject *args)
|
||||||
PyListObject *self;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int i = -1;
|
int i = -1;
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
@ -706,10 +652,7 @@ listpop(self, args)
|
||||||
supplied function is NULL. */
|
supplied function is NULL. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
docompare(x, y, compare)
|
docompare(PyObject *x, PyObject *y, PyObject *compare)
|
||||||
PyObject *x;
|
|
||||||
PyObject *y;
|
|
||||||
PyObject *compare;
|
|
||||||
{
|
{
|
||||||
PyObject *args, *res;
|
PyObject *args, *res;
|
||||||
int i;
|
int i;
|
||||||
|
@ -795,11 +738,8 @@ docompare(x, y, compare)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
binarysort(lo, hi, start, compare)
|
binarysort(PyObject **lo, PyObject **hi, PyObject **start, PyObject *compare)
|
||||||
PyObject **lo;
|
/* compare -- comparison function object, or NULL for default */
|
||||||
PyObject **hi;
|
|
||||||
PyObject **start;
|
|
||||||
PyObject *compare;/* Comparison function object, or NULL for default */
|
|
||||||
{
|
{
|
||||||
/* assert lo <= start <= hi
|
/* assert lo <= start <= hi
|
||||||
assert [lo, start) is sorted */
|
assert [lo, start) is sorted */
|
||||||
|
@ -929,10 +869,8 @@ static long cutoff[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
samplesortslice(lo, hi, compare)
|
samplesortslice(PyObject **lo, PyObject **hi, PyObject *compare)
|
||||||
PyObject **lo;
|
/* compare -- comparison function object, or NULL for default */
|
||||||
PyObject **hi;
|
|
||||||
PyObject *compare;/* Comparison function object, or NULL for default */
|
|
||||||
{
|
{
|
||||||
register PyObject **l, **r;
|
register PyObject **l, **r;
|
||||||
register PyObject *tmp, *pivot;
|
register PyObject *tmp, *pivot;
|
||||||
|
@ -1235,9 +1173,7 @@ samplesortslice(lo, hi, compare)
|
||||||
staticforward PyTypeObject immutable_list_type;
|
staticforward PyTypeObject immutable_list_type;
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listsort(self, args)
|
listsort(PyListObject *self, PyObject *args)
|
||||||
PyListObject *self;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
PyObject *compare = NULL;
|
PyObject *compare = NULL;
|
||||||
|
@ -1258,8 +1194,7 @@ listsort(self, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyList_Sort(v)
|
PyList_Sort(PyObject *v)
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
if (v == NULL || !PyList_Check(v)) {
|
if (v == NULL || !PyList_Check(v)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -1273,9 +1208,7 @@ PyList_Sort(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listreverse(self, args)
|
listreverse(PyListObject *self, PyObject *args)
|
||||||
PyListObject *self;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
register PyObject **p, **q;
|
register PyObject **p, **q;
|
||||||
register PyObject *tmp;
|
register PyObject *tmp;
|
||||||
|
@ -1297,8 +1230,7 @@ listreverse(self, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyList_Reverse(v)
|
PyList_Reverse(PyObject *v)
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
if (v == NULL || !PyList_Check(v)) {
|
if (v == NULL || !PyList_Check(v)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -1312,8 +1244,7 @@ PyList_Reverse(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyList_AsTuple(v)
|
PyList_AsTuple(PyObject *v)
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
PyObject *w;
|
PyObject *w;
|
||||||
PyObject **p;
|
PyObject **p;
|
||||||
|
@ -1338,9 +1269,7 @@ PyList_AsTuple(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listindex(self, args)
|
listindex(PyListObject *self, PyObject *args)
|
||||||
PyListObject *self;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
@ -1358,9 +1287,7 @@ listindex(self, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listcount(self, args)
|
listcount(PyListObject *self, PyObject *args)
|
||||||
PyListObject *self;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1378,9 +1305,7 @@ listcount(self, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listremove(self, args)
|
listremove(PyListObject *self, PyObject *args)
|
||||||
PyListObject *self;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
|
@ -1459,9 +1384,7 @@ static PyMethodDef list_methods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
list_getattr(f, name)
|
list_getattr(PyListObject *f, char *name)
|
||||||
PyListObject *f;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
return Py_FindMethod(list_methods, (PyObject *)f, name);
|
return Py_FindMethod(list_methods, (PyObject *)f, name);
|
||||||
}
|
}
|
||||||
|
@ -1512,7 +1435,7 @@ PyTypeObject PyList_Type = {
|
||||||
compare a list that's being sorted... */
|
compare a list that's being sorted... */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
immutable_list_op(/*No args!*/)
|
immutable_list_op(void)
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"a list cannot be modified while it is being sorted");
|
"a list cannot be modified while it is being sorted");
|
||||||
|
@ -1531,15 +1454,13 @@ static PyMethodDef immutable_list_methods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
immutable_list_getattr(f, name)
|
immutable_list_getattr(PyListObject *f, char *name)
|
||||||
PyListObject *f;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
return Py_FindMethod(immutable_list_methods, (PyObject *)f, name);
|
return Py_FindMethod(immutable_list_methods, (PyObject *)f, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
immutable_list_ass(/*No args!*/)
|
immutable_list_ass(void)
|
||||||
{
|
{
|
||||||
immutable_list_op();
|
immutable_list_op();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1581,4 +1502,3 @@ static PyTypeObject immutable_list_type = {
|
||||||
0, /* tp_doc */
|
0, /* tp_doc */
|
||||||
(traverseproc)list_traverse, /* tp_traverse */
|
(traverseproc)list_traverse, /* tp_traverse */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue