summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-03-01 23:10:49 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-03-01 23:10:49 (GMT)
commit5df2e614e651d91bd433d6de5cd90b304aead70c (patch)
tree2676df82d41a5892628333a6b395f4573f2cfe26
parent7087f78dbe4f9c69ae040c142c8a04fedf010047 (diff)
downloadcpython-5df2e614e651d91bd433d6de5cd90b304aead70c.zip
cpython-5df2e614e651d91bd433d6de5cd90b304aead70c.tar.gz
cpython-5df2e614e651d91bd433d6de5cd90b304aead70c.tar.bz2
Remove UNLESS.
-rw-r--r--Modules/cStringIO.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c
index 385999f..14e35f3 100644
--- a/Modules/cStringIO.c
+++ b/Modules/cStringIO.c
@@ -33,9 +33,6 @@ PyDoc_STRVAR(cStringIO_module_documentation,
"\n"
"cStringIO.c,v 1.29 1999/06/15 14:10:27 jim Exp\n");
-#define UNLESS(E) if (!(E))
-
-
/* Declaration for file-like objects that manage data as strings
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.");
static int
IO__opencheck(IOobject *self) {
- UNLESS (self->buf) {
+ if (!self->buf) {
PyErr_SetString(PyExc_ValueError,
"I/O operation on closed file");
return 0;
@@ -107,7 +104,7 @@ static PyGetSetDef file_getsetlist[] = {
static PyObject *
IO_flush(IOobject *self, PyObject *unused) {
- UNLESS (IO__opencheck(self)) return NULL;
+ if (!IO__opencheck(self)) return NULL;
Py_INCREF(Py_None);
return Py_None;
@@ -121,7 +118,7 @@ PyDoc_STRVAR(IO_getval__doc__,
static PyObject *
IO_cgetval(PyObject *self) {
- UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL;
+ if (!IO__opencheck(IOOOBJECT(self))) return NULL;
return PyString_FromStringAndSize(((IOobject*)self)->buf,
((IOobject*)self)->pos);
}
@@ -131,8 +128,8 @@ IO_getval(IOobject *self, PyObject *args) {
PyObject *use_pos=Py_None;
Py_ssize_t s;
- UNLESS (IO__opencheck(self)) return NULL;
- UNLESS (PyArg_UnpackTuple(args,"getval", 0, 1,&use_pos)) return NULL;
+ if (!IO__opencheck(self)) return NULL;
+ if (!PyArg_UnpackTuple(args,"getval", 0, 1,&use_pos)) return NULL;
if (PyObject_IsTrue(use_pos)) {
s=self->pos;
@@ -158,7 +155,7 @@ static int
IO_cread(PyObject *self, char **output, Py_ssize_t n) {
Py_ssize_t l;
- UNLESS (IO__opencheck(IOOOBJECT(self))) return -1;
+ if (!IO__opencheck(IOOOBJECT(self))) return -1;
l = ((IOobject*)self)->string_size - ((IOobject*)self)->pos;
if (n < 0 || n > l) {
n = l;
@@ -175,7 +172,7 @@ IO_read(IOobject *self, PyObject *args) {
Py_ssize_t n = -1;
char *output = NULL;
- UNLESS (PyArg_ParseTuple(args, "|n:read", &n)) return NULL;
+ if (!PyArg_ParseTuple(args, "|n:read", &n)) return NULL;
if ( (n=IO_cread((PyObject*)self,&output,n)) < 0) return NULL;
@@ -189,7 +186,7 @@ IO_creadline(PyObject *self, char **output) {
char *n, *s;
Py_ssize_t l;
- UNLESS (IO__opencheck(IOOOBJECT(self))) return -1;
+ if (!IO__opencheck(IOOOBJECT(self))) return -1;
for (n = ((IOobject*)self)->buf + ((IOobject*)self)->pos,
s = ((IOobject*)self)->buf + ((IOobject*)self)->string_size;
@@ -209,7 +206,7 @@ IO_readline(IOobject *self, PyObject *args) {
char *output;
if (args)
- UNLESS (PyArg_ParseTuple(args, "|i:readline", &m)) return NULL;
+ if (!PyArg_ParseTuple(args, "|i:readline", &m)) return NULL;
if( (n=IO_creadline((PyObject*)self,&output)) < 0) return NULL;
if (m >= 0 && m < n) {
@@ -229,7 +226,7 @@ IO_readlines(IOobject *self, PyObject *args) {
PyObject *result, *line;
int hint = 0, length = 0;
- UNLESS (PyArg_ParseTuple(args, "|i:readlines", &hint)) return NULL;
+ if (!PyArg_ParseTuple(args, "|i:readlines", &hint)) return NULL;
result = PyList_New(0);
if (!result)
@@ -264,7 +261,7 @@ PyDoc_STRVAR(IO_reset__doc__,
static PyObject *
IO_reset(IOobject *self, PyObject *unused) {
- UNLESS (IO__opencheck(self)) return NULL;
+ if (!IO__opencheck(self)) return NULL;
self->pos = 0;
@@ -277,7 +274,7 @@ PyDoc_STRVAR(IO_tell__doc__, "tell() -- get the current position.");
static PyObject *
IO_tell(IOobject *self, PyObject *unused) {
- UNLESS (IO__opencheck(self)) return NULL;
+ if (!IO__opencheck(self)) return NULL;
return PyInt_FromSsize_t(self->pos);
}
@@ -289,8 +286,8 @@ static PyObject *
IO_truncate(IOobject *self, PyObject *args) {
Py_ssize_t pos = -1;
- UNLESS (IO__opencheck(self)) return NULL;
- UNLESS (PyArg_ParseTuple(args, "|n:truncate", &pos)) return NULL;
+ if (!IO__opencheck(self)) return NULL;
+ if (!PyArg_ParseTuple(args, "|n:truncate", &pos)) return NULL;
if (pos < 0) pos = self->pos;
if (self->string_size > pos) self->string_size = pos;
@@ -329,8 +326,8 @@ O_seek(Oobject *self, PyObject *args) {
Py_ssize_t position;
int mode = 0;
- UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL;
- UNLESS (PyArg_ParseTuple(args, "n|i:seek", &position, &mode))
+ if (!IO__opencheck(IOOOBJECT(self))) return NULL;
+ if (!PyArg_ParseTuple(args, "n|i:seek", &position, &mode))
return NULL;
if (mode == 2) {
@@ -343,8 +340,8 @@ O_seek(Oobject *self, PyObject *args) {
if (position > self->buf_size) {
self->buf_size*=2;
if (self->buf_size <= position) self->buf_size=position+1;
- UNLESS (self->buf = (char*)
- realloc(self->buf,self->buf_size)) {
+ self->buf = (char*) realloc(self->buf,self->buf_size);
+ if (!self->buf) {
self->buf_size=self->pos=0;
return PyErr_NoMemory();
}
@@ -369,7 +366,7 @@ O_cwrite(PyObject *self, const char *c, Py_ssize_t l) {
Py_ssize_t newl;
Oobject *oself;
- UNLESS (IO__opencheck(IOOOBJECT(self))) return -1;
+ if (!IO__opencheck(IOOOBJECT(self))) return -1;
oself = (Oobject *)self;
newl = oself->pos+l;
@@ -379,8 +376,8 @@ O_cwrite(PyObject *self, const char *c, Py_ssize_t l) {
assert(newl + 1 < INT_MAX);
oself->buf_size = (int)(newl+1);
}
- UNLESS (oself->buf =
- (char*)realloc(oself->buf, oself->buf_size)) {
+ oself->buf = (char*)realloc(oself->buf, oself->buf_size);
+ if (!oself->buf) {
PyErr_SetString(PyExc_MemoryError,"out of memory");
oself->buf_size = oself->pos = 0;
return -1;
@@ -404,7 +401,7 @@ O_write(Oobject *self, PyObject *args) {
char *c;
int l;
- UNLESS (PyArg_ParseTuple(args, "t#:write", &c, &l)) return NULL;
+ if (!PyArg_ParseTuple(args, "t#:write", &c, &l)) return NULL;
if (O_cwrite((PyObject*)self,c,l) < 0) return NULL;
@@ -543,7 +540,8 @@ newOobject(int size) {
self->string_size = 0;
self->softspace = 0;
- UNLESS (self->buf = (char *)malloc(size)) {
+ self->buf = (char *)malloc(size);
+ if (!self->buf) {
PyErr_SetString(PyExc_MemoryError,"out of memory");
self->buf_size = 0;
return NULL;
@@ -573,8 +571,8 @@ I_seek(Iobject *self, PyObject *args) {
Py_ssize_t position;
int mode = 0;
- UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL;
- UNLESS (PyArg_ParseTuple(args, "n|i:seek", &position, &mode))
+ if (!IO__opencheck(IOOOBJECT(self))) return NULL;
+ if (!PyArg_ParseTuple(args, "n|i:seek", &position, &mode))
return NULL;
if (mode == 2) position += self->string_size;
@@ -662,7 +660,8 @@ newIobject(PyObject *s) {
s->ob_type->tp_name);
return NULL;
}
- UNLESS (self = PyObject_New(Iobject, &Itype)) return NULL;
+ self = PyObject_New(Iobject, &Itype);
+ if (!self) return NULL;
Py_INCREF(s);
self->buf=buf;
self->string_size=size;