summaryrefslogtreecommitdiff
path: root/src/make_unicode_wb_data.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-11-20 20:10:50 +0100
committerJörg Frings-Fürst <debian@jff.email>2023-11-20 20:10:50 +0100
commit35e13e4c9637f5bf7bef6039c8c813207780a174 (patch)
treef2ea0b1aa455bb2552ffe8a7bb083f24e86d1f34 /src/make_unicode_wb_data.py
parentdb6f38bc1b73930f1da954525464cf1986f43a28 (diff)
New upstream version 6.9.9upstream/6.9.9upstream
Diffstat (limited to 'src/make_unicode_wb_data.py')
-rwxr-xr-xsrc/make_unicode_wb_data.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/make_unicode_wb_data.py b/src/make_unicode_wb_data.py
index dfa8f1e..fc7d93a 100755
--- a/src/make_unicode_wb_data.py
+++ b/src/make_unicode_wb_data.py
@@ -1,7 +1,7 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# make_unicode_wb_data.py
-# Copyright (c) 2019-2021 K.Kosako
+# Copyright (c) 2019-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_wb_data.c: Generated by make_unicode_wb_data.py. */'
+print('/* unicode_wb_data.c: Generated by make_unicode_wb_data.py. */')
+
COPYRIGHT = '''
/*-
- * Copyright (c) 2019-2021 K.Kosako
+ * Copyright (c) 2019-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 WORD_BREAK_PROPERTY_VERSION %02d%02d%02d" % (VERSION_INFO[0], VERSION_INFO[1], VERSION_INFO[2])
-print ''
+print("#define WORD_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 WB_RANGE_NUM = %d;" % num_ranges
+print("static int WB_RANGE_NUM = %d;" % num_ranges)
-print 'static WB_RANGE_TYPE WB_RANGES[] = {'
+print('static WB_RANGE_TYPE WB_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 = 'WB_' + 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)