From 21e7b5f956c155a703ec4d2c7c222d7243f3a634 Mon Sep 17 00:00:00 2001 From: chrchr Date: Tue, 12 Sep 2023 15:07:47 +0200 Subject: [PATCH] Undo, limit maxsize to 1000 tokens --- simplecpp.cpp | 14 +++++--------- simplecpp.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/simplecpp.cpp b/simplecpp.cpp index 96c9d31b..7c4a6c4d 100755 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -1362,18 +1362,14 @@ std::string simplecpp::TokenList::lastLine(int maxsize) const if (++count > maxsize) return ""; if (!ret.empty()) - ret += ' '; - // add tokens in reverse for performance reasons + ret.insert(0, 1, ' '); if (tok->str()[0] == '\"') - ret += "%rts%"; // %str% + ret.insert(0, "%str%"); else if (tok->number) - ret += "%mun%"; // %num% - else { - ret += tok->str(); - std::reverse(ret.end() - tok->str().length(), ret.end()); - } + ret.insert(0, "%num%"); + else + ret.insert(0, tok->str()); } - std::reverse(ret.begin(), ret.end()); return ret; } diff --git a/simplecpp.h b/simplecpp.h index b6124953..afd7d92c 100755 --- a/simplecpp.h +++ b/simplecpp.h @@ -294,7 +294,7 @@ namespace simplecpp { std::string readUntil(Stream &stream, const Location &location, char start, char end, OutputList *outputList); void lineDirective(unsigned int fileIndex, unsigned int line, Location *location); - std::string lastLine(int maxsize=100000) const; + std::string lastLine(int maxsize=1000) const; bool isLastLinePreprocessor(int maxsize=100000) const; unsigned int fileIndex(const std::string &filename);