mirror of
https://github.com/qpdf/qpdf.git
synced 2024-09-27 12:39:06 +00:00
Merge pull request #918 from m-holger/fixqdf
Code tidy QdfFixer methods
This commit is contained in:
commit
1e53da74bc
@ -316,21 +316,18 @@ QdfFixer::processLines(std::string const& input)
|
|||||||
void
|
void
|
||||||
QdfFixer::checkObjId(std::string const& cur_obj_str)
|
QdfFixer::checkObjId(std::string const& cur_obj_str)
|
||||||
{
|
{
|
||||||
int cur_obj = QUtil::string_to_int(cur_obj_str.c_str());
|
if (std::stoi(cur_obj_str) != ++last_obj) {
|
||||||
if (cur_obj != last_obj + 1) {
|
|
||||||
fatal(
|
fatal(
|
||||||
filename + ":" + std::to_string(lineno) + ": expected object " +
|
filename + ":" + std::to_string(lineno) + ": expected object " +
|
||||||
std::to_string(last_obj + 1));
|
std::to_string(last_obj));
|
||||||
}
|
}
|
||||||
last_obj = cur_obj;
|
xref.push_back(QPDFXRefEntry(1, last_offset, 0));
|
||||||
xref.push_back(QPDFXRefEntry(1, QIntC::to_offset(last_offset), 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QdfFixer::adjustOstreamXref()
|
QdfFixer::adjustOstreamXref()
|
||||||
{
|
{
|
||||||
xref.pop_back();
|
xref.back() = QPDFXRefEntry(2, ostream_id, QIntC::to_int(ostream_idx++));
|
||||||
xref.push_back(QPDFXRefEntry(2, ostream_id, QIntC::to_int(ostream_idx++)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -382,14 +379,10 @@ QdfFixer::writeBinary(unsigned long long val, size_t bytes)
|
|||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
"fix-qdf::writeBinary called with too many bytes");
|
"fix-qdf::writeBinary called with too many bytes");
|
||||||
}
|
}
|
||||||
std::string data;
|
std::string data(bytes, '\0');
|
||||||
data.reserve(bytes);
|
for (auto i = bytes; i > 0; --i) {
|
||||||
for (size_t i = 0; i < bytes; ++i) {
|
data[i - 1] = static_cast<char>(val & 0xff); // i.e. val % 256
|
||||||
data.append(1, '\0');
|
val >>= 8; // i.e. val = val / 256
|
||||||
}
|
|
||||||
for (size_t i = 0; i < bytes; ++i) {
|
|
||||||
data.at(bytes - i - 1) = static_cast<char>(QIntC::to_uchar(val & 0xff));
|
|
||||||
val >>= 8;
|
|
||||||
}
|
}
|
||||||
std::cout << data;
|
std::cout << data;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user