Updates to the compose-parse.py script

Get gdkkeysyms.h from git, instead of the outdated copy from svn.
Get Unicode 5.2.0 data. Fix a few issues with missing keysyms in
keysyms.txt. Make the filtering of non-BMP keysyms work.
This commit is contained in:
Matthias Clasen 2010-03-09 02:12:33 -05:00
parent 0fca5a3cca
commit a152f7360d

View File

@ -23,8 +23,8 @@ import getopt
# We grab files off the web, left and right.
URL_COMPOSE = 'http://gitweb.freedesktop.org/?p=xorg/lib/libX11.git;a=blob_plain;f=nls/en_US.UTF-8/Compose.pre'
URL_KEYSYMSTXT = "http://www.cl.cam.ac.uk/~mgk25/ucs/keysyms.txt"
URL_GDKKEYSYMSH = "http://svn.gnome.org/svn/gtk%2B/trunk/gdk/gdkkeysyms.h"
URL_UNICODEDATATXT = 'http://www.unicode.org/Public/5.0.0/ucd/UnicodeData.txt'
URL_GDKKEYSYMSH = "http://git.gnome.org/browse/gtk%2B/plain/gdk/gdkkeysyms.h"
URL_UNICODEDATATXT = 'http://www.unicode.org/Public/5.2.0/ucd/UnicodeData.txt'
FILENAME_COMPOSE_SUPPLEMENTARY = 'gtk-compose-lookaside.txt'
# We currently support keysyms of size 2; once upstream xorg gets sorted,
@ -266,8 +266,8 @@ def process_gdkkeysymsh():
% {'linenum': linenum_gdkkeysymsh, 'filename': filename_gdkkeysymsh, 'line': line}
print "Was expecting a keysym starting with GDK_"
sys.exit(-1)
if components[2][:2] == '0x' and match('[0-9a-fA-F]+$', components[2][2:]):
unival = atoi(components[2][2:], 16)
if match('^0x[0-9a-fA-F]+$', components[2]):
unival = long(components[2][2:], 16)
if unival == 0:
continue
keysymdb[components[1][4:]] = unival
@ -328,8 +328,8 @@ def process_keysymstxt():
% {'linenum': linenum_keysymstxt, 'filename': filename_keysymstxt, 'line': line}
print "Was expecting 5 items in the line"
sys.exit(-1)
if components[1][0] == 'U' and match('[0-9a-fA-F]+$', components[1][1:]):
unival = atoi(components[1][1:], 16)
if match('^U[0-9a-fA-F]+$', components[1]):
unival = long(components[1][1:], 16)
if unival == 0:
continue
keysymdb[components[4]] = unival
@ -373,6 +373,8 @@ def process_keysymstxt():
keysymdb['sevensubscript'] = 0x2087
keysymdb['eightsubscript'] = 0x2088
keysymdb['ninesubscript'] = 0x2089
keysymdb['dead_doublegrave'] = 0x030F
keysymdb['dead_invertedbreve'] = 0x0311
return keysymdb
@ -389,9 +391,9 @@ def keysymvalue(keysym, file = "n/a", linenum = 0):
elif keysym[:2] == '0x' and match('[0-9a-fA-F]+$', keysym[2:]):
return atoi(keysym[2:], 16)
else:
#print 'UNKNOWN{%(keysym)s}' % { "keysym": keysym }
return -1
#sys.exit(-1)
print 'keysymvalue: UNKNOWN{%(keysym)s}' % { "keysym": keysym }
#return -1
sys.exit(-1)
def keysymunicodevalue(keysym, file = "n/a", linenum = 0):
""" Extracts a value from the keysym """
@ -406,15 +408,18 @@ def keysymunicodevalue(keysym, file = "n/a", linenum = 0):
elif keysym[:2] == '0x' and match('[0-9a-fA-F]+$', keysym[2:]):
return atoi(keysym[2:], 16)
else:
print 'UNKNOWN{%(keysym)s}' % { "keysym": keysym }
print 'keysymunicodevalue: UNKNOWN{%(keysym)s}' % { "keysym": keysym }
sys.exit(-1)
def rename_combining(seq):
filtered_sequence = []
for ks in seq:
if findall('^combining_', ks):
filtered_sequence.append(sub('^combining_', 'dead_', ks))
else:
ks = sub('^combining_', 'dead_', ks)
if ks == 'dead_double_grave':
ks = 'dead_doublegrave'
if ks == 'dead_inverted_breve':
ks = 'dead_invertedbreve'
filtered_sequence.append(ks)
return filtered_sequence
@ -514,12 +519,12 @@ for line in xorg_compose_sequences_raw:
continue
if raw_sequence[0][0] == 'U' and match('[0-9a-fA-F]+$', raw_sequence[0][1:]):
raw_sequence[0] = '0x' + raw_sequence[0][1:]
if codepointstr[0] == 'U' and match('[0-9a-fA-F]+$', codepointstr[1:]):
codepoint = atoi(codepointstr[1:], 16)
if match('^U[0-9a-fA-F]+$', codepointstr):
codepoint = long(codepointstr[1:], 16)
elif keysymunicodedatabase.has_key(codepointstr):
if keysymdatabase[codepointstr] != keysymunicodedatabase[codepointstr]:
print "DIFFERENCE: 0x%(a)X 0x%(b)X" % { "a": keysymdatabase[codepointstr], "b": keysymunicodedatabase[codepointstr]},
print raw_sequence, codepointstr
#if keysymdatabase[codepointstr] != keysymunicodedatabase[codepointstr]:
#print "DIFFERENCE: 0x%(a)X 0x%(b)X" % { "a": keysymdatabase[codepointstr], "b": keysymunicodedatabase[codepointstr]},
#print raw_sequence, codepointstr
codepoint = keysymunicodedatabase[codepointstr]
else:
print
@ -547,6 +552,7 @@ for line in xorg_compose_sequences_raw:
"0x0314" in sequence:
continue
if "dead_belowring" in sequence or\
"dead_currency" in sequence or\
"dead_belowcomma" in sequence or\
"dead_belowmacron" in sequence or\
"dead_belowtilde" in sequence or\