aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/tty/vt/gen_ucs_width_table.py
diff options
context:
space:
mode:
authorNicolas Pitre <npitre@baylibre.com>2025-04-17 14:45:16 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-26 11:22:04 +0200
commitc2d2c5c0d631f7de9697870e4eec89289177d445 (patch)
tree08e5ab964480b90f43a9fb7a8b6fec7e213e1dd4 /drivers/tty/vt/gen_ucs_width_table.py
parentvt: refresh ucs_width_table.h and adjust code in ucs.c accordingly (diff)
downloadwireguard-linux-c2d2c5c0d631f7de9697870e4eec89289177d445.tar.xz
wireguard-linux-c2d2c5c0d631f7de9697870e4eec89289177d445.zip
vt: move UCS tables to the "shipped" form
Use the "shipped" mechanism to copy pre-generated tables to the build tree by default. If GENERATE_UCS_TABLES=1 then they are generated at build time instead. If GENERATE_UCS_TABLES=2 then gen_ucs_recompose_table.py is invoked with --full. Signed-off-by: Nicolas Pitre <npitre@baylibre.com> Suggested-by: Jiri Slaby <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20250417184849.475581-15-nico@fluxnic.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt/gen_ucs_width_table.py')
-rwxr-xr-xdrivers/tty/vt/gen_ucs_width_table.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/tty/vt/gen_ucs_width_table.py b/drivers/tty/vt/gen_ucs_width_table.py
index 059ed9a8baa2..76e80ebeff13 100755
--- a/drivers/tty/vt/gen_ucs_width_table.py
+++ b/drivers/tty/vt/gen_ucs_width_table.py
@@ -5,13 +5,14 @@
import unicodedata
import sys
+import argparse
# This script's file name
from pathlib import Path
this_file = Path(__file__).name
-# Output file name
-out_file = "ucs_width_table.h"
+# Default output file name
+DEFAULT_OUT_FILE = "ucs_width_table.h"
# --- Global Constants for Width Assignments ---
@@ -185,13 +186,14 @@ def create_width_tables():
return zero_width_ranges, double_width_ranges
-def write_tables(zero_width_ranges, double_width_ranges):
+def write_tables(zero_width_ranges, double_width_ranges, out_file=DEFAULT_OUT_FILE):
"""
Write the generated tables to C header file.
Args:
zero_width_ranges: List of (start, end) ranges for zero-width characters
double_width_ranges: List of (start, end) ranges for double-width characters
+ out_file: Output file name (default: DEFAULT_OUT_FILE)
"""
# Function to split ranges into BMP (16-bit) and non-BMP (above 16-bit)
@@ -286,14 +288,20 @@ static const struct ucs_interval32 ucs_double_width_non_bmp_ranges[] = {
f.write("};\n")
if __name__ == "__main__":
+ # Parse command line arguments
+ parser = argparse.ArgumentParser(description="Generate Unicode width tables")
+ parser.add_argument("-o", "--output", dest="output_file", default=DEFAULT_OUT_FILE,
+ help=f"Output file name (default: {DEFAULT_OUT_FILE})")
+ args = parser.parse_args()
+
# Write tables to header file
zero_width_ranges, double_width_ranges = create_width_tables()
- write_tables(zero_width_ranges, double_width_ranges)
+ write_tables(zero_width_ranges, double_width_ranges, out_file=args.output_file)
# Print summary
zero_width_count = sum(end - start + 1 for start, end in zero_width_ranges)
double_width_count = sum(end - start + 1 for start, end in double_width_ranges)
- print(f"Generated {out_file} with:")
+ print(f"Generated {args.output_file} with:")
print(f"- {len(zero_width_ranges)} zero-width ranges covering ~{zero_width_count} code points")
print(f"- {len(double_width_ranges)} double-width ranges covering ~{double_width_count} code points")
print(f"- Unicode Version: {unicodedata.unidata_version}")