[Python-checkins] CVS: python/dist/src/Lib sre.py,1.7,1.8 sre_compile.py,1.5,1.6 sre_constants.py,1.5,1.6 sre_parse.py,1.5,1.6

Fredrik Lundh python-dev@python.org
Thu, 29 Jun 2000 03:34:58 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv1431/Lib

Modified Files:
	sre.py sre_compile.py sre_constants.py sre_parse.py 
Log Message:


- removed "alpha only" licensing restriction
- removed some hacks that worked around 1.6 alpha bugs
- removed bogus test code from sre_parse

Index: sre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8

Index: sre_compile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** sre_compile.py	2000/06/29 08:58:44	1.5
--- sre_compile.py	2000/06/29 10:34:55	1.6
***************
*** 7,13 ****
  # Copyright (c) 1997-2000 by Secret Labs AB.  All rights reserved.
  #
- # This code can only be used for 1.6 alpha testing.  All other use
- # require explicit permission from Secret Labs AB.
- #
  # Portions of this engine have been developed in cooperation with
  # CNRI.  Hewlett-Packard provided funding for 1.6 integration and
--- 7,10 ----

Index: sre_constants.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** sre_constants.py	2000/06/29 08:58:44	1.5
--- sre_constants.py	2000/06/29 10:34:55	1.6
***************
*** 8,14 ****
  # Copyright (c) 1998-2000 by Secret Labs AB.  All rights reserved.
  #
- # This code can only be used for 1.6 alpha testing.  All other use
- # require explicit permission from Secret Labs AB.
- #
  # Portions of this engine have been developed in cooperation with
  # CNRI.  Hewlett-Packard provided funding for 1.6 integration and
--- 8,11 ----

Index: sre_parse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** sre_parse.py	2000/06/29 08:58:44	1.5
--- sre_parse.py	2000/06/29 10:34:55	1.6
***************
*** 7,13 ****
  # Copyright (c) 1998-2000 by Secret Labs AB.  All rights reserved.
  #
- # This code can only be used for 1.6 alpha testing.  All other use
- # require explicit permission from Secret Labs AB.
- #
  # Portions of this engine have been developed in cooperation with
  # CNRI.  Hewlett-Packard provided funding for 1.6 integration and
--- 7,10 ----
***************
*** 21,39 ****
  from sre_constants import *
  
! # FIXME: <fl> should be 65535, but the array module currently chokes
! # on unsigned integers larger than 32767 [fixed in 1.6b1?]
! MAXREPEAT = int(2L**(_sre.getcodesize()*8-1))-1
  
  SPECIAL_CHARS = ".\\[{()*+?^$|"
  REPEAT_CHARS  = "*+?{"
  
! # FIXME: <fl> string in tuple tests may explode with if char is
! # unicode [fixed in 1.6b1?]
! DIGITS = tuple(string.digits)
  
! OCTDIGITS = tuple("01234567")
! HEXDIGITS = tuple("0123456789abcdefABCDEF")
  
! WHITESPACE = tuple(string.whitespace)
  
  ESCAPES = {
--- 18,33 ----
  from sre_constants import *
  
! # FIXME: should be 65535, but the arraymodule is still broken
! MAXREPEAT = 32767
  
  SPECIAL_CHARS = ".\\[{()*+?^$|"
  REPEAT_CHARS  = "*+?{"
  
! DIGITS = string.digits
  
! OCTDIGITS = "01234567"
! HEXDIGITS = "0123456789abcdefABCDEF"
  
! WHITESPACE = string.whitespace
  
  ESCAPES = {
***************
*** 195,199 ****
      try:
  	if escape[1:2] == "x":
! 	    while source.next in HEXDIGITS:
  		escape = escape + source.get()
  	    escape = escape[2:]
--- 189,193 ----
      try:
  	if escape[1:2] == "x":
! 	    while source.next and source.next in HEXDIGITS:
  		escape = escape + source.get()
  	    escape = escape[2:]
***************
*** 201,205 ****
  	    return LITERAL, chr(int(escape[-4:], 16) & 0xff)
  	elif str(escape[1:2]) in OCTDIGITS:
! 	    while source.next in OCTDIGITS:
  		escape = escape + source.get()
  	    escape = escape[1:]
--- 195,199 ----
  	    return LITERAL, chr(int(escape[-4:], 16) & 0xff)
  	elif str(escape[1:2]) in OCTDIGITS:
! 	    while source.next and source.next in OCTDIGITS:
  		escape = escape + source.get()
  	    escape = escape[1:]
***************
*** 222,226 ****
      try:
  	if escape[1:2] == "x":
! 	    while source.next in HEXDIGITS:
  		escape = escape + source.get()
  	    escape = escape[2:]
--- 216,220 ----
      try:
  	if escape[1:2] == "x":
! 	    while source.next and source.next in HEXDIGITS:
  		escape = escape + source.get()
  	    escape = escape[2:]
***************
*** 235,239 ****
  		        return GROUP, group
  		    escape = escape + source.get()
! 		elif source.next in OCTDIGITS:
  		    escape = escape + source.get()
  		else:
--- 229,233 ----
  		        return GROUP, group
  		    escape = escape + source.get()
! 		elif source.next and source.next in OCTDIGITS:
  		    escape = escape + source.get()
  		else:
***************
*** 298,302 ****
      while 1:
  
! 	if str(source.next) in ("|", ")"):
  	    break # end of subpattern
  	this = source.get()
--- 292,296 ----
      while 1:
  
! 	if source.next in ("|", ")"):
  	    break # end of subpattern
  	this = source.get()
***************
*** 379,386 ****
  		min, max = 0, MAXREPEAT
  		lo = hi = ""
! 		while str(source.next) in DIGITS:
  		    lo = lo + source.get()
  		if source.match(","):
! 		    while str(source.next) in DIGITS:
  			hi = hi + source.get()
  		else:
--- 373,380 ----
  		min, max = 0, MAXREPEAT
  		lo = hi = ""
! 		while source.next and source.next in DIGITS:
  		    lo = lo + source.get()
  		if source.match(","):
! 		    while source.next and source.next in DIGITS:
  			hi = hi + source.get()
  		else:
***************
*** 572,600 ****
  	    a(s)
      return match.string[:0].join(p)
- 
- if __name__ == "__main__":
-     from pprint import pprint
-     from testpatterns import PATTERNS
-     a = b = c = 0
-     for pattern, flags in PATTERNS:
- 	if flags:
- 	    continue
- 	print "-"*68
- 	try:
- 	    p = parse(pattern)
- 	    print repr(pattern), "->"
- 	    pprint(p.data)
- 	    import sre_compile
- 	    try:
- 		code = sre_compile.compile(p)
- 		c = c + 1
- 	    except:
- 		pass
- 	    a = a + 1
- 	except error, v:
- 	    print "**", repr(pattern), v
- 	b = b + 1
-     print "-"*68
-     print a, "of", b, "patterns successfully parsed"
-     print c, "of", b, "patterns successfully compiled"
- 
--- 566,567 ----