/
vsysoev
/
libxml2
Обзор
Документация
Войти
/
vsysoev
/
libxml2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
codegen/rangetab.py
34 строки
1013 B
Nick Wellnhofer
codegen: Factor out code to generate range tables
17 май 2025, 02:29
17 май 2025, 02:29
7c82391
Код
Авторство
О чём код?
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)