From d36b3fbf9d244edca1c974e38a6e9c3b4790eef5 Mon Sep 17 00:00:00 2001
From: ellensp <530024+ellensp@users.noreply.github.com>
Date: Sun, 17 Mar 2024 07:37:42 +1300
Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix=20RLE?=
 =?UTF-8?q?=20script=20for=20infille=20=3D=3D=20outfile=20(#26795)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 buildroot/share/scripts/rle_compress_bitmap.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/buildroot/share/scripts/rle_compress_bitmap.py b/buildroot/share/scripts/rle_compress_bitmap.py
index c3f673c6169..12d25a7e4a3 100755
--- a/buildroot/share/scripts/rle_compress_bitmap.py
+++ b/buildroot/share/scripts/rle_compress_bitmap.py
@@ -10,6 +10,8 @@ import sys,struct
 import re
 
 def addCompressedData(input_file, output_file):
+    input_lines = input_file.readlines()
+    input_file.close()
     ofile = open(output_file, 'wt')
 
     datatype = "uint8_t"
@@ -18,8 +20,7 @@ def addCompressedData(input_file, output_file):
     arrname = ''
 
     c_data_section = False ; c_skip_data = False ; c_footer = False
-    while True:
-        line = input_file.readline()
+    for line in input_lines:
         if not line: break
 
         if not c_footer:
@@ -56,8 +57,6 @@ def addCompressedData(input_file, output_file):
                 arrname = line.split('[')[0].split(' ')[-1]
                 print("Found data array", arrname)
 
-    input_file.close()
-
     #print("\nRaw Bitmap Data", raw_data)
 
     #
@@ -190,11 +189,11 @@ if len(sys.argv) <= 2:
     print('Usage: rle_compress_bitmap.py INPUT_FILE OUTPUT_FILE')
     exit(1)
 
-output_cpp = sys.argv[2]
+output_h = sys.argv[2]
 inname = sys.argv[1].replace('//', '/')
 try:
-    input_cpp = open(inname)
+    input_h = open(inname)
     print("Processing", inname, "...")
-    addCompressedData(input_cpp, output_cpp)
+    addCompressedData(input_h, output_h)
 except OSError:
     print("Can't find input file", inname)