Commit fd04bf1f authored by chris's avatar chris

checked in to be sure repository is up to date.

parent f750e11c
/*
$Id: cStringIO.c,v 1.9 1996/12/27 21:40:29 jim Exp $
$Id: cStringIO.c,v 1.10 1997/01/02 15:19:55 chris Exp $
A simple fast partial StringIO replacement.
......@@ -58,6 +58,9 @@
$Log: cStringIO.c,v $
Revision 1.10 1997/01/02 15:19:55 chris
checked in to be sure repository is up to date.
Revision 1.9 1996/12/27 21:40:29 jim
Took out some lamosities in interface, like returning self from
write.
......@@ -124,6 +127,14 @@ static char cStringIO_module_documentation[] =
static PyObject *ErrorObject;
#ifdef __cplusplus
#define ARG(T,N) T N
#define ARGDECL(T,N)
#else
#define ARG(T,N) N
#define ARGDECL(T,N) T N;
#endif
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
#define UNLESS_ASSIGN(V,E) ASSIGN(V,E) UNLESS(V)
......@@ -163,7 +174,9 @@ static char O_reset__doc__[] =
;
static PyObject *
O_reset(Oobject *self, PyObject *args)
O_reset(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
self->pos = 0;
......@@ -176,7 +189,9 @@ static char O_tell__doc__[] =
"tell() -- get the current position.";
static PyObject *
O_tell(Oobject *self, PyObject *args)
O_tell(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
return PyInt_FromLong(self->pos);
}
......@@ -187,7 +202,9 @@ static char O_seek__doc__[] =
"seek(position, mode) -- mode 0: absolute; 1: relative; 2: relative to EOF";
static PyObject *
O_seek(Oobject *self, PyObject *args)
O_seek(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
int position, mode = 0;
......@@ -217,7 +234,10 @@ static char O_read__doc__[] =
;
static int
O_cread(Oobject *self, char **output, int n)
O_cread(ARG(Oobject*, self), ARG(char**, output), ARG(int, n))
ARGDECL(Oobject*, self)
ARGDECL(char**, output)
ARGDECL(int, n)
{
int l;
......@@ -233,7 +253,9 @@ O_cread(Oobject *self, char **output, int n)
}
static PyObject *
O_read(Oobject *self, PyObject *args)
O_read(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
int n = -1;
char *output;
......@@ -251,7 +273,9 @@ static char O_readline__doc__[] =
;
static int
O_creadline(Oobject *self, char **output)
O_creadline(ARG(Oobject*, self), ARG(char**, output))
ARGDECL(Oobject*, self)
ARGDECL(char**, output)
{
char *n, *s;
int l;
......@@ -267,7 +291,9 @@ O_creadline(Oobject *self, char **output)
}
static PyObject *
O_readline(Oobject *self, PyObject *args)
O_readline(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
int n;
char *output;
......@@ -283,7 +309,10 @@ static char O_write__doc__[] =
static int
O_cwrite(Oobject *self, char *c, int l)
O_cwrite(ARG(Oobject*, self), ARG(char*, c), ARG(int, l))
ARGDECL(Oobject*, self)
ARGDECL(char*, c)
ARGDECL(int, l)
{
PyObject *s;
char *b;
......@@ -315,7 +344,9 @@ O_cwrite(Oobject *self, char *c, int l)
}
static PyObject *
O_write(Oobject *self, PyObject *args)
O_write(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
PyObject *s;
char *c, *b;
......@@ -331,9 +362,9 @@ O_write(Oobject *self, PyObject *args)
}
static PyObject *
O_getval(self,args)
Oobject *self;
PyObject *args;
O_getval(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
return PyString_FromStringAndSize(self->buf,self->pos);
}
......@@ -342,9 +373,9 @@ static char O_truncate__doc__[] =
"truncate(): truncate the file at the current position.";
static PyObject *
O_truncate(self, args)
Oobject *self;
PyObject *args;
O_truncate(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
self->string_size = self->pos;
Py_INCREF(Py_None);
......@@ -354,9 +385,9 @@ O_truncate(self, args)
static char O_isatty__doc__[] = "isatty(): always returns 0";
static PyObject *
O_isatty(self, args)
Oobject *self;
PyObject *args;
O_isatty(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
return PyInt_FromLong(0);
}
......@@ -364,9 +395,9 @@ O_isatty(self, args)
static char O_close__doc__[] = "close(): explicitly release resources held.";
static PyObject *
O_close(self, args)
Oobject *self;
PyObject *args;
O_close(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
free(self->buf);
......@@ -380,9 +411,9 @@ O_close(self, args)
static char O_flush__doc__[] = "flush(): does nothing.";
static PyObject *
O_flush(self, args)
Oobject *self;
PyObject *args;
O_flush(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
Py_INCREF(Py_None);
return Py_None;
......@@ -391,9 +422,9 @@ O_flush(self, args)
static char O_writelines__doc__[] = "blah";
static PyObject *
O_writelines(self, args)
Oobject *self;
PyObject *args;
O_writelines(ARG(Oobject*, self), ARG(PyObject*, args))
ARGDECL(Oobject*, self)
ARGDECL(PyObject*, args)
{
PyObject *string_module = 0;
static PyObject *string_joinfields = 0;
......@@ -448,7 +479,8 @@ static struct PyMethodDef O_methods[] = {
static Oobject *
newOobject(int size)
newOobject(ARG(int, size))
ARGDECL(int, size)
{
Oobject *self;
......@@ -472,17 +504,17 @@ newOobject(int size)
static void
O_dealloc(self)
Oobject *self;
O_dealloc(ARG(Oobject*, self))
ARGDECL(Oobject*, self)
{
free(self->buf);
PyMem_DEL(self);
}
static PyObject *
O_getattr(self, name)
Oobject *self;
char *name;
O_getattr(ARG(Oobject*, self), ARG(char*, name))
ARGDECL(Oobject*, self)
ARGDECL(char*, name)
{
return Py_FindMethod(O_methods, (PyObject *)self, name);
}
......@@ -520,9 +552,9 @@ static PyTypeObject Otype = {
/* -------------------------------------------------------- */
static PyObject *
I_close(self, args)
Iobject *self;
PyObject *args;
I_close(ARG(Iobject*, self), ARG(PyObject*, args))
ARGDECL(Iobject*, self)
ARGDECL(PyObject*, args)
{
Py_DECREF(self->pbuf);
......@@ -550,7 +582,8 @@ static struct PyMethodDef I_methods[] = {
static Iobject *
newIobject(PyObject *s)
newIobject(ARG(PyObject*, s))
ARGDECL(PyObject*, s)
{
Iobject *self;
char *buf;
......@@ -571,17 +604,17 @@ newIobject(PyObject *s)
static void
I_dealloc(self)
Iobject *self;
I_dealloc(ARG(Iobject*, self))
ARGDECL(Iobject*, self)
{
Py_DECREF(self->pbuf);
PyMem_DEL(self);
}
static PyObject *
I_getattr(self, name)
Iobject *self;
char *name;
I_getattr(ARG(Iobject*, self), ARG(char*, name))
ARGDECL(Iobject*, self)
ARGDECL(char*, name)
{
return Py_FindMethod(I_methods, (PyObject *)self, name);
}
......@@ -624,9 +657,9 @@ static char IO_StringIO__doc__[] =
;
static PyObject *
IO_StringIO(self, args)
PyObject *self; /* Not used */
PyObject *args;
IO_StringIO(ARG(PyObject*, self), ARG(PyObject*, args))
ARGDECL(PyObject*, self)
ARGDECL(PyObject*, args)
{
PyObject *s=0;
......
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