From 77df76eaf2b5163f8df9da691d373dd27dea20b4 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 15 Dec 2025 16:15:24 -0600 Subject: [PATCH] Fixed lineno for multiline char literals This avoids redundant newlines in the output when encountering a multiline char literal. I don't think multiline char literals are actually valid in C, but preserving the original whitespace is useful when mixed with other tooling. Before: '\(newline) => '\(newline) \(newline) \(newline) c'(newline) c'(newline) (newline) (newline) After: '\(newline) => '\(newline) \(newline) \(newline) c'(newline) c'(newline) It looks like t_CPP_CHAR was trying to adjust the lineno for consumed newlines, but unlike t_CPP_STRING and t_CPP_COMMENT1, it doesn't actually consume any newlines. --- pcpp/parser.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pcpp/parser.py b/pcpp/parser.py index 8e6a10a..bdfc819 100644 --- a/pcpp/parser.py +++ b/pcpp/parser.py @@ -131,7 +131,6 @@ def t_CPP_STRING(t): # Character constant 'c' or L'c' def t_CPP_CHAR(t): r'(L)?\'([^\\\n]|(\\(.|\n)))*?\'' - t.lexer.lineno += t.value.count("\n") return t # Comment