[Python-checkins] python/dist/src/Lib sre_compile.py,1.45,1.46 sre_constants.py,1.30,1.31 sre_parse.py,1.55,1.56

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Mon, 14 Apr 2003 11:00:08 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv12812/Lib

Modified Files:
	sre_compile.py sre_constants.py sre_parse.py 
Log Message:
SF patch #720991 by Gary Herron:
A small fix for bug #545855 and Greg Chapman's
addition of op code SRE_OP_MIN_REPEAT_ONE for
eliminating recursion on simple uses of pattern '*?' on a
long string.


Index: sre_compile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** sre_compile.py	24 Feb 2003 01:18:35 -0000	1.45
--- sre_compile.py	14 Apr 2003 17:59:31 -0000	1.46
***************
*** 56,61 ****
                  emit(OPCODES[SUCCESS])
                  code[skip] = len(code) - skip
!             elif _simple(av) and op == MAX_REPEAT:
!                 emit(OPCODES[REPEAT_ONE])
                  skip = len(code); emit(0)
                  emit(av[0])
--- 56,64 ----
                  emit(OPCODES[SUCCESS])
                  code[skip] = len(code) - skip
!             elif _simple(av) and op != REPEAT:
!                 if op == MAX_REPEAT:
!                     emit(OPCODES[REPEAT_ONE])
!                 else:
!                     emit(OPCODES[MIN_REPEAT_ONE])
                  skip = len(code); emit(0)
                  emit(av[0])

Index: sre_constants.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** sre_constants.py	4 Sep 2001 19:10:20 -0000	1.30
--- sre_constants.py	14 Apr 2003 17:59:32 -0000	1.31
***************
*** 61,64 ****
--- 61,65 ----
  REPEAT_ONE = "repeat_one"
  SUBPATTERN = "subpattern"
+ MIN_REPEAT_ONE = "min_repeat_one"
  
  # positions
***************
*** 121,125 ****
      REPEAT,
      REPEAT_ONE,
!     SUBPATTERN
  
  ]
--- 122,127 ----
      REPEAT,
      REPEAT_ONE,
!     SUBPATTERN,
!     MIN_REPEAT_ONE
  
  ]

Index: sre_parse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** sre_parse.py	2 Jun 2002 00:40:05 -0000	1.55
--- sre_parse.py	14 Apr 2003 17:59:32 -0000	1.56
***************
*** 420,424 ****
                          set.append((LITERAL, ord("-")))
                          break
!                     else:
                          if this[0] == "\\":
                              code2 = _class_escape(source, this)
--- 420,424 ----
                          set.append((LITERAL, ord("-")))
                          break
!                     elif this:
                          if this[0] == "\\":
                              code2 = _class_escape(source, this)
***************
*** 432,435 ****
--- 432,437 ----
                              raise error, "bad character range"
                          set.append((RANGE, (lo, hi)))
+                     else:
+                         raise error, "unexpected end of regular expression"
                  else:
                      if code1[0] is IN: