From 94854ab2276465c94d41c2d09e073bba9322ef41 Mon Sep 17 00:00:00 2001 From: Tobias Baumgartl Date: Tue, 15 Sep 2026 00:56:00 +0200 Subject: [PATCH] Analyse the moving window after EOF instead of dropping the file tail The moving window parsers never looked at the last few lines of any file. The window centre is at index 3 of a 7 line window, so the main loop only ever gets the centre as far as the fourth line from the end. The loop which is supposed to walk the window off the end of the file shifted it but never called _handle_file_parsing_moving_window, so every event or returnvalue declared in the last three lines of a header was dropped without a warning. That loop also cleared trailing window entries before shifting the remaining ones down, which overwrote lines that had not reached the centre yet, so even with the analysis call added the window contents would have been wrong. Shift by one with pop/append and run the analysis on each resulting window. Found via sourceobsw, where this silently dropped three CFDP returnvalues and two events from the generated tables, including a HIGH severity MGT_STARTUP_FAILURE_REMINDER which the ground could not translate. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01RZpKfWUzvTkBMXEv9NEoTM --- CHANGELOG.md | 8 ++++++++ fsfwgen/parserbase/parser.py | 26 ++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7acc3c3..3573eae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/fsfwgen/parserbase/parser.py b/fsfwgen/parserbase/parser.py index 52bc084..b4e94e2 100644 --- a/fsfwgen/parserbase/parser.py +++ b/fsfwgen/parserbase/parser.py @@ -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: -- 2.43.0