From d37900d91031d944652c6f4fa3e6a258b21e28b9 Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 4 Dec 2025 15:07:22 +0100 Subject: [PATCH] do not default `simplecpp::Location::line` to `1` --- simplecpp.cpp | 1 + simplecpp.h | 2 +- test.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/simplecpp.cpp b/simplecpp.cpp index 8e10ca54..1e5443d2 100644 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -565,6 +565,7 @@ std::string simplecpp::TokenList::stringify(bool linenrs) const { std::ostringstream ret; Location loc(files); + loc.line = 1; bool filechg = true; for (const Token *tok = cfront(); tok; tok = tok->next) { if (tok->location.line < loc.line || tok->location.fileIndex != loc.fileIndex) { diff --git a/simplecpp.h b/simplecpp.h index 15187063..3fd378b0 100644 --- a/simplecpp.h +++ b/simplecpp.h @@ -110,7 +110,7 @@ namespace simplecpp { const std::vector &files; unsigned int fileIndex{}; - unsigned int line{1}; + unsigned int line{}; unsigned int col{}; private: static const std::string emptyFileName; diff --git a/test.cpp b/test.cpp index 69e08781..a9b66efe 100644 --- a/test.cpp +++ b/test.cpp @@ -2732,7 +2732,7 @@ static void readfile_file_not_found() simplecpp::OutputList outputList; std::vector files; (void)simplecpp::TokenList("NotAFile", files, &outputList); - ASSERT_EQUALS("file0,1,file_not_found,File is missing: NotAFile\n", toString(outputList)); + ASSERT_EQUALS("file0,0,file_not_found,File is missing: NotAFile\n", toString(outputList)); } static void stringify1()