From 9ac62c3a973f7f89df9f53d7332c120e2c528753 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 18 Nov 2022 22:27:37 +0100 Subject: [PATCH] Explain space preservation Signed-off-by: Gilles Peskine --- tests/scripts/generate_test_code.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/scripts/generate_test_code.py b/tests/scripts/generate_test_code.py index e70fffb93..c1d1c1cbf 100755 --- a/tests/scripts/generate_test_code.py +++ b/tests/scripts/generate_test_code.py @@ -550,6 +550,13 @@ def skip_comments(line, stream): line += next(stream) closing = line.find('*/', opening.end(0)) pos = closing + 2 + # Replace inner comment by spaces. There needs to be at least one space + # for things like 'int/*ihatespaces*/foo'. Go further and preserve the + # width of the comment, this way column positions in error messages + # remain correct. + # TODO: It would be better to preserve line breaks, to get accurate + # line numbers if there's something interesting after a comment on + # the same line. line = (line[:opening.start(0)] + ' ' * (pos - opening.start(0)) + line[pos:])