[Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.37,2.38

Tim Peters tim_one@users.sourceforge.net
2002年3月07日 21:43:34 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv13773/python/Modules
Modified Files:
	mmapmodule.c 
Log Message:
SF bug 515943: searching for data with 0円 in mmap.
mmap_find_method(): this obtained the string to find via s#, but it
ignored its length, acting as if it were 0円-terminated instead.
Someone please run on Linux too (the extended test_mmap works on Windows).
Bugfix candidate.
Index: mmapmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v
retrieving revision 2.37
retrieving revision 2.38
diff -C2 -d -r2.37 -r2.38
*** mmapmodule.c	17 Jan 2002 23:15:58 -0000	2.37
--- mmapmodule.c	8 Mar 2002 05:43:32 -0000	2.38
***************
*** 252,269 ****
 else if ((size_t)start > self->size)
 			start = self->size;
- p = self->data + start;
 
! 		while (p < e) {
! 			char *s = p;
! 			char *n = needle;
! 			while ((s<e) && (*n) && !(*s-*n)) {
! 				s++, n++;
! 			}
! 			if (!*n) {
 				return Py_BuildValue (
 					"l",
 					(long) (p - self->data));
 			}
- 			p++;
 		}
 		return Py_BuildValue ("l", (long) -1);
--- 252,265 ----
 else if ((size_t)start > self->size)
 			start = self->size;
 
! 		for (p = self->data + start; p + len <= e; ++p) {
! 			int i;
! 			for (i = 0; i < len && needle[i] == p[i]; ++i)
! 				/* nothing */;
! 			if (i == len) {
 				return Py_BuildValue (
 					"l",
 					(long) (p - self->data));
 			}
 		}
 		return Py_BuildValue ("l", (long) -1);

AltStyle によって変換されたページ (->オリジナル) /