summaryrefslogtreecommitdiff
path: root/indra/llcommon/llstreamtools.cpp
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2023-08-24 07:37:50 +0800
committerErik Kundiman <erik@megapahit.org>2023-08-24 07:37:50 +0800
commit7f354c70ba623b591c36dadd0f6616b349be4fc7 (patch)
tree67557a9981877e6e4b1f08937dfde94e6287dc61 /indra/llcommon/llstreamtools.cpp
parent5b9cb5bba3c12b1b5c86ba56d43ccf06b83edc14 (diff)
parent33e0766ee08cccb480675a75d83b3a6e78849906 (diff)
Merge tag '6.6.14-release'
source for viewer 6.6.14.581101
Diffstat (limited to 'indra/llcommon/llstreamtools.cpp')
-rw-r--r--indra/llcommon/llstreamtools.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/indra/llcommon/llstreamtools.cpp b/indra/llcommon/llstreamtools.cpp
index 1ff15fcf89..bc32b6fd9e 100644
--- a/indra/llcommon/llstreamtools.cpp
+++ b/indra/llcommon/llstreamtools.cpp
@@ -513,3 +513,29 @@ std::istream& operator>>(std::istream& str, const char *tocheck)
}
return str;
}
+
+int cat_streambuf::underflow()
+{
+ if (gptr() == egptr())
+ {
+ // here because our buffer is empty
+ std::streamsize size = 0;
+ // Until we've run out of mInputs, try reading the first of them
+ // into mBuffer. If that fetches some characters, break the loop.
+ while (! mInputs.empty()
+ && ! (size = mInputs.front()->sgetn(mBuffer.data(), mBuffer.size())))
+ {
+ // We tried to read mInputs.front() but got zero characters.
+ // Discard the first streambuf and try the next one.
+ mInputs.pop_front();
+ }
+ // Either we ran out of mInputs or we succeeded in reading some
+ // characters, that is, size != 0. Tell base class what we have.
+ setg(mBuffer.data(), mBuffer.data(), mBuffer.data() + size);
+ }
+ // If we fell out of the above loop with mBuffer still empty, return
+ // eof(), otherwise return the next character.
+ return (gptr() == egptr())
+ ? std::char_traits<char>::eof()
+ : std::char_traits<char>::to_int_type(*gptr());
+}