mirror of
https://github.com/openharmony/third_party_rust_unicode-normalization.git
synced 2026-07-18 13:07:58 -04:00
format tables with one entry per line
This change avoids formatting table entries into a string, only to split them apart again. The new format is also slightly easier to read and compare when changes are made to how the tables are organized.
This commit is contained in:
+4
-16
@@ -160,19 +160,9 @@ def to_combines(combs):
|
||||
return combs_out
|
||||
|
||||
def format_table_content(f, content, indent):
|
||||
line = " "*indent
|
||||
first = True
|
||||
for chunk in content.split(","):
|
||||
if len(line) + len(chunk) < 98:
|
||||
if first:
|
||||
line += chunk
|
||||
else:
|
||||
line += ", " + chunk
|
||||
first = False
|
||||
else:
|
||||
f.write(line + ",\n")
|
||||
line = " "*indent + chunk
|
||||
f.write(line)
|
||||
indent = " "*indent
|
||||
for c in content:
|
||||
f.write("%s%s,\n" % (indent, c))
|
||||
|
||||
def load_properties(f, interestingprops):
|
||||
fetch(f)
|
||||
@@ -220,9 +210,7 @@ def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True,
|
||||
if is_pub:
|
||||
pub_string = "pub "
|
||||
f.write(" %sconst %s: %s = &[\n" % (pub_string, name, t_type))
|
||||
data = [pfun(d) for d in t_data]
|
||||
data = ','.join(data)
|
||||
format_table_content(f, data, 8)
|
||||
format_table_content(f, [pfun(d) for d in t_data], 8)
|
||||
f.write("\n ];\n\n")
|
||||
|
||||
def emit_norm_module(f, canon, compat, combine, norm_props, general_category_mark):
|
||||
|
||||
+6769
-2769
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user