File: rangetab.py

package info (click to toggle)
libxml2 2.15.2%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,036 kB
  • sloc: xml: 305,167; ansic: 138,598; python: 6,692; javascript: 5,897; sh: 4,736; makefile: 1,308
file content (34 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (7)
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
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)