From ab9103440ade87509a1a3bd1eaad0b5396a89d1e Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sat, 17 May 2025 03:20:11 -0600 Subject: Pull UTF-8 decoding into libmisc/utf8.c --- lib9p/core_gen/c.py | 2 +- lib9p/core_gen/c_fmt_print.py | 2 +- lib9p/core_gen/c_validate.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib9p/core_gen') diff --git a/lib9p/core_gen/c.py b/lib9p/core_gen/c.py index 60ceb70..5776035 100644 --- a/lib9p/core_gen/c.py +++ b/lib9p/core_gen/c.py @@ -29,11 +29,11 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str: #include #include +#include #include #include "core_tables.h" -#include "core_utf8.h" """ # utilities ################################################################ ret += """ diff --git a/lib9p/core_gen/c_fmt_print.py b/lib9p/core_gen/c_fmt_print.py index eaacddb..7a0a9d3 100644 --- a/lib9p/core_gen/c_fmt_print.py +++ b/lib9p/core_gen/c_fmt_print.py @@ -112,7 +112,7 @@ def gen_c_fmt_print(versions: set[str], typs: list[idl.UserType]) -> str: cnt_str = f"self->{member.cnt.membname}" cnt_typ = c9util.typename(member.cnt.typ) if member.typ.static_size == 1: # SPECIAL (data) - ret += f"\tif (is_valid_utf8_without_nul((uint8_t *)self->{member.membname}, (size_t){cnt_str})) {{\n" + ret += f"\tif (utf8_is_valid_without_nul((uint8_t *)self->{member.membname}, (size_t){cnt_str})) {{\n" ret += f'\t\tfmt_print_str(w, " {member.membname}=");\n' ret += f"\t\tfmt_print_qmem(w, self->{member.membname}, {cnt_str} < 50 ? {cnt_str} : 50);\n" ret += f"\t\tif ({cnt_str} > 50)\n" diff --git a/lib9p/core_gen/c_validate.py b/lib9p/core_gen/c_validate.py index 9c55d8d..e7a4017 100644 --- a/lib9p/core_gen/c_validate.py +++ b/lib9p/core_gen/c_validate.py @@ -66,7 +66,7 @@ def gen_c_validate(versions: set[str], typs: list[idl.UserType]) -> str: "\t{\n" "\t\tsize_t len = n;\n" "\t\tVALIDATE_NET_BYTES(len);\n" - "\t\tif (!is_valid_utf8_without_nul(&net_bytes[net_offset-len], len))\n" + "\t\tif (!utf8_is_valid_without_nul(&net_bytes[net_offset-len], len))\n" f'\t\t\treturn lib9p_error(ctx, {c9util.IDENT("ERRNO_L_EBADMSG")}, "message contains invalid UTF-8");\n' "\t}\n" ) -- cgit v1.2.3-2-g168b