diff options
author | Fred Drake <fdrake@acm.org> | 2000-07-09 04:36:04 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-07-09 04:36:04 (GMT) |
commit | 4288c80599642880dd5710ccd2ce5d2c80696a81 (patch) | |
tree | 7cf4c92e615545df260541f325884401941ac454 /Objects | |
parent | 4201b9e42038c24a5d5f0ae856eba1c5afab90c3 (diff) | |
download | cpython-4288c80599642880dd5710ccd2ce5d2c80696a81.zip cpython-4288c80599642880dd5710ccd2ce5d2c80696a81.tar.gz cpython-4288c80599642880dd5710ccd2ce5d2c80696a81.tar.bz2 |
ANSI-fication of the sources.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/complexobject.c | 146 |
1 files changed, 48 insertions, 98 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 7ef8a51..eaccfab 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -28,8 +28,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. static Py_complex c_1 = {1., 0.}; -Py_complex c_sum(a,b) - Py_complex a,b; +Py_complex c_sum(Py_complex a, Py_complex b) { Py_complex r; r.real = a.real + b.real; @@ -37,8 +36,7 @@ Py_complex c_sum(a,b) return r; } -Py_complex c_diff(a,b) - Py_complex a,b; +Py_complex c_diff(Py_complex a, Py_complex b) { Py_complex r; r.real = a.real - b.real; @@ -46,8 +44,7 @@ Py_complex c_diff(a,b) return r; } -Py_complex c_neg(a) - Py_complex a; +Py_complex c_neg(Py_complex a) { Py_complex r; r.real = -a.real; @@ -55,8 +52,7 @@ Py_complex c_neg(a) return r; } -Py_complex c_prod(a,b) - Py_complex a,b; +Py_complex c_prod(Py_complex a, Py_complex b) { Py_complex r; r.real = a.real*b.real - a.imag*b.imag; @@ -64,8 +60,7 @@ Py_complex c_prod(a,b) return r; } -Py_complex c_quot(a,b) - Py_complex a,b; +Py_complex c_quot(Py_complex a, Py_complex b) { Py_complex r; double d = b.real*b.real + b.imag*b.imag; @@ -76,8 +71,7 @@ Py_complex c_quot(a,b) return r; } -Py_complex c_pow(a,b) - Py_complex a,b; +Py_complex c_pow(Py_complex a, Py_complex b) { Py_complex r; double vabs,len,at,phase; @@ -106,9 +100,7 @@ Py_complex c_pow(a,b) return r; } -static Py_complex c_powu(x, n) - Py_complex x; - long n; +static Py_complex c_powu(Py_complex x, long n) { Py_complex r, p; long mask = 1; @@ -123,9 +115,7 @@ static Py_complex c_powu(x, n) return r; } -static Py_complex c_powi(x, n) - Py_complex x; - long n; +static Py_complex c_powi(Py_complex x, long n) { Py_complex cn; @@ -142,8 +132,7 @@ static Py_complex c_powi(x, n) } PyObject * -PyComplex_FromCComplex(cval) - Py_complex cval; +PyComplex_FromCComplex(Py_complex cval) { register PyComplexObject *op; @@ -157,8 +146,7 @@ PyComplex_FromCComplex(cval) } PyObject * -PyComplex_FromDoubles(real, imag) - double real, imag; +PyComplex_FromDoubles(double real, double imag) { Py_complex c; c.real = real; @@ -167,35 +155,35 @@ PyComplex_FromDoubles(real, imag) } double -PyComplex_RealAsDouble(op) - PyObject *op; +PyComplex_RealAsDouble(PyObject *op) { if (PyComplex_Check(op)) { return ((PyComplexObject *)op)->cval.real; - } else { + } + else { return PyFloat_AsDouble(op); } } double -PyComplex_ImagAsDouble(op) - PyObject *op; +PyComplex_ImagAsDouble(PyObject *op) { if (PyComplex_Check(op)) { return ((PyComplexObject *)op)->cval.imag; - } else { + } + else { return 0.0; } } Py_complex -PyComplex_AsCComplex(op) - PyObject *op; +PyComplex_AsCComplex(PyObject *op) { Py_complex cv; if (PyComplex_Check(op)) { return ((PyComplexObject *)op)->cval; - } else { + } + else { cv.real = PyFloat_AsDouble(op); cv.imag = 0.; return cv; @@ -203,17 +191,14 @@ PyComplex_AsCComplex(op) } static void -complex_dealloc(op) - PyObject *op; +complex_dealloc(PyObject *op) { PyObject_DEL(op); } static void -complex_buf_repr(buf, v) - char *buf; - PyComplexObject *v; +complex_buf_repr(char *buf, PyComplexObject *v) { if (v->cval.real == 0.) sprintf(buf, "%.12gj", v->cval.imag); @@ -222,10 +207,8 @@ complex_buf_repr(buf, v) } static int -complex_print(v, fp, flags) - PyComplexObject *v; - FILE *fp; - int flags; /* Not used but required by interface */ +complex_print(PyComplexObject *v, FILE *fp, int flags) + /* flags -- not used but required by interface */ { char buf[100]; complex_buf_repr(buf, v); @@ -234,8 +217,7 @@ complex_print(v, fp, flags) } static PyObject * -complex_repr(v) - PyComplexObject *v; +complex_repr(PyComplexObject *v) { char buf[100]; complex_buf_repr(buf, v); @@ -243,25 +225,23 @@ complex_repr(v) } static int -complex_compare(v, w) - PyComplexObject *v, *w; +complex_compare(PyComplexObject *v, PyComplexObject *w) { -/* Note: "greater" and "smaller" have no meaning for complex numbers, - but Python requires that they be defined nevertheless. */ + /* Note: "greater" and "smaller" have no meaning for complex numbers, + but Python requires that they be defined nevertheless. */ Py_complex i, j; i = v->cval; j = w->cval; if (i.real == j.real && i.imag == j.imag) - return 0; + return 0; else if (i.real != j.real) - return (i.real < j.real) ? -1 : 1; + return (i.real < j.real) ? -1 : 1; else - return (i.imag < j.imag) ? -1 : 1; + return (i.imag < j.imag) ? -1 : 1; } static long -complex_hash(v) - PyComplexObject *v; +complex_hash(PyComplexObject *v) { double intpart, fractpart; long x; @@ -312,9 +292,7 @@ complex_hash(v) } static PyObject * -complex_add(v, w) - PyComplexObject *v; - PyComplexObject *w; +complex_add(PyComplexObject *v, PyComplexObject *w) { Py_complex result; PyFPE_START_PROTECT("complex_add", return 0) @@ -324,9 +302,7 @@ complex_add(v, w) } static PyObject * -complex_sub(v, w) - PyComplexObject *v; - PyComplexObject *w; +complex_sub(PyComplexObject *v, PyComplexObject *w) { Py_complex result; PyFPE_START_PROTECT("complex_sub", return 0) @@ -336,9 +312,7 @@ complex_sub(v, w) } static PyObject * -complex_mul(v, w) - PyComplexObject *v; - PyComplexObject *w; +complex_mul(PyComplexObject *v, PyComplexObject *w) { Py_complex result; PyFPE_START_PROTECT("complex_mul", return 0) @@ -348,9 +322,7 @@ complex_mul(v, w) } static PyObject * -complex_div(v, w) - PyComplexObject *v; - PyComplexObject *w; +complex_div(PyComplexObject *v, PyComplexObject *w) { Py_complex quot; PyFPE_START_PROTECT("complex_div", return 0) @@ -365,9 +337,7 @@ complex_div(v, w) } static PyObject * -complex_remainder(v, w) - PyComplexObject *v; - PyComplexObject *w; +complex_remainder(PyComplexObject *v, PyComplexObject *w) { Py_complex div, mod; errno = 0; @@ -385,9 +355,7 @@ complex_remainder(v, w) static PyObject * -complex_divmod(v, w) - PyComplexObject *v; - PyComplexObject *w; +complex_divmod(PyComplexObject *v, PyComplexObject *w) { Py_complex div, mod; PyObject *d, *m, *z; @@ -409,10 +377,7 @@ complex_divmod(v, w) } static PyObject * -complex_pow(v, w, z) - PyComplexObject *v; - PyObject *w; - PyComplexObject *z; +complex_pow(PyComplexObject *v, PyObject *w, PyComplexObject *z) { Py_complex p; Py_complex exponent; @@ -422,7 +387,6 @@ complex_pow(v, w, z) PyErr_SetString(PyExc_ValueError, "complex modulo"); return NULL; } - PyFPE_START_PROTECT("complex_pow", return 0) errno = 0; exponent = ((PyComplexObject*)w)->cval; @@ -438,13 +402,11 @@ complex_pow(v, w, z) "0.0 to a negative or complex power"); return NULL; } - return PyComplex_FromCComplex(p); } static PyObject * -complex_neg(v) - PyComplexObject *v; +complex_neg(PyComplexObject *v) { Py_complex neg; neg.real = -v->cval.real; @@ -453,16 +415,14 @@ complex_neg(v) } static PyObject * -complex_pos(v) - PyComplexObject *v; +complex_pos(PyComplexObject *v) { Py_INCREF(v); return (PyObject *)v; } static PyObject * -complex_abs(v) - PyComplexObject *v; +complex_abs(PyComplexObject *v) { double result; PyFPE_START_PROTECT("complex_abs", return 0) @@ -472,16 +432,13 @@ complex_abs(v) } static int -complex_nonzero(v) - PyComplexObject *v; +complex_nonzero(PyComplexObject *v) { return v->cval.real != 0.0 || v->cval.imag != 0.0; } static int -complex_coerce(pv, pw) - PyObject **pv; - PyObject **pw; +complex_coerce(PyObject **pv, PyObject **pw) { Py_complex cval; cval.imag = 0.; @@ -507,8 +464,7 @@ complex_coerce(pv, pw) } static PyObject * -complex_int(v) - PyObject *v; +complex_int(PyObject *v) { PyErr_SetString(PyExc_TypeError, "can't convert complex to int; use e.g. int(abs(z))"); @@ -516,8 +472,7 @@ complex_int(v) } static PyObject * -complex_long(v) - PyObject *v; +complex_long(PyObject *v) { PyErr_SetString(PyExc_TypeError, "can't convert complex to long; use e.g. long(abs(z))"); @@ -525,8 +480,7 @@ complex_long(v) } static PyObject * -complex_float(v) - PyObject *v; +complex_float(PyObject *v) { PyErr_SetString(PyExc_TypeError, "can't convert complex to float; use e.g. abs(z)"); @@ -534,9 +488,7 @@ complex_float(v) } static PyObject * -complex_conjugate(self, args) - PyObject *self; - PyObject *args; +complex_conjugate(PyObject *self, PyObject *args) { Py_complex c; if (!PyArg_ParseTuple(args, ":conjugate")) @@ -553,9 +505,7 @@ static PyMethodDef complex_methods[] = { static PyObject * -complex_getattr(self, name) - PyComplexObject *self; - char *name; +complex_getattr(PyComplexObject *self, char *name) { if (strcmp(name, "real") == 0) return (PyObject *)PyFloat_FromDouble(self->cval.real); |