Analyse the moving window after EOF instead of dropping the file tail #6

Merged
tbaumgartl merged 1 commits from baumgartl/fix-moving-window-eof into main 2026-09-15 01:00:56 +02:00
2 changed files with 26 additions and 8 deletions

No files matched your search

+8
View File
@@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
# [unreleased]
## Fixed
- Moving window parsers dropped the last `moving_window_size - 1 - center_idx` lines of every
file, so events and returnvalues declared near the end of a header were silently missing from
the generated tables. The post-EOF loop shifted the window but never ran the analysis on it,
and it cleared trailing entries before shifting, which overwrote lines that had not reached
the window centre yet.
# [v0.4.0]
- Update event handling for new `constexpr` templated arguments
+18 -8
View File
@@ -198,21 +198,31 @@ class FileParser:
self._handle_file_parsing_moving_window(
file_name, line_idx, moving_window_size, moving_window, *args, **kwargs
)
# Now the moving window moved past the end of the file. Sections which are outside
# the file are assigned an empty string until the window has moved out of file completely
# Now the moving window moves past the end of the file, with empty strings shifted in
# from beyond EOF. This has to keep calling the analysis: the loop above only ever gets
# the window centre as far as the line moving_window_size - 1 - center_idx from the end,
# so without this the last few lines of every file are never looked at and whatever they
# declare is dropped without a warning.
for remaining_windows_idx in range(moving_window_size):
if self.__debug_moving_window and self.__debug_moving_window_filename in file_name:
print("Moving window pre line analysis post EOF")
print(moving_window)
num_entries_to_clear = remaining_windows_idx + 1
for idx_to_clear in range(num_entries_to_clear):
moving_window[moving_window_size - 1 - idx_to_clear] = ""
for idx_to_reassign in range(moving_window_size - 1 - num_entries_to_clear):
moving_window[idx_to_reassign] = moving_window[idx_to_reassign + 1]
# Shift by one, discarding the oldest line and appending the empty line which is now
# past the end of the file. The previous implementation cleared trailing entries
# before shifting, which overwrote lines that had not reached the centre yet.
moving_window.pop(0)
moving_window.append("")
if self.__debug_moving_window and self.__debug_moving_window_filename in file_name:
print("Moving window post line analysis post EOF")
print(moving_window)
pass
self._handle_file_parsing_moving_window(
file_name,
len(all_lines) + remaining_windows_idx,
moving_window_size,
moving_window,
*args,
**kwargs,
)
@staticmethod
def _open_file(file_name: Path) -> list: