Commit d732c95e authored by Raymond Hettinger's avatar Raymond Hettinger

Revert 1.51 booleans so that sre will still run on old pythons.

parent 968c56a6
...@@ -203,16 +203,16 @@ def _optimize_charset(charset, fixup): ...@@ -203,16 +203,16 @@ def _optimize_charset(charset, fixup):
# internal: optimize character set # internal: optimize character set
out = [] out = []
outappend = out.append outappend = out.append
charmap = [False]*256 charmap = [0]*256
try: try:
for op, av in charset: for op, av in charset:
if op is NEGATE: if op is NEGATE:
outappend((op, av)) outappend((op, av))
elif op is LITERAL: elif op is LITERAL:
charmap[fixup(av)] = True charmap[fixup(av)] = 1
elif op is RANGE: elif op is RANGE:
for i in range(fixup(av[0]), fixup(av[1])+1): for i in range(fixup(av[0]), fixup(av[1])+1):
charmap[i] = True charmap[i] = 1
elif op is CATEGORY: elif op is CATEGORY:
# XXX: could append to charmap tail # XXX: could append to charmap tail
return charset # cannot compress return charset # cannot compress
...@@ -298,17 +298,17 @@ def _optimize_unicode(charset, fixup): ...@@ -298,17 +298,17 @@ def _optimize_unicode(charset, fixup):
import array import array
except ImportError: except ImportError:
return charset return charset
charmap = [False]*65536 charmap = [0]*65536
negate = 0 negate = 0
try: try:
for op, av in charset: for op, av in charset:
if op is NEGATE: if op is NEGATE:
negate = 1 negate = 1
elif op is LITERAL: elif op is LITERAL:
charmap[fixup(av)] = True charmap[fixup(av)] = 1
elif op is RANGE: elif op is RANGE:
for i in xrange(fixup(av[0]), fixup(av[1])+1): for i in xrange(fixup(av[0]), fixup(av[1])+1):
charmap[i] = True charmap[i] = 1
elif op is CATEGORY: elif op is CATEGORY:
# XXX: could expand category # XXX: could expand category
return charset # cannot compress return charset # cannot compress
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment