From 796713b9d54d1e93b991d4b5e5365033a0da7ba6 Mon Sep 17 00:00:00 2001 From: Vlad-Stefan Harbuz Date: Sun, 13 Aug 2023 19:54:08 +0100 Subject: [PATCH] xxd.py: always write \n line endings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, `open()` was used with the default option of `newline=None`, which means that “any '\n' characters written are translated to the system default line separator”. Now, `xxd.py` always writes `\n` line endings. This eliminates the need for the .gitattributes file. --- .gitattributes | 12 ------------ cmake/xxd.py | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 56cee3023..000000000 --- a/.gitattributes +++ /dev/null @@ -1,12 +0,0 @@ -*.c text -*.cpp text -*.h text -*.cmake text -*.py text -*.txt text -*.sh text -*.vcxproj text eol=crlf -*.sln text eol=crlf -*.filters text eol=crlf -*.appxmanifest text eol=crlf -*.pbxproj text diff --git a/cmake/xxd.py b/cmake/xxd.py index 5254cd1f7..678946ae6 100755 --- a/cmake/xxd.py +++ b/cmake/xxd.py @@ -17,7 +17,7 @@ def main(): binary_data = args.input.open("rb").read() - with args.output.open("w") as fout: + with args.output.open("w", newline="\n") as fout: fout.write("unsigned char {}[] = {{\n".format(varname)) bytes_written = 0 while bytes_written < len(binary_data):