aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFParser.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-12-16 19:08:56 +0100
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-12-31 16:23:59 +0100
commit0ef2def8ad1f280adc34825b1588d9811d9ac031 (patch)
tree56f49962d12a4bdcf530ad4dc482ad47e9d7d146 /libqpdf/QPDFParser.cc
parentc833c25499257662ab3bad8083989283fdbe0736 (diff)
downloadqpdf-0ef2def8ad1f280adc34825b1588d9811d9ac031.tar.zst
Delay adding offsets to object descriptions until necessary
Diffstat (limited to 'libqpdf/QPDFParser.cc')
-rw-r--r--libqpdf/QPDFParser.cc19
1 files changed, 6 insertions, 13 deletions
diff --git a/libqpdf/QPDFParser.cc b/libqpdf/QPDFParser.cc
index 70c328e1..0ce97a8e 100644
--- a/libqpdf/QPDFParser.cc
+++ b/libqpdf/QPDFParser.cc
@@ -288,8 +288,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
if (!indirect_ref && !is_null) {
// No need to set description for direct nulls - they will
// become implicit.
- auto os = input->getLastOffset();
- setDescription(object, os, os);
+ setDescription(object, input->getLastOffset());
}
set_offset = true;
olist.push_back(is_null ? null_oh : object);
@@ -312,7 +311,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
state_stack.pop_back();
if (old_state == st_array) {
object = QPDFObjectHandle::newArray(olist);
- setDescription(object, offset, offset - 1);
+ setDescription(object, offset - 1);
// The `offset` points to the next of "[". Set the rewind
// offset to point to the beginning of "[". This has been
// explicitly tested with whitespace surrounding the array start
@@ -386,7 +385,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
dict["/Contents"].setParsedOffset(frame.contents_offset);
}
object = QPDFObjectHandle::newDictionary(dict);
- setDescription(object, offset, offset - 2);
+ setDescription(object, offset - 2);
// The `offset` points to the next of "<<". Set the rewind
// offset to point to the beginning of "<<". This has been
// explicitly tested with whitespace surrounding the dictionary
@@ -407,22 +406,16 @@ QPDFParser::parse(bool& empty, bool content_stream)
object = QPDFObjectHandle::newNull();
}
if (!set_offset) {
- setDescription(object, offset, offset);
+ setDescription(object, offset);
}
return object;
}
void
-QPDFParser::setDescription(
- QPDFObjectHandle oh,
- qpdf_offset_t descr_offset,
- qpdf_offset_t parsed_offset) const
+QPDFParser::setDescription(QPDFObjectHandle oh, qpdf_offset_t parsed_offset)
{
if (auto& obj = oh.obj) {
- auto descr = std::make_shared<std::string>(
- input->getName() + ", " + object_description + " at offset " +
- std::to_string(descr_offset));
- obj->setDescription(context, descr, parsed_offset);
+ obj->setDescription(context, description, parsed_offset);
}
}