From ff900a00d869e44a1930fad0cbd87b292cdac3ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imanol=20Guti=C3=A9rrez?= Date: Sat, 12 Sep 2026 16:28:35 +0300 Subject: [PATCH] Add a newline char at EOF on C and C++ headers --- graphify/extractors/engine.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/graphify/extractors/engine.py b/graphify/extractors/engine.py index 16109a777..aeec2574a 100644 --- a/graphify/extractors/engine.py +++ b/graphify/extractors/engine.py @@ -3177,6 +3177,11 @@ def _extract_generic( try: parser = Parser(language) source = path.read_bytes() if source_override is None else source_override + # In C and C++, if the .h file does not end with a newline '\n' an error + # is throwed even if the file is valid. In order to avoid this, a new line + # char is added only if the original file does not end with it. + if source and not source.endswith(b"\n"): + source = source + b"\n" tree = parser.parse(source) root = tree.root_node except Exception as e: