[Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.29,2.30
Greg Stein
gstein@users.sourceforge.net
Mon, 14 May 2001 02:32:28 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv21364
Modified Files:
mmapmodule.c
Log Message:
Fix the .find() method for memory maps.
1) it didn't obey the "start" parameter (and when it does, we must validate
the value)
2) the return value needs to be an absolute index, rather than relative to
some arbitrary point in the file
(checking CVS, it appears this method never worked; these changes bring it
into line with typical .find() behavior)
Index: mmapmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v
retrieving revision 2.29
retrieving revision 2.30
diff -C2 -r2.29 -r2.30
*** mmapmodule.c 2001/05/09 18:48:26 2.29
--- mmapmodule.c 2001/05/14 09:32:26 2.30
***************
*** 233,238 ****
return NULL;
} else {
! char *p = self->data+self->pos;
! char *e = self->data+self->size;
while (p < e) {
char *s = p;
--- 233,247 ----
return NULL;
} else {
! char *p;
! char *e = self->data + self->size;
!
! if (start < 0)
! start += self->size;
! if (start < 0)
! start = 0;
! else if (start > self->size)
! start = self->size;
! p = self->data + start;
!
while (p < e) {
char *s = p;
***************
*** 244,248 ****
return Py_BuildValue (
"i",
! (int) (p - (self->data + start)));
}
p++;
--- 253,257 ----
return Py_BuildValue (
"i",
! (int) (p - self->data));
}
p++;