]> granicus.if.org Git - onig/commitdiff
add output of CASEFOLD_VERSION
authorK.Kosako <kkosako0@gmail.com>
Tue, 3 May 2016 15:11:41 +0000 (00:11 +0900)
committerK.Kosako <kkosako0@gmail.com>
Tue, 3 May 2016 15:11:41 +0000 (00:11 +0900)
src/make_unicode_fold_data.py

index 8510b97aa2ab09d38e43754a1a6cb43f685e5fe7..3f7d416289a923eb4b963d479940f855b2301b49 100755 (executable)
@@ -15,6 +15,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_INFO = None
 
 FOLDS = {}
 TURKISH_FOLDS = {}
@@ -51,10 +54,18 @@ def form3bytes(x):
     x2 = (x>>16) & 0xff
     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)
+
 def parse_line(s):
     if len(s) == 0:
         return False
     if s[0] == '#':
+        check_version_info(s)
         return False
 
     m = LINE_REG.match(s)
@@ -220,6 +231,9 @@ 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 CASEFOLD_VERSION  %s" % re.sub(r'[\.-]', '_', VERSION_INFO)
+        print ''
     #output_macros(f, DataName)
     print >> f, ''
     #output_typedef(f)