File size: 1,013 Bytes
6baed57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def gen_range_tables(out, name, s_suffix, l_suffix, ranges):
    numshort = 0
    numlong = 0
    sptr = "NULL"
    lptr = "NULL"

    for range in ranges:
        (low, high) = range
        if high < 0x10000:
            if numshort == 0:
                sptr = name + s_suffix
                pline = "static const xmlChSRange %s[] = {" % sptr
            else:
                pline += ","
            numshort += 1
        else:
            if numlong == 0:
                if numshort > 0:
                    out.write(pline + "};\n")
                lptr = name + l_suffix
                pline = "static const xmlChLRange %s[] = {" % lptr
            else:
                pline += ","
            numlong += 1
        if len(pline) > 60:
            out.write(pline + "\n")
            pline = "    "
        elif pline[-1:] == ",":
            pline += " "
        pline += "{%s, %s}" % (hex(low), hex(high))

    out.write(pline + "};\n")

    return "{%s,%s,%s,%s}" % (numshort, numlong, sptr, lptr)