Commit 97225da2 authored by Martin v. Löwis's avatar Martin v. Löwis

Sort names independent of the Python version. Fix hex constant warning.

Include all First/Last blocks.
parent 5b21df4a
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# 2002-09-11 wd use string methods # 2002-09-11 wd use string methods
# 2002-10-18 mvl update to Unicode 3.2 # 2002-10-18 mvl update to Unicode 3.2
# 2002-10-22 mvl generate NFC tables # 2002-10-22 mvl generate NFC tables
# 2002-11-24 mvl expand all ranges, sort names version-independently
# #
# written by Fredrik Lundh (fredrik@pythonware.com) # written by Fredrik Lundh (fredrik@pythonware.com)
# #
...@@ -403,10 +404,13 @@ def makeunicodename(unicode, trace): ...@@ -403,10 +404,13 @@ def makeunicodename(unicode, trace):
wordlist = words.items() wordlist = words.items()
# sort on falling frequency # sort on falling frequency, then by name
# XXX: different Python versions produce a different order def cmpwords((aword, alist),(bword, blist)):
# for words with equal frequency r = -cmp(len(alist),len(blist))
wordlist.sort(lambda a, b: len(b[1])-len(a[1])) if r:
return r
return cmp(aword, bword)
wordlist.sort(cmpwords)
# figure out how many phrasebook escapes we need # figure out how many phrasebook escapes we need
escapes = 0 escapes = 0
...@@ -541,10 +545,10 @@ class UnicodeData: ...@@ -541,10 +545,10 @@ class UnicodeData:
char = int(s[0], 16) char = int(s[0], 16)
table[char] = s table[char] = s
# expand first-last ranges (ignore surrogates and private use) # expand first-last ranges
if expand: if expand:
field = None field = None
for i in range(0, 0xD800): for i in range(0, 0x110000):
s = table[i] s = table[i]
if s: if s:
if s[1][-6:] == "First>": if s[1][-6:] == "First>":
...@@ -587,7 +591,7 @@ def myhash(s, magic): ...@@ -587,7 +591,7 @@ def myhash(s, magic):
h = 0 h = 0
for c in map(ord, s.upper()): for c in map(ord, s.upper()):
h = (h * magic) + c h = (h * magic) + c
ix = h & 0xff000000 ix = h & 0xff000000L
if ix: if ix:
h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff
return h return h
......
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