コード例 #1
0
 def prev_n(self, position, n, start_position):
     for i in range(n):
         if position <= start_position:
             raise EndOfString
         position = rutf8.prev_codepoint_pos(self._utf8, position)
     assert position >= 0
     return position
コード例 #2
0
def _decr(s, pos, isutf8):
    if isutf8:
        from rpython.rlib.rutf8 import prev_codepoint_pos
        if pos <= 0:
            return -1
        return intmask(prev_codepoint_pos(s, pos))
    else:
        return pos - 1
コード例 #3
0
 def prev_n(self, position, n, start_position):
     i = 0
     # avoid range(n) since n can be quite large
     while i < n:
         if position <= start_position:
             raise EndOfString
         position = rutf8.prev_codepoint_pos(self._utf8, position)
         i += 1
     assert position >= 0
     return position
コード例 #4
0
 def prev(self, position):
     if position <= 0:
         raise EndOfString
     position = rutf8.prev_codepoint_pos(self._utf8, position)
     assert position >= 0
     return position