+
+ if (m_sg && !current_span_remaining)
+ {
+ m_sg->getNextSourceSpan(source_pos, bytes_read, current_span_offset, current_span_remaining);
+
+ if (source_pos != current_span_offset)
+ source_pos = m_raw_source.lseek(current_span_offset, SEEK_SET);
+ bytes_read = 0;
+ }
+
+ size_t maxread = sizeof(m_buffer);
+
+ /* if we have a source span, don't read past the end */
+ if (m_sg && maxread > current_span_remaining)
+ maxread = current_span_remaining;
+