Skip to content

Commit 7552e6c

Browse files
committed
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.
1 parent 6190241 commit 7552e6c

File tree

2 files changed

+6773
-2785
lines changed

2 files changed

+6773
-2785
lines changed

scripts/unicode.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,9 @@ def to_combines(combs):
160160
return combs_out
161161

162162
def format_table_content(f, content, indent):
163-
line = " "*indent
164-
first = True
165-
for chunk in content.split(","):
166-
if len(line) + len(chunk) < 98:
167-
if first:
168-
line += chunk
169-
else:
170-
line += ", " + chunk
171-
first = False
172-
else:
173-
f.write(line + ",\n")
174-
line = " "*indent + chunk
175-
f.write(line)
163+
indent = " "*indent
164+
for c in content:
165+
f.write("%s%s,\n" % (indent, c))
176166

177167
def load_properties(f, interestingprops):
178168
fetch(f)
@@ -220,9 +210,7 @@ def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True,
220210
if is_pub:
221211
pub_string = "pub "
222212
f.write(" %sconst %s: %s = &[\n" % (pub_string, name, t_type))
223-
data = [pfun(d) for d in t_data]
224-
data = ','.join(data)
225-
format_table_content(f, data, 8)
213+
format_table_content(f, [pfun(d) for d in t_data], 8)
226214
f.write("\n ];\n\n")
227215

228216
def emit_norm_module(f, canon, compat, combine, norm_props, general_category_mark):

0 commit comments

Comments
 (0)