commit 93191447032d21b41cfe4a4e584c3f0c42a8a92e
Author: Richard Kimberly Heck <[email protected]>
Date: Sat Apr 25 17:34:27 2020 -0400
Buffer methods for dealing with recursive includes.
---
src/Buffer.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/Buffer.h | 7 +++++++
2 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 4be7e21..ebb302f 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -297,6 +297,8 @@ public:
///
CloneList_ptr clone_list_;
+ ///
+ std::list<Buffer const *> include_list_;
private:
/// So we can force access via the accessors.
mutable Buffer const * parent_buffer;
@@ -5591,4 +5593,55 @@ void Buffer::clearExternalModification() const
}
+void Buffer::pushIncludedBuffer(Buffer const * buf) const
+{
+ masterBuffer()->d->include_list_.push_back(buf);
+ if (lyxerr.debugging(Debug::FILES)) {
+ LYXERR0("Pushed. Stack now:");
+ if (masterBuffer()->d->include_list_.empty())
+ LYXERR0("EMPTY!");
+ else
+ for (auto const & b : masterBuffer()->d->include_list_)
+ LYXERR0(b->fileName());
+ }
+}
+
+
+void Buffer::popIncludedBuffer() const
+{
+ masterBuffer()->d->include_list_.pop_back();
+ if (lyxerr.debugging(Debug::FILES)) {
+ LYXERR0("Popped. Stack now:");
+ if (masterBuffer()->d->include_list_.empty())
+ LYXERR0("EMPTY!");
+ else
+ for (auto const & b : masterBuffer()->d->include_list_)
+ LYXERR0(b->fileName());
+ }
+}
+
+
+bool Buffer::isBufferIncluded(Buffer const * buf) const
+{
+ if (!buf)
+ return false;
+ if (lyxerr.debugging(Debug::FILES)) {
+ LYXERR0("Checking for " << buf->fileName() << ". Stack now:");
+ if (masterBuffer()->d->include_list_.empty())
+ LYXERR0("EMPTY!");
+ else
+ for (auto const & b : masterBuffer()->d->include_list_)
+ LYXERR0(b->fileName());
+ }
+ list<Buffer const *> const & blist = masterBuffer()->d->include_list_;
+ return find(blist.begin(), blist.end(), buf) != blist.end();
+}
+
+
+void Buffer::clearIncludeList() const
+{
+ LYXERR(Debug::FILES, "Clearing include list for " << fileName());
+ d->include_list_.clear();
+}
+
} // namespace lyx
diff --git a/src/Buffer.h b/src/Buffer.h
index e717e46..8eb6e06 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -783,6 +783,13 @@ public:
///
support::FileName getBibfilePath(docstring const & bibid) const;
+ /// routines for dealing with possible self-inclusion
+ void pushIncludedBuffer(Buffer const * buf) const;
+ void popIncludedBuffer() const;
+ bool isBufferIncluded(Buffer const * buf) const;
+private:
+ void clearIncludeList() const;
+
private:
friend class MarkAsExporting;
/// mark the buffer as busy exporting something, or not
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs