Implement weak pointers
[libs/core.git] / jis.py
diff --git a/jis.py b/jis.py
index d28cd8094f51b6e28d7233777e8269a36dff560e..aed6064a592b992d211530ef3eb4d131b34613ff 100755 (executable)
--- a/jis.py
+++ b/jis.py
@@ -3,24 +3,25 @@
 import sys
 import os
 
 import sys
 import os
 
-in_fn=sys.argv[1]
-out_fn=os.path.splitext(in_fn)[0]+".table"
+in_fn = sys.argv[1]
+out_fn = os.path.splitext(in_fn)[0]+".table"
 
 
-data=[]
+data = []
 for line in file(in_fn):
 for line in file(in_fn):
-       line=line.strip()
+       line = line.strip()
        if line[0]=='#':
                continue
        if line[0]=='#':
                continue
-       parts=line.split(None, 3)
-       code=eval(parts[1])
-       code2=((code&0xFF)-0x21)+(((code>>8)&0xFF)-0x21)*94
+       parts = line.split(None, 3)
+       code = eval(parts[1])-0x2020
+       code2 = (code&0xFF)+((code>>8)&0xFF)*94-95
        data.append((code, eval(parts[2]), code2))
 
        data.append((code, eval(parts[2]), code2))
 
-out=file(out_fn, "w")
+out = file(out_fn, "w")
 out.write("namespace {\n\n")
 
 out.write("namespace {\n\n")
 
+data.sort(lambda x,y: cmp(x[0],y[0]))
 out.write("const unsigned short jisx0208_to_ucs_table[94*94] =\n{\n\t")
 out.write("const unsigned short jisx0208_to_ucs_table[94*94] =\n{\n\t")
-i=0
+i = 0
 for code in xrange(94*94):
        if code>0:
                out.write(", ")
 for code in xrange(94*94):
        if code>0:
                out.write(", ")
@@ -28,7 +29,7 @@ for code in xrange(94*94):
                        out.write("\n\t")
        if i<len(data) and data[i][2]==code:
                out.write("0x%04X"%data[i][1])
                        out.write("\n\t")
        if i<len(data) and data[i][2]==code:
                out.write("0x%04X"%data[i][1])
-               i+=1
+               i += 1
        else:
                out.write("0     ")
 out.write("\n};\n\n")
        else:
                out.write("0     ")
 out.write("\n};\n\n")