Commit a6dcacbe authored by Jim Fulton's avatar Jim Fulton

Took out some lamosities in interface, like returning self from

write.
parent d21a3fba
/* /*
$Id: cStringIO.c,v 1.8 1996/12/23 15:52:49 jim Exp $ $Id: cStringIO.c,v 1.9 1996/12/27 21:40:29 jim Exp $
A simple fast partial StringIO replacement. A simple fast partial StringIO replacement.
...@@ -58,6 +58,10 @@ ...@@ -58,6 +58,10 @@
$Log: cStringIO.c,v $ $Log: cStringIO.c,v $
Revision 1.9 1996/12/27 21:40:29 jim
Took out some lamosities in interface, like returning self from
write.
Revision 1.8 1996/12/23 15:52:49 jim Revision 1.8 1996/12/23 15:52:49 jim
Added ifdef to check for CObject before using it. Added ifdef to check for CObject before using it.
...@@ -204,7 +208,8 @@ O_seek(Oobject *self, PyObject *args) ...@@ -204,7 +208,8 @@ O_seek(Oobject *self, PyObject *args)
self->pos = (position > self->string_size ? self->string_size : self->pos = (position > self->string_size ? self->string_size :
(position < 0 ? 0 : position)); (position < 0 ? 0 : position));
return PyInt_FromLong(self->pos); Py_INCREF(Py_None);
return Py_None;
} }
static char O_read__doc__[] = static char O_read__doc__[] =
...@@ -317,27 +322,12 @@ O_write(Oobject *self, PyObject *args) ...@@ -317,27 +322,12 @@ O_write(Oobject *self, PyObject *args)
int l, newl, space_needed; int l, newl, space_needed;
UNLESS(PyArg_Parse(args, "O", &s)) return NULL; UNLESS(PyArg_Parse(args, "O", &s)) return NULL;
if(s!=Py_None)
{
UNLESS(-1 != (l=PyString_Size(s))) return NULL; UNLESS(-1 != (l=PyString_Size(s))) return NULL;
UNLESS(c=PyString_AsString(s)) return NULL; UNLESS(c=PyString_AsString(s)) return NULL;
UNLESS(-1 != O_cwrite(self,c,l)) return NULL; UNLESS(-1 != O_cwrite(self,c,l)) return NULL;
}
else
{
self->pos=0;
self->string_size = 0;
}
Py_INCREF(self);
return (PyObject *)self;
}
static PyObject * Py_INCREF(Py_None);
O_repr(self) return Py_None;
Oobject *self;
{
return PyString_FromStringAndSize(self->buf,self->string_size);
} }
static PyObject * static PyObject *
...@@ -513,7 +503,7 @@ static PyTypeObject Otype = { ...@@ -513,7 +503,7 @@ static PyTypeObject Otype = {
(getattrfunc)O_getattr, /*tp_getattr*/ (getattrfunc)O_getattr, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/ (setattrfunc)0, /*tp_setattr*/
(cmpfunc)0, /*tp_compare*/ (cmpfunc)0, /*tp_compare*/
(reprfunc)O_repr, /*tp_repr*/ (reprfunc)0, /*tp_repr*/
0, /*tp_as_number*/ 0, /*tp_as_number*/
0, /*tp_as_sequence*/ 0, /*tp_as_sequence*/
0, /*tp_as_mapping*/ 0, /*tp_as_mapping*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment