ANSI-fication of the sources.

This commit is contained in:
Fred Drake 2000-07-09 05:02:18 +00:00
parent 7dfeb42939
commit fd99de6470
2 changed files with 59 additions and 155 deletions

View File

@ -76,8 +76,7 @@ typedef struct {
} PyFileObject;
FILE *
PyFile_AsFile(f)
PyObject *f;
PyFile_AsFile(PyObject *f)
{
if (f == NULL || !PyFile_Check(f))
return NULL;
@ -86,8 +85,7 @@ PyFile_AsFile(f)
}
PyObject *
PyFile_Name(f)
PyObject *f;
PyFile_Name(PyObject *f)
{
if (f == NULL || !PyFile_Check(f))
return NULL;
@ -96,11 +94,7 @@ PyFile_Name(f)
}
PyObject *
PyFile_FromFile(fp, name, mode, close)
FILE *fp;
char *name;
char *mode;
int (*close)(FILE *);
PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *))
{
PyFileObject *f = PyObject_NEW(PyFileObject, &PyFile_Type);
if (f == NULL)
@ -123,8 +117,7 @@ PyFile_FromFile(fp, name, mode, close)
}
PyObject *
PyFile_FromString(name, mode)
char *name, *mode;
PyFile_FromString(char *name, char *mode)
{
extern int fclose(FILE *);
PyFileObject *f;
@ -160,9 +153,7 @@ PyFile_FromString(name, mode)
}
void
PyFile_SetBufSize(f, bufsize)
PyObject *f;
int bufsize;
PyFile_SetBufSize(PyObject *f, int bufsize)
{
if (bufsize >= 0) {
#ifdef HAVE_SETVBUF
@ -188,7 +179,7 @@ PyFile_SetBufSize(f, bufsize)
}
static PyObject *
err_closed()
err_closed(void)
{
PyErr_SetString(PyExc_ValueError, "I/O operation on closed file");
return NULL;
@ -197,8 +188,7 @@ err_closed()
/* Methods */
static void
file_dealloc(f)
PyFileObject *f;
file_dealloc(PyFileObject *f)
{
if (f->f_fp != NULL && f->f_close != NULL) {
Py_BEGIN_ALLOW_THREADS
@ -215,8 +205,7 @@ file_dealloc(f)
}
static PyObject *
file_repr(f)
PyFileObject *f;
file_repr(PyFileObject *f)
{
char buf[300];
sprintf(buf, "<%s file '%.256s', mode '%.10s' at %p>",
@ -228,9 +217,7 @@ file_repr(f)
}
static PyObject *
file_close(f, args)
PyFileObject *f;
PyObject *args;
file_close(PyFileObject *f, PyObject *args)
{
int sts = 0;
if (!PyArg_NoArgs(args))
@ -253,9 +240,7 @@ file_close(f, args)
}
static PyObject *
file_seek(f, args)
PyFileObject *f;
PyObject *args;
file_seek(PyFileObject *f, PyObject *args)
{
int whence;
int ret;
@ -296,9 +281,7 @@ file_seek(f, args)
#ifdef HAVE_FTRUNCATE
static PyObject *
file_truncate(f, args)
PyFileObject *f;
PyObject *args;
file_truncate(PyFileObject *f, PyObject *args)
{
int ret;
off_t newsize;
@ -358,9 +341,7 @@ file_truncate(f, args)
#endif /* HAVE_FTRUNCATE */
static PyObject *
file_tell(f, args)
PyFileObject *f;
PyObject *args;
file_tell(PyFileObject *f, PyObject *args)
{
off_t offset;
if (f->f_fp == NULL)
@ -390,9 +371,7 @@ file_tell(f, args)
}
static PyObject *
file_fileno(f, args)
PyFileObject *f;
PyObject *args;
file_fileno(PyFileObject *f, PyObject *args)
{
if (f->f_fp == NULL)
return err_closed();
@ -402,9 +381,7 @@ file_fileno(f, args)
}
static PyObject *
file_flush(f, args)
PyFileObject *f;
PyObject *args;
file_flush(PyFileObject *f, PyObject *args)
{
int res;
@ -426,9 +403,7 @@ file_flush(f, args)
}
static PyObject *
file_isatty(f, args)
PyFileObject *f;
PyObject *args;
file_isatty(PyFileObject *f, PyObject *args)
{
long res;
if (f->f_fp == NULL)
@ -455,9 +430,7 @@ file_isatty(f, args)
#endif
static size_t
new_buffersize(f, currentsize)
PyFileObject *f;
size_t currentsize;
new_buffersize(PyFileObject *f, size_t currentsize)
{
#ifdef HAVE_FSTAT
long pos, end;
@ -495,9 +468,7 @@ new_buffersize(f, currentsize)
}
static PyObject *
file_read(f, args)
PyFileObject *f;
PyObject *args;
file_read(PyFileObject *f, PyObject *args)
{
long bytesrequested = -1;
size_t bytesread, buffersize, chunksize;
@ -544,9 +515,7 @@ file_read(f, args)
}
static PyObject *
file_readinto(f, args)
PyFileObject *f;
PyObject *args;
file_readinto(PyFileObject *f, PyObject *args)
{
char *ptr;
int ntodo, ndone, nnow;
@ -583,9 +552,7 @@ file_readinto(f, args)
*/
static PyObject *
get_line(f, n)
PyFileObject *f;
int n;
get_line(PyFileObject *f, int n)
{
register FILE *fp;
register int c;
@ -648,9 +615,7 @@ get_line(f, n)
/* External C interface */
PyObject *
PyFile_GetLine(f, n)
PyObject *f;
int n;
PyFile_GetLine(PyObject *f, int n)
{
if (f == NULL) {
PyErr_BadInternalCall();
@ -711,9 +676,7 @@ PyFile_GetLine(f, n)
/* Python method */
static PyObject *
file_readline(f, args)
PyFileObject *f;
PyObject *args;
file_readline(PyFileObject *f, PyObject *args)
{
int n = -1;
@ -729,9 +692,7 @@ file_readline(f, args)
}
static PyObject *
file_readlines(f, args)
PyFileObject *f;
PyObject *args;
file_readlines(PyFileObject *f, PyObject *args)
{
long sizehint = 0;
PyObject *list;
@ -842,9 +803,7 @@ file_readlines(f, args)
}
static PyObject *
file_write(f, args)
PyFileObject *f;
PyObject *args;
file_write(PyFileObject *f, PyObject *args)
{
char *s;
int n, n2;
@ -867,9 +826,7 @@ file_write(f, args)
}
static PyObject *
file_writelines(f, args)
PyFileObject *f;
PyObject *args;
file_writelines(PyFileObject *f, PyObject *args)
{
#define CHUNKSIZE 1000
PyObject *list, *line;
@ -992,9 +949,7 @@ static struct memberlist file_memberlist[] = {
};
static PyObject *
file_getattr(f, name)
PyFileObject *f;
char *name;
file_getattr(PyFileObject *f, char *name)
{
PyObject *res;
@ -1008,10 +963,7 @@ file_getattr(f, name)
}
static int
file_setattr(f, name, v)
PyFileObject *f;
char *name;
PyObject *v;
file_setattr(PyFileObject *f, char *name, PyObject *v)
{
if (v == NULL) {
PyErr_SetString(PyExc_AttributeError,
@ -1038,9 +990,7 @@ PyTypeObject PyFile_Type = {
/* Interface for the 'soft space' between print items. */
int
PyFile_SoftSpace(f, newflag)
PyObject *f;
int newflag;
PyFile_SoftSpace(PyObject *f, int newflag)
{
int oldflag = 0;
if (f == NULL) {
@ -1075,10 +1025,7 @@ PyFile_SoftSpace(f, newflag)
/* Interfaces to write objects/strings to file-like objects */
int
PyFile_WriteObject(v, f, flags)
PyObject *v;
PyObject *f;
int flags;
PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
{
PyObject *writer, *value, *args, *result;
if (f == NULL) {
@ -1121,13 +1068,11 @@ PyFile_WriteObject(v, f, flags)
}
int
PyFile_WriteString(s, f)
char *s;
PyObject *f;
PyFile_WriteString(char *s, PyObject *f)
{
if (f == NULL) {
/* Should be caused by a pre-existing error */
if(!PyErr_Occurred())
if (!PyErr_Occurred())
PyErr_SetString(PyExc_SystemError,
"null file for PyFile_WriteString");
return -1;

View File

@ -94,7 +94,7 @@ static PyFloatBlock *block_list = NULL;
static PyFloatObject *free_list = NULL;
static PyFloatObject *
fill_free_list()
fill_free_list(void)
{
PyFloatObject *p, *q;
/* XXX Float blocks escape the object heap. Use PyObject_MALLOC ??? */
@ -133,9 +133,7 @@ PyFloat_FromDouble(fval)
}
PyObject *
PyFloat_FromString(v, pend)
PyObject *v;
char **pend;
PyFloat_FromString(PyObject *v, char **pend)
{
extern double strtod(const char *, char **);
const char *s, *last, *end;
@ -207,16 +205,14 @@ PyFloat_FromString(v, pend)
}
static void
float_dealloc(op)
PyFloatObject *op;
float_dealloc(PyFloatObject *op)
{
op->ob_type = (struct _typeobject *)free_list;
free_list = op;
}
double
PyFloat_AsDouble(op)
PyObject *op;
PyFloat_AsDouble(PyObject *op)
{
PyNumberMethods *nb;
PyFloatObject *fo;
@ -249,10 +245,7 @@ PyFloat_AsDouble(op)
/* Methods */
void
PyFloat_AsStringEx(buf, v, precision)
char *buf;
PyFloatObject *v;
int precision;
PyFloat_AsStringEx(char *buf, PyFloatObject *v, int precision)
{
register char *cp;
/* Subroutine for float_repr and float_print.
@ -295,19 +288,15 @@ PyFloat_AsStringEx(buf, v, precision)
#define PREC_STR 12
void
PyFloat_AsString(buf, v)
char *buf;
PyFloatObject *v;
PyFloat_AsString(char *buf, PyFloatObject *v)
{
PyFloat_AsStringEx(buf, v, PREC_STR);
}
/* ARGSUSED */
static int
float_print(v, fp, flags)
PyFloatObject *v;
FILE *fp;
int flags; /* Not used but required by interface */
float_print(PyFloatObject *v, FILE *fp, int flags)
/* flags -- not used but required by interface */
{
char buf[100];
PyFloat_AsStringEx(buf, v, flags&Py_PRINT_RAW ? PREC_STR : PREC_REPR);
@ -316,8 +305,7 @@ float_print(v, fp, flags)
}
static PyObject *
float_repr(v)
PyFloatObject *v;
float_repr(PyFloatObject *v)
{
char buf[100];
PyFloat_AsStringEx(buf, v, PREC_REPR);
@ -325,8 +313,7 @@ float_repr(v)
}
static PyObject *
float_str(v)
PyFloatObject *v;
float_str(PyFloatObject *v)
{
char buf[100];
PyFloat_AsStringEx(buf, v, PREC_STR);
@ -334,8 +321,7 @@ float_str(v)
}
static int
float_compare(v, w)
PyFloatObject *v, *w;
float_compare(PyFloatObject *v, PyFloatObject *w)
{
double i = v->ob_fval;
double j = w->ob_fval;
@ -344,8 +330,7 @@ float_compare(v, w)
static long
float_hash(v)
PyFloatObject *v;
float_hash(PyFloatObject *v)
{
double intpart, fractpart;
long x;
@ -388,9 +373,7 @@ float_hash(v)
}
static PyObject *
float_add(v, w)
PyFloatObject *v;
PyFloatObject *w;
float_add(PyFloatObject *v, PyFloatObject *w)
{
double result;
PyFPE_START_PROTECT("add", return 0)
@ -400,9 +383,7 @@ float_add(v, w)
}
static PyObject *
float_sub(v, w)
PyFloatObject *v;
PyFloatObject *w;
float_sub(PyFloatObject *v, PyFloatObject *w)
{
double result;
PyFPE_START_PROTECT("subtract", return 0)
@ -412,9 +393,7 @@ float_sub(v, w)
}
static PyObject *
float_mul(v, w)
PyFloatObject *v;
PyFloatObject *w;
float_mul(PyFloatObject *v, PyFloatObject *w)
{
double result;
@ -425,9 +404,7 @@ float_mul(v, w)
}
static PyObject *
float_div(v, w)
PyFloatObject *v;
PyFloatObject *w;
float_div(PyFloatObject *v, PyFloatObject *w)
{
double result;
if (w->ob_fval == 0) {
@ -441,9 +418,7 @@ float_div(v, w)
}
static PyObject *
float_rem(v, w)
PyFloatObject *v;
PyFloatObject *w;
float_rem(PyFloatObject *v, PyFloatObject *w)
{
double vx, wx;
double mod;
@ -465,9 +440,7 @@ float_rem(v, w)
}
static PyObject *
float_divmod(v, w)
PyFloatObject *v;
PyFloatObject *w;
float_divmod(PyFloatObject *v, PyFloatObject *w)
{
double vx, wx;
double div, mod, floordiv;
@ -500,9 +473,7 @@ float_divmod(v, w)
return Py_BuildValue("(dd)", floordiv, mod);
}
static double powu(x, n)
double x;
long n;
static double powu(double x, long n)
{
double r = 1.;
double p = x;
@ -517,10 +488,7 @@ static double powu(x, n)
}
static PyObject *
float_pow(v, w, z)
PyFloatObject *v;
PyObject *w;
PyFloatObject *z;
float_pow(PyFloatObject *v, PyObject *w, PyFloatObject *z)
{
double iv, iw, ix;
long intw;
@ -591,23 +559,20 @@ float_pow(v, w, z)
}
static PyObject *
float_neg(v)
PyFloatObject *v;
float_neg(PyFloatObject *v)
{
return PyFloat_FromDouble(-v->ob_fval);
}
static PyObject *
float_pos(v)
PyFloatObject *v;
float_pos(PyFloatObject *v)
{
Py_INCREF(v);
return (PyObject *)v;
}
static PyObject *
float_abs(v)
PyFloatObject *v;
float_abs(PyFloatObject *v)
{
if (v->ob_fval < 0)
return float_neg(v);
@ -616,16 +581,13 @@ float_abs(v)
}
static int
float_nonzero(v)
PyFloatObject *v;
float_nonzero(PyFloatObject *v)
{
return v->ob_fval != 0.0;
}
static int
float_coerce(pv, pw)
PyObject **pv;
PyObject **pw;
float_coerce(PyObject **pv, PyObject **pw)
{
if (PyInt_Check(*pw)) {
long x = PyInt_AsLong(*pw);
@ -642,8 +604,7 @@ float_coerce(pv, pw)
}
static PyObject *
float_int(v)
PyObject *v;
float_int(PyObject *v)
{
double x = PyFloat_AsDouble(v);
if (x < 0 ? (x = ceil(x)) < (double)LONG_MIN
@ -656,16 +617,14 @@ float_int(v)
}
static PyObject *
float_long(v)
PyObject *v;
float_long(PyObject *v)
{
double x = PyFloat_AsDouble(v);
return PyLong_FromDouble(x);
}
static PyObject *
float_float(v)
PyObject *v;
float_float(PyObject *v)
{
Py_INCREF(v);
return v;
@ -719,7 +678,7 @@ PyTypeObject PyFloat_Type = {
};
void
PyFloat_Fini()
PyFloat_Fini(void)
{
PyFloatObject *p;
PyFloatBlock *list, *next;