Commit 84158d84 authored by Jim Fulton's avatar Jim Fulton

Fixed problem in seek method. The seek method should (and now does) fill with nulls

when seeking past the end of the "file".
parent eba4b092
/* /*
$Id: cStringIO.c,v 1.24 1998/05/05 14:53:45 jim Exp $ $Id: cStringIO.c,v 1.25 1998/10/01 22:24:25 jim Exp $
A simple fast partial StringIO replacement. A simple fast partial StringIO replacement.
...@@ -85,7 +85,7 @@ static char cStringIO_module_documentation[] = ...@@ -85,7 +85,7 @@ static char cStringIO_module_documentation[] =
"If someone else wants to provide a more complete implementation,\n" "If someone else wants to provide a more complete implementation,\n"
"go for it. :-) \n" "go for it. :-) \n"
"\n" "\n"
"$Id: cStringIO.c,v 1.24 1998/05/05 14:53:45 jim Exp $\n" "$Id: cStringIO.c,v 1.25 1998/10/01 22:24:25 jim Exp $\n"
; ;
#include "Python.h" #include "Python.h"
...@@ -152,8 +152,19 @@ O_seek(Oobject *self, PyObject *args) { ...@@ -152,8 +152,19 @@ O_seek(Oobject *self, PyObject *args) {
position += self->pos; position += self->pos;
} }
self->pos = (position > self->string_size ? self->string_size : if (position > self->buf_size) {
(position < 0 ? 0 : position)); self->buf_size*=2;
if(self->buf_size <= position) self->buf_size=position+1;
UNLESS(self->buf=(char*)realloc(self->buf,self->buf_size*sizeof(char))) {
self->buf_size=self->pos=0;
return PyErr_NoMemory();
}
}
else if(position < 0) position=0;
self->pos=position;
while(--position >= self->string_size) self->buf[position]=0;
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
......
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