Skip to content

Commit

Permalink
Fix reply schemas validator build issue due to new regular expression (
Browse files Browse the repository at this point in the history
…#13103)

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
  • Loading branch information
enjoy-binbin committed Mar 2, 2024
1 parent a50bbcb commit df75153
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/generate-command-code.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ def write_internal_structs(self, f):

def to_c_name(str):
return str.replace(":", "").replace(".", "_").replace("$", "_")\
.replace("^", "_").replace("*", "_").replace("-", "_")
.replace("^", "_").replace("*", "_").replace("-", "_") \
.replace("\\", "_").replace("+", "_")


class ReplySchema(object):
Expand Down Expand Up @@ -285,7 +286,7 @@ def struct_code(name, k, v):
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):
Expand Down

0 comments on commit df75153

Please sign in to comment.