@@ -33,9 +33,6 @@ PyDoc_STRVAR(cStringIO_module_documentation,
3333"\n"
3434"cStringIO.c,v 1.29 1999/06/15 14:10:27 jim Exp\n" );
3535
36- #define UNLESS (E ) if (!(E))
37-
38-
3936/* Declaration for file-like objects that manage data as strings
4037
4138 The IOobject type should be though of as a common base type for
@@ -80,7 +77,7 @@ PyDoc_STRVAR(IO_flush__doc__, "flush(): does nothing.");
8077
8178static int
8279IO__opencheck (IOobject * self ) {
83- UNLESS ( self -> buf ) {
80+ if (! self -> buf ) {
8481 PyErr_SetString (PyExc_ValueError ,
8582 "I/O operation on closed file" );
8683 return 0 ;
@@ -107,7 +104,7 @@ static PyGetSetDef file_getsetlist[] = {
107104static PyObject *
108105IO_flush (IOobject * self , PyObject * unused ) {
109106
110- UNLESS ( IO__opencheck (self )) return NULL ;
107+ if (! IO__opencheck (self )) return NULL ;
111108
112109 Py_INCREF (Py_None );
113110 return Py_None ;
@@ -121,7 +118,7 @@ PyDoc_STRVAR(IO_getval__doc__,
121118
122119static PyObject *
123120IO_cgetval (PyObject * self ) {
124- UNLESS ( IO__opencheck (IOOOBJECT (self ))) return NULL ;
121+ if (! IO__opencheck (IOOOBJECT (self ))) return NULL ;
125122 return PyString_FromStringAndSize (((IOobject * )self )-> buf ,
126123 ((IOobject * )self )-> pos );
127124}
@@ -131,8 +128,8 @@ IO_getval(IOobject *self, PyObject *args) {
131128 PyObject * use_pos = Py_None ;
132129 Py_ssize_t s ;
133130
134- UNLESS ( IO__opencheck (self )) return NULL ;
135- UNLESS ( PyArg_UnpackTuple (args ,"getval" , 0 , 1 ,& use_pos )) return NULL ;
131+ if (! IO__opencheck (self )) return NULL ;
132+ if (! PyArg_UnpackTuple (args ,"getval" , 0 , 1 ,& use_pos )) return NULL ;
136133
137134 if (PyObject_IsTrue (use_pos )) {
138135 s = self -> pos ;
@@ -158,7 +155,7 @@ static int
158155IO_cread (PyObject * self , char * * output , Py_ssize_t n ) {
159156 Py_ssize_t l ;
160157
161- UNLESS ( IO__opencheck (IOOOBJECT (self ))) return -1 ;
158+ if (! IO__opencheck (IOOOBJECT (self ))) return -1 ;
162159 l = ((IOobject * )self )-> string_size - ((IOobject * )self )-> pos ;
163160 if (n < 0 || n > l ) {
164161 n = l ;
@@ -175,7 +172,7 @@ IO_read(IOobject *self, PyObject *args) {
175172 Py_ssize_t n = -1 ;
176173 char * output = NULL ;
177174
178- UNLESS ( PyArg_ParseTuple (args , "|n:read" , & n )) return NULL ;
175+ if (! PyArg_ParseTuple (args , "|n:read" , & n )) return NULL ;
179176
180177 if ( (n = IO_cread ((PyObject * )self ,& output ,n )) < 0 ) return NULL ;
181178
@@ -189,7 +186,7 @@ IO_creadline(PyObject *self, char **output) {
189186 char * n , * s ;
190187 Py_ssize_t l ;
191188
192- UNLESS ( IO__opencheck (IOOOBJECT (self ))) return -1 ;
189+ if (! IO__opencheck (IOOOBJECT (self ))) return -1 ;
193190
194191 for (n = ((IOobject * )self )-> buf + ((IOobject * )self )-> pos ,
195192 s = ((IOobject * )self )-> buf + ((IOobject * )self )-> string_size ;
@@ -209,7 +206,7 @@ IO_readline(IOobject *self, PyObject *args) {
209206 char * output ;
210207
211208 if (args )
212- UNLESS ( PyArg_ParseTuple (args , "|i:readline" , & m )) return NULL ;
209+ if (! PyArg_ParseTuple (args , "|i:readline" , & m )) return NULL ;
213210
214211 if ( (n = IO_creadline ((PyObject * )self ,& output )) < 0 ) return NULL ;
215212 if (m >= 0 && m < n ) {
@@ -229,7 +226,7 @@ IO_readlines(IOobject *self, PyObject *args) {
229226 PyObject * result , * line ;
230227 int hint = 0 , length = 0 ;
231228
232- UNLESS ( PyArg_ParseTuple (args , "|i:readlines" , & hint )) return NULL ;
229+ if (! PyArg_ParseTuple (args , "|i:readlines" , & hint )) return NULL ;
233230
234231 result = PyList_New (0 );
235232 if (!result )
@@ -264,7 +261,7 @@ PyDoc_STRVAR(IO_reset__doc__,
264261static PyObject *
265262IO_reset (IOobject * self , PyObject * unused ) {
266263
267- UNLESS ( IO__opencheck (self )) return NULL ;
264+ if (! IO__opencheck (self )) return NULL ;
268265
269266 self -> pos = 0 ;
270267
@@ -277,7 +274,7 @@ PyDoc_STRVAR(IO_tell__doc__, "tell() -- get the current position.");
277274static PyObject *
278275IO_tell (IOobject * self , PyObject * unused ) {
279276
280- UNLESS ( IO__opencheck (self )) return NULL ;
277+ if (! IO__opencheck (self )) return NULL ;
281278
282279 return PyInt_FromSsize_t (self -> pos );
283280}
@@ -289,8 +286,8 @@ static PyObject *
289286IO_truncate (IOobject * self , PyObject * args ) {
290287 Py_ssize_t pos = -1 ;
291288
292- UNLESS ( IO__opencheck (self )) return NULL ;
293- UNLESS ( PyArg_ParseTuple (args , "|n:truncate" , & pos )) return NULL ;
289+ if (! IO__opencheck (self )) return NULL ;
290+ if (! PyArg_ParseTuple (args , "|n:truncate" , & pos )) return NULL ;
294291 if (pos < 0 ) pos = self -> pos ;
295292
296293 if (self -> string_size > pos ) self -> string_size = pos ;
@@ -329,8 +326,8 @@ O_seek(Oobject *self, PyObject *args) {
329326 Py_ssize_t position ;
330327 int mode = 0 ;
331328
332- UNLESS ( IO__opencheck (IOOOBJECT (self ))) return NULL ;
333- UNLESS ( PyArg_ParseTuple (args , "n|i:seek" , & position , & mode ))
329+ if (! IO__opencheck (IOOOBJECT (self ))) return NULL ;
330+ if (! PyArg_ParseTuple (args , "n|i:seek" , & position , & mode ))
334331 return NULL ;
335332
336333 if (mode == 2 ) {
@@ -343,8 +340,8 @@ O_seek(Oobject *self, PyObject *args) {
343340 if (position > self -> buf_size ) {
344341 self -> buf_size *=2 ;
345342 if (self -> buf_size <= position ) self -> buf_size = position + 1 ;
346- UNLESS ( self -> buf = (char * )
347- realloc ( self -> buf , self -> buf_size ) ) {
343+ self -> buf = (char * ) realloc ( self -> buf , self -> buf_size );
344+ if (! self -> buf ) {
348345 self -> buf_size = self -> pos = 0 ;
349346 return PyErr_NoMemory ();
350347 }
@@ -369,7 +366,7 @@ O_cwrite(PyObject *self, const char *c, Py_ssize_t l) {
369366 Py_ssize_t newl ;
370367 Oobject * oself ;
371368
372- UNLESS ( IO__opencheck (IOOOBJECT (self ))) return -1 ;
369+ if (! IO__opencheck (IOOOBJECT (self ))) return -1 ;
373370 oself = (Oobject * )self ;
374371
375372 newl = oself -> pos + l ;
@@ -379,8 +376,8 @@ O_cwrite(PyObject *self, const char *c, Py_ssize_t l) {
379376 assert (newl + 1 < INT_MAX );
380377 oself -> buf_size = (int )(newl + 1 );
381378 }
382- UNLESS ( oself -> buf =
383- ( char * ) realloc ( oself -> buf , oself -> buf_size ) ) {
379+ oself -> buf = ( char * ) realloc ( oself -> buf , oself -> buf_size );
380+ if (! oself -> buf ) {
384381 PyErr_SetString (PyExc_MemoryError ,"out of memory" );
385382 oself -> buf_size = oself -> pos = 0 ;
386383 return -1 ;
@@ -404,7 +401,7 @@ O_write(Oobject *self, PyObject *args) {
404401 char * c ;
405402 int l ;
406403
407- UNLESS ( PyArg_ParseTuple (args , "t#:write" , & c , & l )) return NULL ;
404+ if (! PyArg_ParseTuple (args , "t#:write" , & c , & l )) return NULL ;
408405
409406 if (O_cwrite ((PyObject * )self ,c ,l ) < 0 ) return NULL ;
410407
@@ -543,7 +540,8 @@ newOobject(int size) {
543540 self -> string_size = 0 ;
544541 self -> softspace = 0 ;
545542
546- UNLESS (self -> buf = (char * )malloc (size )) {
543+ self -> buf = (char * )malloc (size );
544+ if (!self -> buf ) {
547545 PyErr_SetString (PyExc_MemoryError ,"out of memory" );
548546 self -> buf_size = 0 ;
549547 return NULL ;
@@ -573,8 +571,8 @@ I_seek(Iobject *self, PyObject *args) {
573571 Py_ssize_t position ;
574572 int mode = 0 ;
575573
576- UNLESS ( IO__opencheck (IOOOBJECT (self ))) return NULL ;
577- UNLESS ( PyArg_ParseTuple (args , "n|i:seek" , & position , & mode ))
574+ if (! IO__opencheck (IOOOBJECT (self ))) return NULL ;
575+ if (! PyArg_ParseTuple (args , "n|i:seek" , & position , & mode ))
578576 return NULL ;
579577
580578 if (mode == 2 ) position += self -> string_size ;
@@ -662,7 +660,8 @@ newIobject(PyObject *s) {
662660 s -> ob_type -> tp_name );
663661 return NULL ;
664662 }
665- UNLESS (self = PyObject_New (Iobject , & Itype )) return NULL ;
663+ self = PyObject_New (Iobject , & Itype );
664+ if (!self ) return NULL ;
666665 Py_INCREF (s );
667666 self -> buf = buf ;
668667 self -> string_size = size ;
0 commit comments