]> granicus.if.org Git - onig/commitdiff
change Unicode VERSION value format
authorK.Kosako <kosako@sofnec.co.jp>
Sun, 29 Sep 2019 23:46:07 +0000 (08:46 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Sun, 29 Sep 2019 23:46:07 +0000 (08:46 +0900)
src/make_unicode_egcb_data.py
src/make_unicode_fold_data.py
src/make_unicode_property_data.py
src/make_unicode_wb_data.py
src/unicode_egcb_data.c
src/unicode_fold_data.c
src/unicode_property_data.c
src/unicode_wb_data.c

index 2f4df9095fdfef5a4541c26fc3b2750be26642c6..9c71796fd5a7d0c22f48daf8051d155f12f115c3 100755 (executable)
@@ -13,18 +13,19 @@ PR_LINE_REG  = re.compile("([0-9A-Fa-f]+)(?:..([0-9A-Fa-f]+))?\s*;\s*(\w+)")
 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:
@@ -160,7 +161,7 @@ def parse_properties(path):
         continue
 
       if s[0] == '#':
-        if VERSION_INFO is None:
+        if VERSION_INFO[0] < 0:
           check_version_info(s)
 
       m = PR_LINE_REG.match(s)
@@ -222,9 +223,11 @@ COPYRIGHT = '''
 
 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:
index 1b18b7c501d0f20c6a836f90d26eadd46a2affb7..55d5b88c55bf1edbed82fcd05767c8f5bd391734 100755 (executable)
@@ -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)
index dc3071a0229b5c9b7bd7e4c3df550528094d11d3..f167a97334a91c7f5e807911360b55cf6a04622c 100755 (executable)
@@ -22,9 +22,9 @@ PR_LINE_REG  = re.compile("([0-9A-Fa-f]+)(?:..([0-9A-Fa-f]+))?\s*;\s*(\w+)")
 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 = { }
@@ -41,10 +41,11 @@ def fix_block_name(name):
   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):
@@ -244,7 +245,7 @@ def parse_properties(path, klass, prop_prefix = None):
         continue
 
       if s[0] == '#':
-        if VERSION_INFO is None:
+        if VERSION_INFO[0] < 0:
           check_version_info(s)
 
       m = PR_LINE_REG.match(s)
@@ -533,9 +534,11 @@ sys.stdout.write(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:
@@ -569,9 +572,11 @@ if not(POSIX_ONLY):
 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)
index 1dc1178282980732e87d2ed01862c5d80f57bdba..ddedd5da6e051f38138669cd440cf95f4b541b47 100755 (executable)
@@ -13,18 +13,19 @@ PR_LINE_REG  = re.compile("([0-9A-Fa-f]+)(?:..([0-9A-Fa-f]+))?\s*;\s*(\w+)")
 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:
@@ -160,7 +161,7 @@ def parse_properties(path):
         continue
 
       if s[0] == '#':
-        if VERSION_INFO is None:
+        if VERSION_INFO[0] < 0:
           check_version_info(s)
 
       m = PR_LINE_REG.match(s)
@@ -222,9 +223,11 @@ COPYRIGHT = '''
 
 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:
index ef8758583e524da59ab90987f20d8ce937c0dd3a..3c49422a5ac64514323098d50fae8e92d12d1106 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-#define GRAPHEME_BREAK_PROPERTY_VERSION  12_1_0
+#define GRAPHEME_BREAK_PROPERTY_VERSION  120100
 
 /*
 CR
index 0dbf9ae76f4ad7ffa49407a25063b3a712b17473..68694b0bad2c50267214b6089576e7c352a90890 100644 (file)
@@ -1,7 +1,7 @@
 /* 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[] = {
index 5c1c8a97073388376cdf97ecd671cceb43436340..88c24a4c10d5287b1de2bbd5c309cb947443d6c8 100644 (file)
@@ -29580,7 +29580,7 @@ unicode_lookup_property_name (register const char *str, register size_t len)
 
 
 
-#define UNICODE_PROPERTY_VERSION  12_1_0
+#define UNICODE_PROPERTY_VERSION  120100
 
 #define PROPERTY_NAME_MAX_SIZE  59
 #define CODE_RANGES_NUM         568
index 6f3968ee8570c3577096f477023765556de31991..8e1a267076df2abd4d2cd11c360a23eb2d0dffa5 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-#define WORD_BREAK_PROPERTY_VERSION  12_1_0
+#define WORD_BREAK_PROPERTY_VERSION  120100
 
 /*
 ALetter