From 35e13e4c9637f5bf7bef6039c8c813207780a174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 20 Nov 2023 20:10:50 +0100 Subject: New upstream version 6.9.9 --- src/make_unicode_fold_data.py | 74 +++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'src/make_unicode_fold_data.py') diff --git a/src/make_unicode_fold_data.py b/src/make_unicode_fold_data.py index a73a8a4..1600021 100755 --- a/src/make_unicode_fold_data.py +++ b/src/make_unicode_fold_data.py @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # make_unicode_fold_data.py -# Copyright (c) 2016-2021 K.Kosako +# Copyright (c) 2016-2023 K.Kosako import sys import re @@ -30,7 +30,7 @@ LOCALE_UNFOLDS = {} 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 @@ -182,12 +182,12 @@ typedef unsigned long OnigCodePoint; def divide_by_fold_len(d): l = d.items() - l1 = filter(lambda (k,e):e.fold_len == 1, l) - l2 = filter(lambda (k,e):e.fold_len == 2, l) - l3 = filter(lambda (k,e):e.fold_len == 3, l) - sl1 = sorted(l1, key=lambda (k,e):k) - sl2 = sorted(l2, key=lambda (k,e):k) - sl3 = sorted(l3, key=lambda (k,e):k) + l1 = filter(lambda x:x[1].fold_len == 1, l) + l2 = filter(lambda x:x[1].fold_len == 2, l) + l3 = filter(lambda x:x[1].fold_len == 3, l) + sl1 = sorted(l1, key=lambda x:x[0]) + sl2 = sorted(l2, key=lambda x:x[0]) + sl3 = sorted(l3, key=lambda x:x[0]) return (sl1, sl2, sl3) def output_comment(f, s): @@ -198,7 +198,7 @@ def output_data_n1(f, n, fn, c, out_comment): e.index = c if out_comment and n > 1 and e.comment is not None: output_comment(f, e.comment) - print >> f, '' + print('', file=f) f.write(' ') f.write("/*%4d*/ " % c) @@ -226,25 +226,25 @@ def output_data_n1(f, n, fn, c, out_comment): return c def output_data_n(f, name, n, fn, lfn, out_comment): - print >> f, "OnigCodePoint %s%d[] = {" % (name, n) + print("OnigCodePoint %s%d[] = {" % (name, n), file=f) c = 0 c = output_data_n1(f, n, fn, c, out_comment) - print >> f, "#define FOLDS%d_NORMAL_END_INDEX %d" % (n, c) - print >> f, " /* ----- LOCALE ----- */" + print("#define FOLDS%d_NORMAL_END_INDEX %d" % (n, c), file=f) + print(" /* ----- LOCALE ----- */", file=f) c = output_data_n1(f, n, lfn, c, out_comment) - print >> f, "#define FOLDS%d_END_INDEX %d" % (n, c) - print >> f, "};" + print("#define FOLDS%d_END_INDEX %d" % (n, c), file=f) + print("};", file=f) def output_fold_data(f, name, out_comment): f1, f2, f3 = divide_by_fold_len(FOLDS) lf1, lf2, lf3 = divide_by_fold_len(LOCALE_FOLDS) output_data_n(f, name, 1, f1, lf1, out_comment) - print >> f, '' + print('', file=f) output_data_n(f, name, 2, f2, lf2, out_comment) - print >> f, '' + print('', file=f) output_data_n(f, name, 3, f3, lf3, out_comment) - print >> f, '' + print('', file=f) def output_macros(f, name): print >> f, "#define FOLDS1_FOLD(i) (%s1 + (i))" % name @@ -264,18 +264,18 @@ def output_macros(f, name): print >> f, "#define FOLDS3_NEXT_INDEX(i) ((i) + 4 + %s1[(i)+3])" % name def output_fold_source(f, out_comment): - print >> f, "/* This file was generated by make_unicode_fold_data.py. */" - print >> f, COPYRIGHT - print >> f, "\n" - print >> f, '#include "regenc.h"' - print >> f, '' + print("/* This file was generated by make_unicode_fold_data.py. */", file=f) + print(COPYRIGHT, file=f) + print("\n", file=f) + print('#include "regenc.h"', file=f) + print('', file=f) 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 '' + print("#define UNICODE_CASEFOLD_VERSION %02d%02d%02d" % (VERSION_INFO[0], VERSION_INFO[1], VERSION_INFO[2])) + print('') #output_macros(f, DataName) - print >> f, '' + print('', file=f) #output_typedef(f) output_fold_data(f, DataName, out_comment) @@ -296,12 +296,12 @@ struct ByUnfoldKey { f.write(head) UNFOLDS.update(LOCALE_UNFOLDS) l = UNFOLDS.items() - sl = sorted(l, key=lambda (k,e):(e.fold_len, e.index)) + sl = sorted(l, key=lambda x:(x[1].fold_len, x[1].index)) for k, e in sl: f.write('"%s", /*0x%04x*/ %4d, %d\n' % (form3bytes(k), k, e.index, e.fold_len)) - print >> f, '%%' + print('%%', file=f) def output_gperf_fold_key(f, key_len): head = "%{\n/* This gperf source file was generated by make_unicode_fold_data.py */\n\n" + COPYRIGHT + """\ @@ -314,13 +314,13 @@ short int """ f.write(head) l = FOLDS.items() - l = filter(lambda (k,e):e.fold_len == key_len, l) - sl = sorted(l, key=lambda (k,e):e.index) + l = filter(lambda x:x[1].fold_len == key_len, l) + sl = sorted(l, key=lambda x:x[1].index) for k, e in sl: skey = ''.join(map(lambda i: form3bytes(i), e.fold)) f.write('"%s", %4d\n' % (skey, e.index)) - print >> f, '%%' + print('%%', file=f) def output_gperf_source(): with open(GPERF_UNFOLD_KEY_FILE, 'w') as f: @@ -334,7 +334,7 @@ def output_gperf_source(): def unfolds_byte_length_check(encode): l = UNFOLDS.items() - sl = sorted(l, key=lambda (k,e):(e.fold_len, e.index)) + sl = sorted(l, key=lambda x:(x[1].fold_len, x[1].index)) for unfold, e in sl: key_len = enc_len(unfold, encode) fold_len = sum(map(lambda c: enc_len(c, encode), e.fold)) @@ -345,7 +345,7 @@ def unfolds_byte_length_check(encode): def double_fold_check(): l = UNFOLDS.items() - sl = sorted(l, key=lambda (k,e):(e.fold_len, e.index)) + sl = sorted(l, key=lambda x:(x[1].fold_len, x[1].index)) for unfold, e in sl: for f in e.fold: #print >> sys.stderr, ("check 0x%06x" % f) @@ -356,9 +356,9 @@ def double_fold_check(): def unfold_is_multi_code_folds_head_check(): l = UNFOLDS.items() - l2 = filter(lambda (k,e):e.fold_len == 2, l) - l3 = filter(lambda (k,e):e.fold_len == 3, l) - sl = sorted(l, key=lambda (k,e):(e.fold_len, e.index)) + l2 = filter(lambda x:x[1].fold_len == 2, l) + l3 = filter(lambda x:x[1].fold_len == 3, l) + sl = sorted(l, key=lambda x:(x[1].fold_len, x[1].index)) for unfold, _ in sl: for k, e in l2: if e.fold[0] == unfold: @@ -454,7 +454,7 @@ def get_all_folds_expansion_max_num(): one_folds = make_one_folds(l) fold2_heads = make_foldn_heads(l, 2, one_folds) fold3_heads = make_foldn_heads(l, 3, one_folds) - sl = sorted(l, key=lambda (k,e):(e.fold_len, e.index)) + sl = sorted(l, key=lambda x:(x[1].fold_len, x[1].index)) nmax = 0 max_unfold = None for unfold, e in sl: -- cgit v1.2.3