summaryrefslogtreecommitdiff
path: root/src/make_unicode_fold_data.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/make_unicode_fold_data.py')
-rwxr-xr-xsrc/make_unicode_fold_data.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/make_unicode_fold_data.py b/src/make_unicode_fold_data.py
index 783988c..55d5b88 100755
--- a/src/make_unicode_fold_data.py
+++ b/src/make_unicode_fold_data.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# make_unicode_fold_data.py
-# Copyright (c) 2016-2018 K.Kosako
+# Copyright (c) 2016-2019 K.Kosako
import sys
import re
@@ -16,9 +16,9 @@ DataName = 'OnigUnicodeFolds'
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 = {}
@@ -56,18 +56,19 @@ def form3bytes(x):
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:
@@ -232,9 +233,11 @@ def output_fold_source(f, out_comment):
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)
@@ -246,7 +249,7 @@ HEAD = '''
/* This gperf source file was generated by make_unicode_fold_data.py */
/*-
- * Copyright (c) 2017-2018 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
+ * Copyright (c) 2017-2019 K.Kosako
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without