[pypy-commit] pypy stdlib-2.7.4: have rsre use MAXREPEAT var instead of hard coding

bdkearns noreply at buildbot.pypy.org
Wed Apr 10 06:33:26 CEST 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.4
Changeset: r63187:1fe1d53b3311
Date: 2013-04-09 22:42 -0400
http://bitbucket.org/pypy/pypy/changeset/1fe1d53b3311/

Log:	have rsre use MAXREPEAT var instead of hard coding

diff --git a/rpython/rlib/rsre/rsre_char.py b/rpython/rlib/rsre/rsre_char.py
--- a/rpython/rlib/rsre/rsre_char.py
+++ b/rpython/rlib/rsre/rsre_char.py
@@ -26,6 +26,8 @@
 # Identifying as _sre from Python 2.3 and onwards (at least up to 2.7)
 MAGIC = 20031017
 
+MAXREPEAT = 65535
+
 # In _sre.c this is bytesize of the code word type of the C implementation.
 # There it's 2 for normal Python builds and more for wide unicode builds (large 
 # enough to hold a 32-bit UCS-4 encoded character). Since here in pure Python
@@ -48,9 +50,6 @@
 SRE_INFO_CHARSET = 4
 SRE_FLAG_LOCALE = 4 # honour system locale
 SRE_FLAG_UNICODE = 32 # use unicode locale
-OPCODE_INFO = 17
-OPCODE_LITERAL = 19
-MAXREPEAT = 65535
 
 
 def getlower(char_ord, flags):
diff --git a/rpython/rlib/rsre/rsre_core.py b/rpython/rlib/rsre/rsre_core.py
--- a/rpython/rlib/rsre/rsre_core.py
+++ b/rpython/rlib/rsre/rsre_core.py
@@ -374,7 +374,7 @@
                 ptr=ptr, marks=marks, self=self, ctx=ctx)
             if match_more:
                 max = ctx.pat(ppos+2)
-                if max == 65535 or self.num_pending < max:
+                if max == rsre_char.MAXREPEAT or self.num_pending < max:
                     # try to match one more 'item'
                     enum = sre_match(ctx, ppos + 3, ptr, marks)
                 else:
@@ -442,7 +442,7 @@
                     return self
             resume = False
 
-            if max == 65535 or self.num_pending < max:
+            if max == rsre_char.MAXREPEAT or self.num_pending < max:
                 # try to match one more 'item'
                 enum = sre_match(ctx, ppos + 3, ptr, marks)
                 #
@@ -721,7 +721,7 @@
 
             maxptr = ctx.end
             max = ctx.pat(ppos+2)
-            if max != 65535:
+            if max != rsre_char.MAXREPEAT:
                 maxptr1 = start + max
                 if maxptr1 <= maxptr:
                     maxptr = maxptr1
@@ -784,7 +784,7 @@
     if maxcount == 1:
         return ptrp1
     # Else we really need to count how many times it matches.
-    if maxcount != 65535:
+    if maxcount != rsre_char.MAXREPEAT:
         # adjust end
         end1 = ptr + maxcount
         if end1 <= end:
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -446,7 +446,7 @@
     TYPES += ['__int128_t']
 except CompilationError:
     pass
-    
+
 _TYPES_ARE_UNSIGNED = set(['size_t', 'uintptr_t'])   # plus "unsigned *"
 if os.name != 'nt':
     TYPES.append('mode_t')


More information about the pypy-commit mailing list