Skip to content

Commit

Permalink
[clang-format] Explicitly open DOC_FILE with utf-8 in dump_format_sty…
Browse files Browse the repository at this point in the history
…le.py (#79805)

The dump_format_style.py script generates the clang-format style options
documentation.
There was an issue where the script could include spurious characters in
the output when run in windows. It appears that it wasn't defaulting to
the correct encoding when reading the input.
This has been addressed by explicitly setting the encoding when opening
the file.
  • Loading branch information
rmarker committed Jan 31, 2024
1 parent b21a2f9 commit c806d8c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clang/docs/tools/dump_format_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ class State:
opts = sorted(opts, key=lambda x: x.name)
options_text = "\n\n".join(map(str, opts))

with open(DOC_FILE) as f:
with open(DOC_FILE, encoding="utf-8") as f:
contents = f.read()

contents = substitute(contents, "FORMAT_STYLE_OPTIONS", options_text)
Expand Down

0 comments on commit c806d8c

Please sign in to comment.