PA_LINE_REG = re.compile("(\w+)\s*;\s*(\w+)")
PVA_LINE_REG = re.compile("(sc|gc)\s*;\s*(\w+)\s*;\s*(\w+)(?:\s*;\s*(\w+))?")
BL_LINE_REG = re.compile("([0-9A-Fa-f]+)\.\.([0-9A-Fa-f]+)\s*;\s*(.*)")
-VERSION_REG = re.compile("#\s*.*-(\d+\.\d+\.\d+)\.txt")
+VERSION_REG = re.compile("#\s*.*-(\d+)\.(\d+)\.(\d+)\.txt")
-VERSION_INFO = None
+VERSION_INFO = [-1, -1, -1]
DIC = { }
PROPS = []
PropIndex = { }
def check_version_info(s):
- global VERSION_INFO
m = VERSION_REG.match(s)
if m is not None:
- VERSION_INFO = m.group(1)
+ VERSION_INFO[0] = int(m.group(1))
+ VERSION_INFO[1] = int(m.group(2))
+ VERSION_INFO[2] = int(m.group(3))
def print_ranges(ranges):
for (start, end) in ranges:
continue
if s[0] == '#':
- if VERSION_INFO is None:
+ if VERSION_INFO[0] < 0:
check_version_info(s)
m = PR_LINE_REG.match(s)
print COPYRIGHT
print ''
-if VERSION_INFO is not None:
- print "#define GRAPHEME_BREAK_PROPERTY_VERSION %s" % re.sub(r'[\.-]', '_', VERSION_INFO)
- print ''
+if VERSION_INFO[0] < 0:
+ raise RuntimeError("Version is not found")
+
+print "#define GRAPHEME_BREAK_PROPERTY_VERSION %02d%02d%02d" % (VERSION_INFO[0], VERSION_INFO[1], VERSION_INFO[2])
+print ''
ranges = []
for prop in PROPS:
ENCODING = 'utf-8'
LINE_REG = re.compile("([0-9A-F]{1,6}); (.); ([0-9A-F]{1,6})(?: ([0-9A-F]{1,6}))?(?: ([0-9A-F]{1,6}))?;(?:\s*#\s*)(.*)")
-VERSION_REG = re.compile("#.*-(\d+\.\d+\.\d+)\.txt")
+VERSION_REG = re.compile("#.*-(\d+)\.(\d+)\.(\d+)\.txt")
-VERSION_INFO = None
+VERSION_INFO = [-1, -1, -1]
FOLDS = {}
TURKISH_FOLDS = {}
return "\\x%02x\\x%02x\\x%02x" % (x2, x1, x0)
def check_version_info(s):
- global VERSION_INFO
- if VERSION_INFO is None:
- m = VERSION_REG.match(s)
- if m is not None:
- VERSION_INFO = m.group(1)
+ m = VERSION_REG.match(s)
+ if m is not None:
+ VERSION_INFO[0] = int(m.group(1))
+ VERSION_INFO[1] = int(m.group(2))
+ VERSION_INFO[2] = int(m.group(3))
def parse_line(s):
if len(s) == 0:
- return False
+ return False
if s[0] == '#':
+ if VERSION_INFO[0] < 0:
check_version_info(s)
- return False
+ return False
m = LINE_REG.match(s)
if m is None:
print >> f, "/* This file was generated by make_unicode_fold_data.py. */"
print >> f, '#include "regenc.h"'
print >> f, ''
- if VERSION_INFO is not None:
- print "#define UNICODE_CASEFOLD_VERSION %s" % re.sub(r'[\.-]', '_', VERSION_INFO)
- print ''
+ if VERSION_INFO[0] < 0:
+ raise RuntimeError("Version is not found")
+
+ print "#define UNICODE_CASEFOLD_VERSION %02d%02d%02d" % (VERSION_INFO[0], VERSION_INFO[1], VERSION_INFO[2])
+ print ''
#output_macros(f, DataName)
print >> f, ''
#output_typedef(f)
PA_LINE_REG = re.compile("(\w+)\s*;\s*(\w+)")
PVA_LINE_REG = re.compile("(sc|gc)\s*;\s*(\w+)\s*;\s*(\w+)(?:\s*;\s*(\w+))?")
BL_LINE_REG = re.compile("([0-9A-Fa-f]+)\.\.([0-9A-Fa-f]+)\s*;\s*(.*)")
-VERSION_REG = re.compile("#\s*.*-(\d+\.\d+\.\d+)\.txt")
+VERSION_REG = re.compile("#\s*.*-(\d+)\.(\d+)\.(\d+)\.txt")
-VERSION_INFO = None
+VERSION_INFO = [-1, -1, -1]
DIC = { }
KDIC = { }
PropIndex = { }
return 'In_' + s
def check_version_info(s):
- global VERSION_INFO
m = VERSION_REG.match(s)
if m is not None:
- VERSION_INFO = m.group(1)
+ VERSION_INFO[0] = int(m.group(1))
+ VERSION_INFO[1] = int(m.group(2))
+ VERSION_INFO[2] = int(m.group(3))
def print_ranges(ranges):
continue
if s[0] == '#':
- if VERSION_INFO is None:
+ if VERSION_INFO[0] < 0:
check_version_info(s)
m = PR_LINE_REG.match(s)
if OUTPUT_LIST_MODE:
UPF = open("UNICODE_PROPERTIES", "w")
- if VERSION_INFO is not None:
- print >> UPF, "Unicode Properties (from Unicode Version: %s)" % VERSION_INFO
- print >> UPF, ''
+ if VERSION_INFO[0] < 0:
+ raise RuntimeError("Version is not found")
+
+ print >> UPF, "Unicode Properties (from Unicode Version: %d.%d.%d)" % (VERSION_INFO[0], VERSION_INFO[1], VERSION_INFO[2])
+ print >> UPF, ''
index = -1
for prop in POSIX_LIST:
print '%%'
print ''
if not(POSIX_ONLY):
- if VERSION_INFO is not None:
- print "#define UNICODE_PROPERTY_VERSION %s" % re.sub(r'[\.-]', '_', VERSION_INFO)
- print ''
+ if VERSION_INFO[0] < 0:
+ raise RuntimeError("Version is not found")
+
+ print "#define UNICODE_PROPERTY_VERSION %02d%02d%02d" % (VERSION_INFO[0], VERSION_INFO[1], VERSION_INFO[2])
+ print ''
print "#define PROPERTY_NAME_MAX_SIZE %d" % (PROPERTY_NAME_MAX_LEN + 10)
print "#define CODE_RANGES_NUM %d" % (index + 1)
PA_LINE_REG = re.compile("(\w+)\s*;\s*(\w+)")
PVA_LINE_REG = re.compile("(sc|gc)\s*;\s*(\w+)\s*;\s*(\w+)(?:\s*;\s*(\w+))?")
BL_LINE_REG = re.compile("([0-9A-Fa-f]+)\.\.([0-9A-Fa-f]+)\s*;\s*(.*)")
-VERSION_REG = re.compile("#\s*.*-(\d+\.\d+\.\d+)\.txt")
+VERSION_REG = re.compile("#\s*.*-(\d+)\.(\d+)\.(\d+)\.txt")
-VERSION_INFO = None
+VERSION_INFO = [-1, -1, -1]
DIC = { }
PROPS = []
PropIndex = { }
def check_version_info(s):
- global VERSION_INFO
m = VERSION_REG.match(s)
if m is not None:
- VERSION_INFO = m.group(1)
+ VERSION_INFO[0] = int(m.group(1))
+ VERSION_INFO[1] = int(m.group(2))
+ VERSION_INFO[2] = int(m.group(3))
def print_ranges(ranges):
for (start, end) in ranges:
continue
if s[0] == '#':
- if VERSION_INFO is None:
+ if VERSION_INFO[0] < 0:
check_version_info(s)
m = PR_LINE_REG.match(s)
print COPYRIGHT
print ''
-if VERSION_INFO is not None:
- print "#define WORD_BREAK_PROPERTY_VERSION %s" % re.sub(r'[\.-]', '_', VERSION_INFO)
- print ''
+if VERSION_INFO[0] < 0:
+ raise RuntimeError("Version is not found.")
+
+print "#define WORD_BREAK_PROPERTY_VERSION %02d%02d%02d" % (VERSION_INFO[0], VERSION_INFO[1], VERSION_INFO[2])
+print ''
ranges = []
for prop in PROPS:
* SUCH DAMAGE.
*/
-#define GRAPHEME_BREAK_PROPERTY_VERSION 12_1_0
+#define GRAPHEME_BREAK_PROPERTY_VERSION 120100
/*
CR
/* This file was generated by make_unicode_fold_data.py. */
#include "regenc.h"
-#define UNICODE_CASEFOLD_VERSION 12_1_0
+#define UNICODE_CASEFOLD_VERSION 120100
OnigCodePoint OnigUnicodeFolds1[] = {
-#define UNICODE_PROPERTY_VERSION 12_1_0
+#define UNICODE_PROPERTY_VERSION 120100
#define PROPERTY_NAME_MAX_SIZE 59
#define CODE_RANGES_NUM 568
* SUCH DAMAGE.
*/
-#define WORD_BREAK_PROPERTY_VERSION 12_1_0
+#define WORD_BREAK_PROPERTY_VERSION 120100
/*
ALetter