Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 926518b

Browse files
committed
Changes to make the file acceptable to K&R C compilers (HPUX, SunOS 4.x).
1 parent bf05d4c commit 926518b

1 file changed

Lines changed: 38 additions & 25 deletions

File tree

Objects/complexobject.c

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ static Py_complex c_powu(x, n)
140140
Py_complex x;
141141
long n;
142142
{
143-
Py_complex r = c_1;
144-
Py_complex p = x;
143+
Py_complex r, p;
145144
long mask = 1;
145+
r = c_1;
146+
p = x;
146147
while (mask > 0 && n >= mask) {
147148
if (n & mask)
148149
r = c_prod(r,p);
@@ -171,9 +172,11 @@ static Py_complex c_powi(x, n)
171172
}
172173

173174
PyObject *
174-
PyComplex_FromCComplex(Py_complex cval)
175+
PyComplex_FromCComplex(cval)
176+
Py_complex cval;
175177
{
176-
register complexobject *op = (complexobject *) malloc(sizeof(complexobject));
178+
register complexobject *op =
179+
(complexobject *) malloc(sizeof(complexobject));
177180
if (op == NULL)
178181
return err_nomem();
179182
op->ob_type = &Complextype;
@@ -183,33 +186,41 @@ PyComplex_FromCComplex(Py_complex cval)
183186
}
184187

185188
PyObject *
186-
PyComplex_FromDoubles(double real, double imag) {
187-
Py_complex c;
188-
c.real = real;
189-
c.imag = imag;
190-
return PyComplex_FromCComplex(c);
189+
PyComplex_FromDoubles(real, imag)
190+
double real, imag;
191+
{
192+
Py_complex c;
193+
c.real = real;
194+
c.imag = imag;
195+
return PyComplex_FromCComplex(c);
191196
}
192197

193198
double
194-
PyComplex_RealAsDouble(PyObject *op) {
195-
if (PyComplex_Check(op)) {
196-
return ((PyComplexObject *)op)->cval.real;
197-
} else {
198-
return PyFloat_AsDouble(op);
199-
}
199+
PyComplex_RealAsDouble(op)
200+
PyObject *op;
201+
{
202+
if (PyComplex_Check(op)) {
203+
return ((PyComplexObject *)op)->cval.real;
204+
} else {
205+
return PyFloat_AsDouble(op);
206+
}
200207
}
201208

202209
double
203-
PyComplex_ImagAsDouble(PyObject *op) {
204-
if (PyComplex_Check(op)) {
205-
return ((PyComplexObject *)op)->cval.imag;
206-
} else {
207-
return 0.0;
208-
}
210+
PyComplex_ImagAsDouble(op)
211+
PyObject *op;
212+
{
213+
if (PyComplex_Check(op)) {
214+
return ((PyComplexObject *)op)->cval.imag;
215+
} else {
216+
return 0.0;
217+
}
209218
}
210219

211220
Py_complex
212-
PyComplex_AsCComplex(PyObject *op) {
221+
PyComplex_AsCComplex(op)
222+
PyObject *op;
223+
{
213224
Py_complex cv;
214225
if (PyComplex_Check(op)) {
215226
return ((PyComplexObject *)op)->cval;
@@ -266,8 +277,9 @@ complex_compare(v, w)
266277
{
267278
/* Note: "greater" and "smaller" have no meaning for complex numbers,
268279
but Python requires that they be defined nevertheless. */
269-
Py_complex i = v->cval;
270-
Py_complex j = w->cval;
280+
Py_complex i, j;
281+
i = v->cval;
282+
j = w->cval;
271283
if (i.real == j.real && i.imag == j.imag)
272284
return 0;
273285
else if (i.real != j.real)
@@ -497,7 +509,8 @@ static object *
497509
complex_conjugate(self)
498510
object *self;
499511
{
500-
Py_complex c = ((complexobject *)self)->cval;
512+
Py_complex c;
513+
c = ((complexobject *)self)->cval;
501514
c.imag = -c.imag;
502515
return newcomplexobject(c);
503516
}

0 commit comments

Comments
 (0)