From 24a5e6f7efed9335207aebf5135ab71060825b9b Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Thu, 31 Aug 2017 00:25:03 +1100 Subject: [PATCH] Preprocessor: use streambuf queue size for depth instead of a variable --- src/serialization/preprocessor.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/serialization/preprocessor.cpp b/src/serialization/preprocessor.cpp index a7a277328f0e..84caa477f313 100644 --- a/src/serialization/preprocessor.cpp +++ b/src/serialization/preprocessor.cpp @@ -282,7 +282,6 @@ class preprocessor_streambuf : public std::streambuf , textdomain_(PACKAGE) , location_("") , linenum_(0) - , depth_(0) , quoted_(false) { } @@ -296,14 +295,17 @@ class preprocessor_streambuf : public std::streambuf template void add_preprocessor(A&&... args) { - ++depth_; preprocessor_queue_.emplace_back(new T(*this, std::forward(args)...)); } void drop_preprocessor() { preprocessor_queue_.pop_back(); - --depth_; + } + + int depth() const + { + return preprocessor_queue_.size(); } preprocessor* current() const @@ -322,7 +324,6 @@ class preprocessor_streambuf : public std::streambuf , textdomain_(PACKAGE) , location_("") , linenum_(0) - , depth_(t.depth_) , quoted_(t.quoted_) { } @@ -347,7 +348,6 @@ class preprocessor_streambuf : public std::streambuf std::string location_; int linenum_; - int depth_; /** * Set to true if one preprocessor for this target started to read a string. @@ -1410,7 +1410,7 @@ bool preprocessor_data::get_chunk() pop_token(); put(v.str()); - } else if(parent_.depth_ < 100 && (macro = parent_.defines_->find(symbol)) != parent_.defines_->end()) { + } else if(parent_.depth() < 100 && (macro = parent_.defines_->find(symbol)) != parent_.defines_->end()) { const preproc_define& val = macro->second; size_t nb_arg = strings_.size() - token.stack_pos - 1; size_t optional_arg_num = 0; @@ -1519,7 +1519,7 @@ bool preprocessor_data::get_chunk() put(res.str()); } - } else if(parent_.depth_ < 40) { + } else if(parent_.depth() < 40) { LOG_PREPROC << "Macro definition not found for " << symbol << " , attempting to open as file.\n"; pop_token();