xxd.py: always write \n line endings

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.
This commit is contained in:
Vlad-Stefan Harbuz 2023-08-13 19:54:08 +01:00 committed by Sam Lantinga
parent 723bcd0a8b
commit 796713b9d5
2 changed files with 1 additions and 13 deletions

12
.gitattributes vendored
View File

@ -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

View File

@ -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):