[Python-checkins] r60329 - python/trunk/Modules/mmapmodule.c

neal.norwitz python-checkins at python.org
Sat Jan 26 21:24:36 CET 2008


Author: neal.norwitz
Date: Sat Jan 26 21:24:36 2008
New Revision: 60329

Modified:
   python/trunk/Modules/mmapmodule.c
Log:
Cleanup the code a bit.  test_rfind is failing on PPC and PPC64 buildbots,
this might fix the problem.


Modified: python/trunk/Modules/mmapmodule.c
==============================================================================
--- python/trunk/Modules/mmapmodule.c	(original)
+++ python/trunk/Modules/mmapmodule.c	Sat Jan 26 21:24:36 2008
@@ -253,8 +253,8 @@
 	   int reverse)
 {
 	Py_ssize_t start = self->pos;
-        Py_ssize_t end = self->size;
-	char *needle;
+	Py_ssize_t end = self->size;
+	const char *needle;
 	Py_ssize_t len;
 
 	CHECK_VALID(NULL);
@@ -262,7 +262,7 @@
 			      &needle, &len, &start, &end)) {
 		return NULL;
 	} else {
-		char *p;
+		const char *p, *start_p, *end_p;
 		char sign = reverse ? -1 : 1;
 
                 if (start < 0)
@@ -279,11 +279,11 @@
 		else if ((size_t)end > self->size)
 			end = self->size;
 
-		start += (Py_ssize_t)self->data;
-		end += (Py_ssize_t)self->data;
+		start_p = self->data + start;
+		end_p = self->data + end;
 
-		for (p = (char *)(reverse ? end - len : start);
-		     p >= (char *)start && p + len <= (char *)end; p+=sign) {
+		for (p = (reverse ? end_p - len : start_p);
+		     (p >= start_p) && (p + len <= end_p); p += sign) {
 			Py_ssize_t i;
 			for (i = 0; i < len && needle[i] == p[i]; ++i)
 				/* nothing */;


More information about the Python-checkins mailing list