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()