From df75153d79a83e53d71c9cd08e5863b73fe97914 Mon Sep 17 00:00:00 2001 From: Binbin Date: Sun, 3 Mar 2024 03:26:05 +0800 Subject: [PATCH] Fix reply schemas validator build issue due to new regular expression (#13103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new regular expression break the validator: ``` In file included from commands.c:10: commands_with_reply_schema.def:14528:72: error: stray ‘\’ in program 14528 | struct jsonObjectElement MEMORY_STATS_ReplySchema_patternProperties__db\_\d+__properties_overhead_hashtable_main_elements[] = { ``` The reason is that special characters are not added to to_c_name, causes special characters to appear in the structure name, causing c file compilation to fail. Broken by #12913 --- utils/generate-command-code.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/generate-command-code.py b/utils/generate-command-code.py index dc66ce81f..2d7cc5b0d 100755 --- a/utils/generate-command-code.py +++ b/utils/generate-command-code.py @@ -242,7 +242,8 @@ class Argument(object): def to_c_name(str): return str.replace(":", "").replace(".", "_").replace("$", "_")\ - .replace("^", "_").replace("*", "_").replace("-", "_") + .replace("^", "_").replace("*", "_").replace("-", "_") \ + .replace("\\", "_").replace("+", "_") class ReplySchema(object): @@ -285,7 +286,7 @@ class ReplySchema(object): t = "JSON_TYPE_INTEGER" vstr = ".value.integer=%d" % v - return "%s,\"%s\",%s" % (t, k, vstr) + return "%s,%s,%s" % (t, json.dumps(k), vstr) for k, v in self.schema.items(): if isinstance(v, ReplySchema):