ANSI-fication of the sources.
This commit is contained in:
parent
7dfeb42939
commit
fd99de6470
|
@ -76,8 +76,7 @@ typedef struct {
|
||||||
} PyFileObject;
|
} PyFileObject;
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
PyFile_AsFile(f)
|
PyFile_AsFile(PyObject *f)
|
||||||
PyObject *f;
|
|
||||||
{
|
{
|
||||||
if (f == NULL || !PyFile_Check(f))
|
if (f == NULL || !PyFile_Check(f))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -86,8 +85,7 @@ PyFile_AsFile(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyFile_Name(f)
|
PyFile_Name(PyObject *f)
|
||||||
PyObject *f;
|
|
||||||
{
|
{
|
||||||
if (f == NULL || !PyFile_Check(f))
|
if (f == NULL || !PyFile_Check(f))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -96,11 +94,7 @@ PyFile_Name(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyFile_FromFile(fp, name, mode, close)
|
PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *))
|
||||||
FILE *fp;
|
|
||||||
char *name;
|
|
||||||
char *mode;
|
|
||||||
int (*close)(FILE *);
|
|
||||||
{
|
{
|
||||||
PyFileObject *f = PyObject_NEW(PyFileObject, &PyFile_Type);
|
PyFileObject *f = PyObject_NEW(PyFileObject, &PyFile_Type);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
|
@ -123,8 +117,7 @@ PyFile_FromFile(fp, name, mode, close)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyFile_FromString(name, mode)
|
PyFile_FromString(char *name, char *mode)
|
||||||
char *name, *mode;
|
|
||||||
{
|
{
|
||||||
extern int fclose(FILE *);
|
extern int fclose(FILE *);
|
||||||
PyFileObject *f;
|
PyFileObject *f;
|
||||||
|
@ -160,9 +153,7 @@ PyFile_FromString(name, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PyFile_SetBufSize(f, bufsize)
|
PyFile_SetBufSize(PyObject *f, int bufsize)
|
||||||
PyObject *f;
|
|
||||||
int bufsize;
|
|
||||||
{
|
{
|
||||||
if (bufsize >= 0) {
|
if (bufsize >= 0) {
|
||||||
#ifdef HAVE_SETVBUF
|
#ifdef HAVE_SETVBUF
|
||||||
|
@ -188,7 +179,7 @@ PyFile_SetBufSize(f, bufsize)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
err_closed()
|
err_closed(void)
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_ValueError, "I/O operation on closed file");
|
PyErr_SetString(PyExc_ValueError, "I/O operation on closed file");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -197,8 +188,7 @@ err_closed()
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
file_dealloc(f)
|
file_dealloc(PyFileObject *f)
|
||||||
PyFileObject *f;
|
|
||||||
{
|
{
|
||||||
if (f->f_fp != NULL && f->f_close != NULL) {
|
if (f->f_fp != NULL && f->f_close != NULL) {
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
@ -215,8 +205,7 @@ file_dealloc(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_repr(f)
|
file_repr(PyFileObject *f)
|
||||||
PyFileObject *f;
|
|
||||||
{
|
{
|
||||||
char buf[300];
|
char buf[300];
|
||||||
sprintf(buf, "<%s file '%.256s', mode '%.10s' at %p>",
|
sprintf(buf, "<%s file '%.256s', mode '%.10s' at %p>",
|
||||||
|
@ -228,9 +217,7 @@ file_repr(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_close(f, args)
|
file_close(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int sts = 0;
|
int sts = 0;
|
||||||
if (!PyArg_NoArgs(args))
|
if (!PyArg_NoArgs(args))
|
||||||
|
@ -253,9 +240,7 @@ file_close(f, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_seek(f, args)
|
file_seek(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int whence;
|
int whence;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -296,9 +281,7 @@ file_seek(f, args)
|
||||||
|
|
||||||
#ifdef HAVE_FTRUNCATE
|
#ifdef HAVE_FTRUNCATE
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_truncate(f, args)
|
file_truncate(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
off_t newsize;
|
off_t newsize;
|
||||||
|
@ -358,9 +341,7 @@ file_truncate(f, args)
|
||||||
#endif /* HAVE_FTRUNCATE */
|
#endif /* HAVE_FTRUNCATE */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_tell(f, args)
|
file_tell(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
off_t offset;
|
off_t offset;
|
||||||
if (f->f_fp == NULL)
|
if (f->f_fp == NULL)
|
||||||
|
@ -390,9 +371,7 @@ file_tell(f, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_fileno(f, args)
|
file_fileno(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
if (f->f_fp == NULL)
|
if (f->f_fp == NULL)
|
||||||
return err_closed();
|
return err_closed();
|
||||||
|
@ -402,9 +381,7 @@ file_fileno(f, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_flush(f, args)
|
file_flush(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
@ -426,9 +403,7 @@ file_flush(f, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_isatty(f, args)
|
file_isatty(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
long res;
|
long res;
|
||||||
if (f->f_fp == NULL)
|
if (f->f_fp == NULL)
|
||||||
|
@ -455,9 +430,7 @@ file_isatty(f, args)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
new_buffersize(f, currentsize)
|
new_buffersize(PyFileObject *f, size_t currentsize)
|
||||||
PyFileObject *f;
|
|
||||||
size_t currentsize;
|
|
||||||
{
|
{
|
||||||
#ifdef HAVE_FSTAT
|
#ifdef HAVE_FSTAT
|
||||||
long pos, end;
|
long pos, end;
|
||||||
|
@ -495,9 +468,7 @@ new_buffersize(f, currentsize)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_read(f, args)
|
file_read(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
long bytesrequested = -1;
|
long bytesrequested = -1;
|
||||||
size_t bytesread, buffersize, chunksize;
|
size_t bytesread, buffersize, chunksize;
|
||||||
|
@ -544,9 +515,7 @@ file_read(f, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_readinto(f, args)
|
file_readinto(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int ntodo, ndone, nnow;
|
int ntodo, ndone, nnow;
|
||||||
|
@ -583,9 +552,7 @@ file_readinto(f, args)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
get_line(f, n)
|
get_line(PyFileObject *f, int n)
|
||||||
PyFileObject *f;
|
|
||||||
int n;
|
|
||||||
{
|
{
|
||||||
register FILE *fp;
|
register FILE *fp;
|
||||||
register int c;
|
register int c;
|
||||||
|
@ -648,9 +615,7 @@ get_line(f, n)
|
||||||
/* External C interface */
|
/* External C interface */
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyFile_GetLine(f, n)
|
PyFile_GetLine(PyObject *f, int n)
|
||||||
PyObject *f;
|
|
||||||
int n;
|
|
||||||
{
|
{
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -711,9 +676,7 @@ PyFile_GetLine(f, n)
|
||||||
/* Python method */
|
/* Python method */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_readline(f, args)
|
file_readline(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
int n = -1;
|
int n = -1;
|
||||||
|
|
||||||
|
@ -729,9 +692,7 @@ file_readline(f, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_readlines(f, args)
|
file_readlines(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
long sizehint = 0;
|
long sizehint = 0;
|
||||||
PyObject *list;
|
PyObject *list;
|
||||||
|
@ -842,9 +803,7 @@ file_readlines(f, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_write(f, args)
|
file_write(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int n, n2;
|
int n, n2;
|
||||||
|
@ -867,9 +826,7 @@ file_write(f, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_writelines(f, args)
|
file_writelines(PyFileObject *f, PyObject *args)
|
||||||
PyFileObject *f;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
#define CHUNKSIZE 1000
|
#define CHUNKSIZE 1000
|
||||||
PyObject *list, *line;
|
PyObject *list, *line;
|
||||||
|
@ -992,9 +949,7 @@ static struct memberlist file_memberlist[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
file_getattr(f, name)
|
file_getattr(PyFileObject *f, char *name)
|
||||||
PyFileObject *f;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
|
|
||||||
|
@ -1008,10 +963,7 @@ file_getattr(f, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
file_setattr(f, name, v)
|
file_setattr(PyFileObject *f, char *name, PyObject *v)
|
||||||
PyFileObject *f;
|
|
||||||
char *name;
|
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
PyErr_SetString(PyExc_AttributeError,
|
PyErr_SetString(PyExc_AttributeError,
|
||||||
|
@ -1038,9 +990,7 @@ PyTypeObject PyFile_Type = {
|
||||||
/* Interface for the 'soft space' between print items. */
|
/* Interface for the 'soft space' between print items. */
|
||||||
|
|
||||||
int
|
int
|
||||||
PyFile_SoftSpace(f, newflag)
|
PyFile_SoftSpace(PyObject *f, int newflag)
|
||||||
PyObject *f;
|
|
||||||
int newflag;
|
|
||||||
{
|
{
|
||||||
int oldflag = 0;
|
int oldflag = 0;
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
|
@ -1075,10 +1025,7 @@ PyFile_SoftSpace(f, newflag)
|
||||||
/* Interfaces to write objects/strings to file-like objects */
|
/* Interfaces to write objects/strings to file-like objects */
|
||||||
|
|
||||||
int
|
int
|
||||||
PyFile_WriteObject(v, f, flags)
|
PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
|
||||||
PyObject *v;
|
|
||||||
PyObject *f;
|
|
||||||
int flags;
|
|
||||||
{
|
{
|
||||||
PyObject *writer, *value, *args, *result;
|
PyObject *writer, *value, *args, *result;
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
|
@ -1121,13 +1068,11 @@ PyFile_WriteObject(v, f, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyFile_WriteString(s, f)
|
PyFile_WriteString(char *s, PyObject *f)
|
||||||
char *s;
|
|
||||||
PyObject *f;
|
|
||||||
{
|
{
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
/* Should be caused by a pre-existing error */
|
/* Should be caused by a pre-existing error */
|
||||||
if(!PyErr_Occurred())
|
if (!PyErr_Occurred())
|
||||||
PyErr_SetString(PyExc_SystemError,
|
PyErr_SetString(PyExc_SystemError,
|
||||||
"null file for PyFile_WriteString");
|
"null file for PyFile_WriteString");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -94,7 +94,7 @@ static PyFloatBlock *block_list = NULL;
|
||||||
static PyFloatObject *free_list = NULL;
|
static PyFloatObject *free_list = NULL;
|
||||||
|
|
||||||
static PyFloatObject *
|
static PyFloatObject *
|
||||||
fill_free_list()
|
fill_free_list(void)
|
||||||
{
|
{
|
||||||
PyFloatObject *p, *q;
|
PyFloatObject *p, *q;
|
||||||
/* XXX Float blocks escape the object heap. Use PyObject_MALLOC ??? */
|
/* XXX Float blocks escape the object heap. Use PyObject_MALLOC ??? */
|
||||||
|
@ -133,9 +133,7 @@ PyFloat_FromDouble(fval)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyFloat_FromString(v, pend)
|
PyFloat_FromString(PyObject *v, char **pend)
|
||||||
PyObject *v;
|
|
||||||
char **pend;
|
|
||||||
{
|
{
|
||||||
extern double strtod(const char *, char **);
|
extern double strtod(const char *, char **);
|
||||||
const char *s, *last, *end;
|
const char *s, *last, *end;
|
||||||
|
@ -207,16 +205,14 @@ PyFloat_FromString(v, pend)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
float_dealloc(op)
|
float_dealloc(PyFloatObject *op)
|
||||||
PyFloatObject *op;
|
|
||||||
{
|
{
|
||||||
op->ob_type = (struct _typeobject *)free_list;
|
op->ob_type = (struct _typeobject *)free_list;
|
||||||
free_list = op;
|
free_list = op;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
PyFloat_AsDouble(op)
|
PyFloat_AsDouble(PyObject *op)
|
||||||
PyObject *op;
|
|
||||||
{
|
{
|
||||||
PyNumberMethods *nb;
|
PyNumberMethods *nb;
|
||||||
PyFloatObject *fo;
|
PyFloatObject *fo;
|
||||||
|
@ -249,10 +245,7 @@ PyFloat_AsDouble(op)
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
void
|
void
|
||||||
PyFloat_AsStringEx(buf, v, precision)
|
PyFloat_AsStringEx(char *buf, PyFloatObject *v, int precision)
|
||||||
char *buf;
|
|
||||||
PyFloatObject *v;
|
|
||||||
int precision;
|
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
/* Subroutine for float_repr and float_print.
|
/* Subroutine for float_repr and float_print.
|
||||||
|
@ -295,19 +288,15 @@ PyFloat_AsStringEx(buf, v, precision)
|
||||||
#define PREC_STR 12
|
#define PREC_STR 12
|
||||||
|
|
||||||
void
|
void
|
||||||
PyFloat_AsString(buf, v)
|
PyFloat_AsString(char *buf, PyFloatObject *v)
|
||||||
char *buf;
|
|
||||||
PyFloatObject *v;
|
|
||||||
{
|
{
|
||||||
PyFloat_AsStringEx(buf, v, PREC_STR);
|
PyFloat_AsStringEx(buf, v, PREC_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
static int
|
static int
|
||||||
float_print(v, fp, flags)
|
float_print(PyFloatObject *v, FILE *fp, int flags)
|
||||||
PyFloatObject *v;
|
/* flags -- not used but required by interface */
|
||||||
FILE *fp;
|
|
||||||
int flags; /* Not used but required by interface */
|
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
PyFloat_AsStringEx(buf, v, flags&Py_PRINT_RAW ? PREC_STR : PREC_REPR);
|
PyFloat_AsStringEx(buf, v, flags&Py_PRINT_RAW ? PREC_STR : PREC_REPR);
|
||||||
|
@ -316,8 +305,7 @@ float_print(v, fp, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_repr(v)
|
float_repr(PyFloatObject *v)
|
||||||
PyFloatObject *v;
|
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
PyFloat_AsStringEx(buf, v, PREC_REPR);
|
PyFloat_AsStringEx(buf, v, PREC_REPR);
|
||||||
|
@ -325,8 +313,7 @@ float_repr(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_str(v)
|
float_str(PyFloatObject *v)
|
||||||
PyFloatObject *v;
|
|
||||||
{
|
{
|
||||||
char buf[100];
|
char buf[100];
|
||||||
PyFloat_AsStringEx(buf, v, PREC_STR);
|
PyFloat_AsStringEx(buf, v, PREC_STR);
|
||||||
|
@ -334,8 +321,7 @@ float_str(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
float_compare(v, w)
|
float_compare(PyFloatObject *v, PyFloatObject *w)
|
||||||
PyFloatObject *v, *w;
|
|
||||||
{
|
{
|
||||||
double i = v->ob_fval;
|
double i = v->ob_fval;
|
||||||
double j = w->ob_fval;
|
double j = w->ob_fval;
|
||||||
|
@ -344,8 +330,7 @@ float_compare(v, w)
|
||||||
|
|
||||||
|
|
||||||
static long
|
static long
|
||||||
float_hash(v)
|
float_hash(PyFloatObject *v)
|
||||||
PyFloatObject *v;
|
|
||||||
{
|
{
|
||||||
double intpart, fractpart;
|
double intpart, fractpart;
|
||||||
long x;
|
long x;
|
||||||
|
@ -388,9 +373,7 @@ float_hash(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_add(v, w)
|
float_add(PyFloatObject *v, PyFloatObject *w)
|
||||||
PyFloatObject *v;
|
|
||||||
PyFloatObject *w;
|
|
||||||
{
|
{
|
||||||
double result;
|
double result;
|
||||||
PyFPE_START_PROTECT("add", return 0)
|
PyFPE_START_PROTECT("add", return 0)
|
||||||
|
@ -400,9 +383,7 @@ float_add(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_sub(v, w)
|
float_sub(PyFloatObject *v, PyFloatObject *w)
|
||||||
PyFloatObject *v;
|
|
||||||
PyFloatObject *w;
|
|
||||||
{
|
{
|
||||||
double result;
|
double result;
|
||||||
PyFPE_START_PROTECT("subtract", return 0)
|
PyFPE_START_PROTECT("subtract", return 0)
|
||||||
|
@ -412,9 +393,7 @@ float_sub(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_mul(v, w)
|
float_mul(PyFloatObject *v, PyFloatObject *w)
|
||||||
PyFloatObject *v;
|
|
||||||
PyFloatObject *w;
|
|
||||||
{
|
{
|
||||||
double result;
|
double result;
|
||||||
|
|
||||||
|
@ -425,9 +404,7 @@ float_mul(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_div(v, w)
|
float_div(PyFloatObject *v, PyFloatObject *w)
|
||||||
PyFloatObject *v;
|
|
||||||
PyFloatObject *w;
|
|
||||||
{
|
{
|
||||||
double result;
|
double result;
|
||||||
if (w->ob_fval == 0) {
|
if (w->ob_fval == 0) {
|
||||||
|
@ -441,9 +418,7 @@ float_div(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_rem(v, w)
|
float_rem(PyFloatObject *v, PyFloatObject *w)
|
||||||
PyFloatObject *v;
|
|
||||||
PyFloatObject *w;
|
|
||||||
{
|
{
|
||||||
double vx, wx;
|
double vx, wx;
|
||||||
double mod;
|
double mod;
|
||||||
|
@ -465,9 +440,7 @@ float_rem(v, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_divmod(v, w)
|
float_divmod(PyFloatObject *v, PyFloatObject *w)
|
||||||
PyFloatObject *v;
|
|
||||||
PyFloatObject *w;
|
|
||||||
{
|
{
|
||||||
double vx, wx;
|
double vx, wx;
|
||||||
double div, mod, floordiv;
|
double div, mod, floordiv;
|
||||||
|
@ -500,9 +473,7 @@ float_divmod(v, w)
|
||||||
return Py_BuildValue("(dd)", floordiv, mod);
|
return Py_BuildValue("(dd)", floordiv, mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double powu(x, n)
|
static double powu(double x, long n)
|
||||||
double x;
|
|
||||||
long n;
|
|
||||||
{
|
{
|
||||||
double r = 1.;
|
double r = 1.;
|
||||||
double p = x;
|
double p = x;
|
||||||
|
@ -517,10 +488,7 @@ static double powu(x, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_pow(v, w, z)
|
float_pow(PyFloatObject *v, PyObject *w, PyFloatObject *z)
|
||||||
PyFloatObject *v;
|
|
||||||
PyObject *w;
|
|
||||||
PyFloatObject *z;
|
|
||||||
{
|
{
|
||||||
double iv, iw, ix;
|
double iv, iw, ix;
|
||||||
long intw;
|
long intw;
|
||||||
|
@ -591,23 +559,20 @@ float_pow(v, w, z)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_neg(v)
|
float_neg(PyFloatObject *v)
|
||||||
PyFloatObject *v;
|
|
||||||
{
|
{
|
||||||
return PyFloat_FromDouble(-v->ob_fval);
|
return PyFloat_FromDouble(-v->ob_fval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_pos(v)
|
float_pos(PyFloatObject *v)
|
||||||
PyFloatObject *v;
|
|
||||||
{
|
{
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
return (PyObject *)v;
|
return (PyObject *)v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_abs(v)
|
float_abs(PyFloatObject *v)
|
||||||
PyFloatObject *v;
|
|
||||||
{
|
{
|
||||||
if (v->ob_fval < 0)
|
if (v->ob_fval < 0)
|
||||||
return float_neg(v);
|
return float_neg(v);
|
||||||
|
@ -616,16 +581,13 @@ float_abs(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
float_nonzero(v)
|
float_nonzero(PyFloatObject *v)
|
||||||
PyFloatObject *v;
|
|
||||||
{
|
{
|
||||||
return v->ob_fval != 0.0;
|
return v->ob_fval != 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
float_coerce(pv, pw)
|
float_coerce(PyObject **pv, PyObject **pw)
|
||||||
PyObject **pv;
|
|
||||||
PyObject **pw;
|
|
||||||
{
|
{
|
||||||
if (PyInt_Check(*pw)) {
|
if (PyInt_Check(*pw)) {
|
||||||
long x = PyInt_AsLong(*pw);
|
long x = PyInt_AsLong(*pw);
|
||||||
|
@ -642,8 +604,7 @@ float_coerce(pv, pw)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_int(v)
|
float_int(PyObject *v)
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
double x = PyFloat_AsDouble(v);
|
double x = PyFloat_AsDouble(v);
|
||||||
if (x < 0 ? (x = ceil(x)) < (double)LONG_MIN
|
if (x < 0 ? (x = ceil(x)) < (double)LONG_MIN
|
||||||
|
@ -656,16 +617,14 @@ float_int(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_long(v)
|
float_long(PyObject *v)
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
double x = PyFloat_AsDouble(v);
|
double x = PyFloat_AsDouble(v);
|
||||||
return PyLong_FromDouble(x);
|
return PyLong_FromDouble(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
float_float(v)
|
float_float(PyObject *v)
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
return v;
|
return v;
|
||||||
|
@ -719,7 +678,7 @@ PyTypeObject PyFloat_Type = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
PyFloat_Fini()
|
PyFloat_Fini(void)
|
||||||
{
|
{
|
||||||
PyFloatObject *p;
|
PyFloatObject *p;
|
||||||
PyFloatBlock *list, *next;
|
PyFloatBlock *list, *next;
|
||||||
|
|
Loading…
Reference in New Issue