@@ -20,7 +20,8 @@ typedef struct {
2020 NULL on error.
2121*/
2222static PyObject *
23- validate_step (PyObject * step ) {
23+ validate_step (PyObject * step )
24+ {
2425 /* No step specified, use a step of 1. */
2526 if (!step )
2627 return PyLong_FromLong (1 );
@@ -48,7 +49,8 @@ validate_step(PyObject *step) {
4849 range(0, 5, -1)
4950*/
5051static PyObject *
51- range_new (PyTypeObject * type , PyObject * args , PyObject * kw ) {
52+ range_new (PyTypeObject * type , PyObject * args , PyObject * kw )
53+ {
5254 rangeobject * obj = NULL ;
5355 PyObject * start = NULL , * stop = NULL , * step = NULL ;
5456
@@ -116,7 +118,8 @@ PyDoc_STRVAR(range_doc,
116118Returns an iterator that generates the numbers in the range on demand." );
117119
118120static void
119- range_dealloc (rangeobject * r ) {
121+ range_dealloc (rangeobject * r )
122+ {
120123 Py_DECREF (r -> start );
121124 Py_DECREF (r -> stop );
122125 Py_DECREF (r -> step );
@@ -128,7 +131,8 @@ range_dealloc(rangeobject *r) {
128131 * PyLong_Check(). Return NULL when there is an error.
129132 */
130133static PyObject *
131- range_length_obj (rangeobject * r ) {
134+ range_length_obj (rangeobject * r )
135+ {
132136 /* -------------------------------------------------------------
133137 Algorithm is equal to that of get_len_of_range(), but it operates
134138 on PyObjects (which are assumed to be PyLong objects).
@@ -200,7 +204,8 @@ range_length_obj(rangeobject *r) {
200204}
201205
202206static Py_ssize_t
203- range_length (rangeobject * r ) {
207+ range_length (rangeobject * r )
208+ {
204209 PyObject * len = range_length_obj (r );
205210 Py_ssize_t result = -1 ;
206211 if (len ) {
@@ -213,7 +218,8 @@ range_length(rangeobject *r) {
213218/* range(...)[x] is necessary for: seq[:] = range(...) */
214219
215220static PyObject *
216- range_item (rangeobject * r , Py_ssize_t i ) {
221+ range_item (rangeobject * r , Py_ssize_t i )
222+ {
217223 Py_ssize_t len = range_length (r );
218224 PyObject * rem , * incr , * result ;
219225
@@ -240,7 +246,8 @@ range_item(rangeobject *r, Py_ssize_t i) {
240246}
241247
242248static PyObject *
243- range_repr (rangeobject * r ) {
249+ range_repr (rangeobject * r )
250+ {
244251 Py_ssize_t istep ;
245252
246253 /* Check for special case values for printing. We don't always
@@ -260,14 +267,16 @@ range_repr(rangeobject *r) {
260267
261268/* Pickling support */
262269static PyObject *
263- range_reduce (rangeobject * r , PyObject * args ) {
270+ range_reduce (rangeobject * r , PyObject * args )
271+ {
264272 return Py_BuildValue ("(O(OOO))" , Py_TYPE (r ),
265273 r -> start , r -> stop , r -> step );
266274}
267275
268276/* Assumes (PyLong_CheckExact(ob) || PyBool_Check(ob)) */
269277static int
270- range_contains_long (rangeobject * r , PyObject * ob ) {
278+ range_contains_long (rangeobject * r , PyObject * ob )
279+ {
271280 int cmp1 , cmp2 , cmp3 ;
272281 PyObject * tmp1 = NULL ;
273282 PyObject * tmp2 = NULL ;
@@ -316,7 +325,8 @@ range_contains_long(rangeobject *r, PyObject *ob) {
316325}
317326
318327static int
319- range_contains (rangeobject * r , PyObject * ob ) {
328+ range_contains (rangeobject * r , PyObject * ob )
329+ {
320330 if (PyLong_CheckExact (ob ) || PyBool_Check (ob ))
321331 return range_contains_long (r , ob );
322332
@@ -325,7 +335,8 @@ range_contains(rangeobject *r, PyObject *ob) {
325335}
326336
327337static PyObject *
328- range_count (rangeobject * r , PyObject * ob ) {
338+ range_count (rangeobject * r , PyObject * ob )
339+ {
329340 if (PyLong_CheckExact (ob ) || PyBool_Check (ob )) {
330341 int result = range_contains_long (r , ob );
331342 if (result == -1 )
@@ -344,7 +355,8 @@ range_count(rangeobject *r, PyObject *ob) {
344355}
345356
346357static PyObject *
347- range_index (rangeobject * r , PyObject * ob ) {
358+ range_index (rangeobject * r , PyObject * ob )
359+ {
348360 int contains ;
349361
350362 if (!PyLong_CheckExact (ob ) && !PyBool_Check (ob )) {
@@ -463,7 +475,8 @@ typedef struct {
463475} rangeiterobject ;
464476
465477static PyObject *
466- rangeiter_next (rangeiterobject * r ) {
478+ rangeiter_next (rangeiterobject * r )
479+ {
467480 if (r -> index < r -> len )
468481 /* cast to unsigned to avoid possible signed overflow
469482 in intermediate calculations. */
@@ -473,7 +486,8 @@ rangeiter_next(rangeiterobject *r) {
473486}
474487
475488static PyObject *
476- rangeiter_len (rangeiterobject * r ) {
489+ rangeiter_len (rangeiterobject * r )
490+ {
477491 return PyLong_FromLong (r -> len - r -> index );
478492}
479493
@@ -486,7 +500,8 @@ typedef struct {
486500} longrangeiterobject ;
487501
488502static PyObject *
489- longrangeiter_len (longrangeiterobject * r , PyObject * no_args ) {
503+ longrangeiter_len (longrangeiterobject * r , PyObject * no_args )
504+ {
490505 return PyNumber_Subtract (r -> len , r -> index );
491506}
492507
@@ -547,7 +562,8 @@ PyTypeObject PyRangeIter_Type = {
547562 * required. The result always fits in an unsigned long.
548563 */
549564static unsigned long
550- get_len_of_range (long lo , long hi , long step ) {
565+ get_len_of_range (long lo , long hi , long step )
566+ {
551567 /* -------------------------------------------------------------
552568 If step > 0 and lo >= hi, or step < 0 and lo <= hi, the range is empty.
553569 Else for step > 0, if n values are in the range, the last one is
@@ -574,7 +590,8 @@ get_len_of_range(long lo, long hi, long step) {
574590 is not representable as a C long, OverflowError is raised. */
575591
576592static PyObject *
577- int_range_iter (long start , long stop , long step ) {
593+ int_range_iter (long start , long stop , long step )
594+ {
578595 rangeiterobject * it = PyObject_New (rangeiterobject , & PyRangeIter_Type );
579596 unsigned long ulen ;
580597 if (it == NULL )
@@ -594,7 +611,8 @@ int_range_iter(long start, long stop, long step) {
594611}
595612
596613static PyObject *
597- rangeiter_new (PyTypeObject * type , PyObject * args , PyObject * kw ) {
614+ rangeiter_new (PyTypeObject * type , PyObject * args , PyObject * kw )
615+ {
598616 long start , stop , step ;
599617
600618 if (!_PyArg_NoKeywords ("rangeiter()" , kw ))
@@ -614,7 +632,8 @@ static PyMethodDef longrangeiter_methods[] = {
614632};
615633
616634static void
617- longrangeiter_dealloc (longrangeiterobject * r ) {
635+ longrangeiter_dealloc (longrangeiterobject * r )
636+ {
618637 Py_XDECREF (r -> index );
619638 Py_XDECREF (r -> start );
620639 Py_XDECREF (r -> step );
@@ -623,7 +642,8 @@ longrangeiter_dealloc(longrangeiterobject *r) {
623642}
624643
625644static PyObject *
626- longrangeiter_next (longrangeiterobject * r ) {
645+ longrangeiter_next (longrangeiterobject * r )
646+ {
627647 PyObject * one , * product , * new_index , * result ;
628648 if (PyObject_RichCompareBool (r -> index , r -> len , Py_LT ) != 1 )
629649 return NULL ;
@@ -690,7 +710,8 @@ PyTypeObject PyLongRangeIter_Type = {
690710};
691711
692712static PyObject *
693- range_iter (PyObject * seq ) {
713+ range_iter (PyObject * seq )
714+ {
694715 rangeobject * r = (rangeobject * )seq ;
695716 longrangeiterobject * it ;
696717 long lstart , lstop , lstep ;
@@ -750,7 +771,8 @@ range_iter(PyObject *seq) {
750771}
751772
752773static PyObject *
753- range_reverse (PyObject * seq ) {
774+ range_reverse (PyObject * seq )
775+ {
754776 rangeobject * range = (rangeobject * ) seq ;
755777 longrangeiterobject * it ;
756778 PyObject * one , * sum , * diff , * len = NULL , * product ;
0 commit comments