File: rangetab.py

package info (click to toggle)
libxml2 2.15.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,964 kB
  • sloc: ansic: 138,103; python: 6,692; sh: 4,736; xml: 1,476; makefile: 715
file content (34 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download
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)