|
16 | 16 | # 2002-09-11 wd use string methods |
17 | 17 | # 2002-10-18 mvl update to Unicode 3.2 |
18 | 18 | # 2002-10-22 mvl generate NFC tables |
| 19 | +# 2002-11-24 mvl expand all ranges, sort names version-independently |
19 | 20 | # |
20 | 21 | # written by Fredrik Lundh ([email protected]) |
21 | 22 | # |
@@ -403,10 +404,13 @@ def makeunicodename(unicode, trace): |
403 | 404 |
|
404 | 405 | wordlist = words.items() |
405 | 406 |
|
406 | | - # sort on falling frequency |
407 | | - # XXX: different Python versions produce a different order |
408 | | - # for words with equal frequency |
409 | | - wordlist.sort(lambda a, b: len(b[1])-len(a[1])) |
| 407 | + # sort on falling frequency, then by name |
| 408 | + def cmpwords((aword, alist),(bword, blist)): |
| 409 | + r = -cmp(len(alist),len(blist)) |
| 410 | + if r: |
| 411 | + return r |
| 412 | + return cmp(aword, bword) |
| 413 | + wordlist.sort(cmpwords) |
410 | 414 |
|
411 | 415 | # figure out how many phrasebook escapes we need |
412 | 416 | escapes = 0 |
@@ -541,10 +545,10 @@ def __init__(self, filename, exclusions, expand=1): |
541 | 545 | char = int(s[0], 16) |
542 | 546 | table[char] = s |
543 | 547 |
|
544 | | - # expand first-last ranges (ignore surrogates and private use) |
| 548 | + # expand first-last ranges |
545 | 549 | if expand: |
546 | 550 | field = None |
547 | | - for i in range(0, 0xD800): |
| 551 | + for i in range(0, 0x110000): |
548 | 552 | s = table[i] |
549 | 553 | if s: |
550 | 554 | if s[1][-6:] == "First>": |
@@ -587,7 +591,7 @@ def myhash(s, magic): |
587 | 591 | h = 0 |
588 | 592 | for c in map(ord, s.upper()): |
589 | 593 | h = (h * magic) + c |
590 | | - ix = h & 0xff000000 |
| 594 | + ix = h & 0xff000000L |
591 | 595 | if ix: |
592 | 596 | h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff |
593 | 597 | return h |
|
0 commit comments