[Python-checkins] commit of r41871 - in python/branches/ssize_t: Include/cStringIO.h Modules/cStringIO.c
martin.v.loewis
python-checkins at python.org
Mon Jan 2 17:35:05 CET 2006
Author: martin.v.loewis
Date: Mon Jan 2 17:35:03 2006
New Revision: 41871
Modified:
python/branches/ssize_t/Include/cStringIO.h
python/branches/ssize_t/Modules/cStringIO.c
Log:
Fix cStringIO ssize_t bugs.
Modified: python/branches/ssize_t/Include/cStringIO.h
==============================================================================
--- python/branches/ssize_t/Include/cStringIO.h (original)
+++ python/branches/ssize_t/Include/cStringIO.h Mon Jan 2 17:35:03 2006
@@ -29,7 +29,7 @@
/* Read a string from an input object. If the last argument
is -1, the remainder will be read.
*/
- int(*cread)(PyObject *, char **, int);
+ int(*cread)(PyObject *, char **, Py_ssize_t);
/* Read a line from an input object. Returns the length of the read
line as an int and a pointer inside the object buffer as char** (so
Modified: python/branches/ssize_t/Modules/cStringIO.c
==============================================================================
--- python/branches/ssize_t/Modules/cStringIO.c (original)
+++ python/branches/ssize_t/Modules/cStringIO.c Mon Jan 2 17:35:03 2006
@@ -47,7 +47,7 @@
typedef struct {
PyObject_HEAD
char *buf;
- int pos, string_size;
+ Py_ssize_t pos, string_size;
} IOobject;
#define IOOOBJECT(O) ((IOobject*)(O))
@@ -68,7 +68,7 @@
typedef struct { /* Subtype of IOobject */
PyObject_HEAD
char *buf;
- int pos, string_size;
+ Py_ssize_t pos, string_size;
/* We store a reference to the object here in order to keep
the buffer alive during the lifetime of the Iobject. */
PyObject *pbuf;
@@ -155,7 +155,7 @@
"read([s]) -- Read s characters, or the rest of the string");
static int
-IO_cread(PyObject *self, char **output, int n) {
+IO_cread(PyObject *self, char **output, Py_ssize_t n) {
int l;
UNLESS (IO__opencheck(IOOOBJECT(self))) return -1;
@@ -172,10 +172,10 @@
static PyObject *
IO_read(IOobject *self, PyObject *args) {
- int n = -1;
+ Py_ssize_t n = -1;
char *output;
- UNLESS (PyArg_ParseTuple(args, "|i:read", &n)) return NULL;
+ UNLESS (PyArg_ParseTuple(args, "|n:read", &n)) return NULL;
if ( (n=IO_cread((PyObject*)self,&output,n)) < 0) return NULL;
@@ -287,10 +287,10 @@
static PyObject *
IO_truncate(IOobject *self, PyObject *args) {
- int pos = -1;
+ Py_ssize_t pos = -1;
UNLESS (IO__opencheck(self)) return NULL;
- UNLESS (PyArg_ParseTuple(args, "|i:truncate", &pos)) return NULL;
+ UNLESS (PyArg_ParseTuple(args, "|n:truncate", &pos)) return NULL;
if (pos < 0) pos = self->pos;
if (self->string_size > pos) self->string_size = pos;
@@ -326,14 +326,14 @@
static PyObject *
O_seek(Oobject *self, PyObject *args) {
- int i_position;
Py_ssize_t position;
int mode = 0;
UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL;
- UNLESS (PyArg_ParseTuple(args, "i|i:seek", &i_position, &mode))
+ UNLESS (PyArg_ParseTuple(args, "n|i:seek", &position, &mode))
return NULL;
- position = i_position;
+
+ printf("Seeking to %d\n",(int)position);
if (mode == 2) {
position += self->string_size;
@@ -572,10 +572,11 @@
static PyObject *
I_seek(Iobject *self, PyObject *args) {
- int position, mode = 0;
+ Py_ssize_t position;
+ int mode = 0;
UNLESS (IO__opencheck(IOOOBJECT(self))) return NULL;
- UNLESS (PyArg_ParseTuple(args, "i|i:seek", &position, &mode))
+ UNLESS (PyArg_ParseTuple(args, "n|i:seek", &position, &mode))
return NULL;
if (mode == 2) position += self->string_size;
More information about the Python-checkins
mailing list