summaryrefslogtreecommitdiff
path: root/src/make_unicode_egcb_data.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/make_unicode_egcb_data.py')
-rwxr-xr-xsrc/make_unicode_egcb_data.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/make_unicode_egcb_data.py b/src/make_unicode_egcb_data.py
index b6ded62..80db3f0 100755
--- a/src/make_unicode_egcb_data.py
+++ b/src/make_unicode_egcb_data.py
@@ -1,7 +1,7 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# make_unicode_egcb_data.py
-# Copyright (c) 2017-2021 K.Kosako
+# Copyright (c) 2017-2023 K.Kosako
import sys
import re
@@ -29,10 +29,10 @@ def check_version_info(s):
def print_ranges(ranges):
for (start, end) in ranges:
- print "0x%06x, 0x%06x" % (start, end)
+ print("0x%06x, 0x%06x" % (start, end))
def print_prop_and_index(prop, i):
- print "%-35s %3d" % (prop + ',', i)
+ print("%-35s %3d" % (prop + ',', i))
PropIndex[prop] = i
def dic_find_by_value(dic, v):
@@ -52,7 +52,7 @@ def normalize_ranges(in_ranges, sort=False):
r = []
prev = None
for (start, end) in ranges:
- if prev >= start - 1:
+ if prev is not None and prev >= start - 1:
(pstart, pend) = r.pop()
end = max(pend, end)
start = pstart
@@ -192,10 +192,11 @@ merge_props(PROPS, props)
PROPS = sorted(PROPS)
-print '/* unicode_egcb_data.c: Generated by make_unicode_egcb_data.py. */'
+print('/* unicode_egcb_data.c: Generated by make_unicode_egcb_data.py. */')
+
COPYRIGHT = '''
/*-
- * Copyright (c) 2017-2021 K.Kosako
+ * Copyright (c) 2017-2023 K.Kosako
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -221,13 +222,13 @@ COPYRIGHT = '''
*/
'''.strip()
-print COPYRIGHT
-print ''
+print(COPYRIGHT)
+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 ''
+print("#define GRAPHEME_BREAK_PROPERTY_VERSION %02d%02d%02d" % (VERSION_INFO[0], VERSION_INFO[1], VERSION_INFO[2]))
+print('')
ranges = []
for prop in PROPS:
@@ -243,16 +244,16 @@ for (start, end, prop) in ranges:
raise ValueError("{2}:{0} - {1} range overlap prev value {3}".format(start, end, prop, prev))
-print '/*'
+print('/*')
for prop in PROPS:
- print "%s" % prop
-print '*/'
-print ''
+ print("%s" % prop)
+print('*/')
+print('')
num_ranges = len(ranges)
-print "static int EGCB_RANGE_NUM = %d;" % num_ranges
+print("static int EGCB_RANGE_NUM = %d;" % num_ranges)
-print 'static EGCB_RANGE_TYPE EGCB_RANGES[] = {'
+print('static EGCB_RANGE_TYPE EGCB_RANGES[] = {')
for i, (start, end, prop) in enumerate(ranges):
if i == num_ranges - 1:
comma = ''
@@ -260,8 +261,8 @@ for i, (start, end, prop) in enumerate(ranges):
comma = ','
type_name = 'EGCB_' + prop
- print " {0x%06x, 0x%06x, %s }%s" % (start, end, type_name, comma)
+ print(" {0x%06x, 0x%06x, %s }%s" % (start, end, type_name, comma))
-print '};'
+print('};')
sys.exit(0)