Skip to content

Commit

Permalink
fix crash when ran with -f on empty files
Browse files Browse the repository at this point in the history
  • Loading branch information
X3nom committed Dec 18, 2024
1 parent 4362482 commit 990b984
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/testcase-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def fix_encoding_file(file_path):

# Normalize line endings to LF and prepare UTF-8 content
normalized_content = content.replace("\r\n", "\n").replace("\r", "\n")
if normalized_content[-1] != '\n': normalized_content += '\n' # ensure the file always ends with \n

if len(normalized_content) > 0 and normalized_content[-1] != '\n': normalized_content += '\n' # ensure the file always ends with \n

# Write the file back with UTF-8 encoding
with open(file_path, "w", encoding="utf-8", newline="\n") as file:
Expand Down

0 comments on commit 990b984

Please sign in to comment.