Author: Armin Rigo <[email protected]>
Branch: unicode-utf8-re
Changeset: r93351:363f54e90b19
Date: 2017-12-10 08:49 +0100
http://bitbucket.org/pypy/pypy/changeset/363f54e90b19/
Log: More
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
@@ -174,6 +174,11 @@
return base_position + index
def next_indirect(self, position):
return position + 1 # like next(), but can be called indirectly
+ def prev_indirect(self, position):
+ position -= 1 # like prev(), but can be called indirectly
+ if position < 0:
+ raise EndOfString
+ return position
def get_mark(self, gid):
return find_mark(self.match_marks, gid)
@@ -217,14 +222,8 @@
these position methods. The Utf8MatchContext subclass doesn't
inherit from here."""
- def next(self, position):
- return position + 1
-
- def prev(self, position):
- position -= 1
- if position < 0:
- raise EndOfString
- return position
+ next = AbstractMatchContext.next_indirect
+ prev = AbstractMatchContext.prev_indirect
def next_n(self, position, n, end_position):
position += n
@@ -397,7 +396,7 @@
self=self, ptr=ptr, ctx=ctx, nextppos=nextppos)
result = sre_match(ctx, nextppos, ptr, self.start_marks)
try:
- ptr = ctx.prev(ptr)
+ ptr = ctx.prev_indirect(ptr)
except EndOfString:
ptr = -1
if result is not None:
diff --git a/rpython/rlib/rsre/rsre_utf8.py b/rpython/rlib/rsre/rsre_utf8.py
--- a/rpython/rlib/rsre/rsre_utf8.py
+++ b/rpython/rlib/rsre/rsre_utf8.py
@@ -41,6 +41,7 @@
position = rutf8.prev_codepoint_pos(self._utf8, position)
assert position >= 0
return position
+ prev_indirect = prev
def next_n(self, position, n, end_position):
for i in range(n):
diff --git a/rpython/rlib/rsre/test/support.py
b/rpython/rlib/rsre/test/support.py
--- a/rpython/rlib/rsre/test/support.py
+++ b/rpython/rlib/rsre/test/support.py
@@ -36,6 +36,7 @@
if position._p == 0:
raise EndOfString
return Position(position._p - 1)
+ prev_indirect = prev
def next_n(self, position, n, end_position):
assert isinstance(position, Position)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit