mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-02 22:50:20 +00:00
Remove broken QPDFTokenizer::expectInlineImage
This commit is contained in:
parent
25dd3c6750
commit
45dac410b5
@ -4,6 +4,10 @@
|
|||||||
QPDF::copyForeignObject with an unused boolean parameter. If you
|
QPDF::copyForeignObject with an unused boolean parameter. If you
|
||||||
were, for some reason, calling this, just take the parameter away.
|
were, for some reason, calling this, just take the parameter away.
|
||||||
|
|
||||||
|
* Source-level incompatibility: remove the version
|
||||||
|
QPDF::copyForeignObject with an unused boolean parameter. If you
|
||||||
|
were, for some reason, calling this, just take the parameter away.
|
||||||
|
|
||||||
* Source-level incompatibility: rename QUtil::strcasecmp to
|
* Source-level incompatibility: rename QUtil::strcasecmp to
|
||||||
QUtil::str_compare_nocase. This is a non-compatible change, but
|
QUtil::str_compare_nocase. This is a non-compatible change, but
|
||||||
QUtil::strcasecmp is hardly the most important part of qpdf's API.
|
QUtil::strcasecmp is hardly the most important part of qpdf's API.
|
||||||
|
3
TODO
3
TODO
@ -1,9 +1,6 @@
|
|||||||
Next ABI
|
Next ABI
|
||||||
========
|
========
|
||||||
|
|
||||||
* Remove version of QPDFTokenizer::expectInlineImage with no
|
|
||||||
arguments.
|
|
||||||
|
|
||||||
* Build with -fvisibility=hidden by default. Fix QPDF_DLL. See #302
|
* Build with -fvisibility=hidden by default. Fix QPDF_DLL. See #302
|
||||||
for discussion. See also https://gcc.gnu.org/wiki/Visibility
|
for discussion. See also https://gcc.gnu.org/wiki/Visibility
|
||||||
|
|
||||||
|
@ -190,12 +190,6 @@ class QPDFTokenizer
|
|||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
void expectInlineImage(PointerHolder<InputSource> input);
|
void expectInlineImage(PointerHolder<InputSource> input);
|
||||||
|
|
||||||
// Legacy version. New code should not call this. The token
|
|
||||||
// returned will include the EI keyword. The recipient of the
|
|
||||||
// token will have to remove it.
|
|
||||||
QPDF_DLL
|
|
||||||
void expectInlineImage();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Do not implement copy or assignment
|
// Do not implement copy or assignment
|
||||||
QPDFTokenizer(QPDFTokenizer const&);
|
QPDFTokenizer(QPDFTokenizer const&);
|
||||||
|
@ -542,20 +542,6 @@ QPDFTokenizer::presentCharacter(char ch)
|
|||||||
this->m->inline_image_bytes = 0;
|
this->m->inline_image_bytes = 0;
|
||||||
this->m->state = st_token_ready;
|
this->m->state = st_token_ready;
|
||||||
}
|
}
|
||||||
else if ((this->m->inline_image_bytes == 0) &&
|
|
||||||
(len >= 4) &&
|
|
||||||
isDelimiter(this->m->val.at(len-4)) &&
|
|
||||||
(this->m->val.at(len-3) == 'E') &&
|
|
||||||
(this->m->val.at(len-2) == 'I') &&
|
|
||||||
isDelimiter(this->m->val.at(len-1)))
|
|
||||||
{
|
|
||||||
QTC::TC("qpdf", "QPDFTokenizer found EI the old way");
|
|
||||||
this->m->val.erase(len - 1);
|
|
||||||
this->m->type = tt_inline_image;
|
|
||||||
this->m->unread_char = true;
|
|
||||||
this->m->char_to_unread = ch;
|
|
||||||
this->m->state = st_token_ready;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -628,20 +614,6 @@ QPDFTokenizer::presentCharacter(char ch)
|
|||||||
void
|
void
|
||||||
QPDFTokenizer::presentEOF()
|
QPDFTokenizer::presentEOF()
|
||||||
{
|
{
|
||||||
if (this->m->state == st_inline_image)
|
|
||||||
{
|
|
||||||
size_t len = this->m->val.length();
|
|
||||||
if ((len >= 3) &&
|
|
||||||
isDelimiter(this->m->val.at(len-3)) &&
|
|
||||||
(this->m->val.at(len-2) == 'E') &&
|
|
||||||
(this->m->val.at(len-1) == 'I'))
|
|
||||||
{
|
|
||||||
QTC::TC("qpdf", "QPDFTokenizer inline image at EOF the old way");
|
|
||||||
this->m->type = tt_inline_image;
|
|
||||||
this->m->state = st_token_ready;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->m->state == st_literal)
|
if (this->m->state == st_literal)
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "QPDFTokenizer EOF reading appendable token");
|
QTC::TC("qpdf", "QPDFTokenizer EOF reading appendable token");
|
||||||
@ -669,12 +641,6 @@ QPDFTokenizer::presentEOF()
|
|||||||
this->m->state = st_token_ready;
|
this->m->state = st_token_ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
QPDFTokenizer::expectInlineImage()
|
|
||||||
{
|
|
||||||
expectInlineImage(PointerHolder<InputSource>());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDFTokenizer::expectInlineImage(PointerHolder<InputSource> input)
|
QPDFTokenizer::expectInlineImage(PointerHolder<InputSource> input)
|
||||||
{
|
{
|
||||||
|
@ -431,9 +431,7 @@ qpdf from_nr from repeat_nr 0
|
|||||||
QPDF resolve duplicated page object 0
|
QPDF resolve duplicated page object 0
|
||||||
QPDF handle direct page object 0
|
QPDF handle direct page object 0
|
||||||
QPDFTokenizer finder found wrong word 0
|
QPDFTokenizer finder found wrong word 0
|
||||||
QPDFTokenizer found EI the old way 0
|
|
||||||
QPDFTokenizer found EI by byte count 0
|
QPDFTokenizer found EI by byte count 0
|
||||||
QPDFTokenizer inline image at EOF the old way 0
|
|
||||||
QPDFTokenizer found EI after more than one try 0
|
QPDFTokenizer found EI after more than one try 0
|
||||||
QPDFPageObjectHelper externalize inline image 0
|
QPDFPageObjectHelper externalize inline image 0
|
||||||
QPDFPageObjectHelper keep inline image 0
|
QPDFPageObjectHelper keep inline image 0
|
||||||
|
@ -796,7 +796,7 @@ foreach my $d (@eii_tests)
|
|||||||
show_ntests();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
$td->notify("--- Tokenizer ---");
|
$td->notify("--- Tokenizer ---");
|
||||||
$n_tests += 5;
|
$n_tests += 4;
|
||||||
|
|
||||||
$td->runtest("tokenizer with no ignorable",
|
$td->runtest("tokenizer with no ignorable",
|
||||||
{$td->COMMAND => "test_tokenizer -no-ignorable tokens.pdf"},
|
{$td->COMMAND => "test_tokenizer -no-ignorable tokens.pdf"},
|
||||||
@ -808,11 +808,6 @@ $td->runtest("tokenizer",
|
|||||||
{$td->FILE => "tokens.out", $td->EXIT_STATUS => 0},
|
{$td->FILE => "tokens.out", $td->EXIT_STATUS => 0},
|
||||||
$td->NORMALIZE_NEWLINES);
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
|
||||||
$td->runtest("tokenizer with old inline image code",
|
|
||||||
{$td->COMMAND => "test_tokenizer -old-ei tokens.pdf"},
|
|
||||||
{$td->FILE => "tokens-old-ei.out", $td->EXIT_STATUS => 0},
|
|
||||||
$td->NORMALIZE_NEWLINES);
|
|
||||||
|
|
||||||
$td->runtest("tokenizer with max_len",
|
$td->runtest("tokenizer with max_len",
|
||||||
{$td->COMMAND => "test_tokenizer -maxlen 50 tokens.pdf"},
|
{$td->COMMAND => "test_tokenizer -maxlen 50 tokens.pdf"},
|
||||||
{$td->FILE => "tokens-maxlen.out", $td->EXIT_STATUS => 0},
|
{$td->FILE => "tokens-maxlen.out", $td->EXIT_STATUS => 0},
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,7 @@ static char const* whoami = 0;
|
|||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
std::cerr << "Usage: " << whoami
|
std::cerr << "Usage: " << whoami
|
||||||
<< " [-maxlen len | -no-ignorable | -old-ei] filename"
|
<< " [-maxlen len | -no-ignorable] filename"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ try_skipping(QPDFTokenizer& tokenizer, PointerHolder<InputSource> is,
|
|||||||
static void
|
static void
|
||||||
dump_tokens(PointerHolder<InputSource> is, std::string const& label,
|
dump_tokens(PointerHolder<InputSource> is, std::string const& label,
|
||||||
size_t max_len, bool include_ignorable,
|
size_t max_len, bool include_ignorable,
|
||||||
bool skip_streams, bool skip_inline_images, bool old_ei)
|
bool skip_streams, bool skip_inline_images)
|
||||||
{
|
{
|
||||||
Finder f1(is, "endstream");
|
Finder f1(is, "endstream");
|
||||||
std::cout << "--- BEGIN " << label << " ---" << std::endl;
|
std::cout << "--- BEGIN " << label << " ---" << std::endl;
|
||||||
@ -186,14 +186,7 @@ dump_tokens(PointerHolder<InputSource> is, std::string const& label,
|
|||||||
{
|
{
|
||||||
char ch;
|
char ch;
|
||||||
is->read(&ch, 1);
|
is->read(&ch, 1);
|
||||||
if (old_ei)
|
tokenizer.expectInlineImage(is);
|
||||||
{
|
|
||||||
tokenizer.expectInlineImage();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tokenizer.expectInlineImage(is);
|
|
||||||
}
|
|
||||||
inline_image_offset = is->tell();
|
inline_image_offset = is->tell();
|
||||||
}
|
}
|
||||||
else if (token.getType() == QPDFTokenizer::tt_eof)
|
else if (token.getType() == QPDFTokenizer::tt_eof)
|
||||||
@ -205,7 +198,7 @@ dump_tokens(PointerHolder<InputSource> is, std::string const& label,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void process(char const* filename, bool include_ignorable,
|
static void process(char const* filename, bool include_ignorable,
|
||||||
size_t max_len, bool old_ei)
|
size_t max_len)
|
||||||
{
|
{
|
||||||
PointerHolder<InputSource> is;
|
PointerHolder<InputSource> is;
|
||||||
|
|
||||||
@ -213,7 +206,7 @@ static void process(char const* filename, bool include_ignorable,
|
|||||||
FileInputSource* fis = new FileInputSource();
|
FileInputSource* fis = new FileInputSource();
|
||||||
fis->setFilename(filename);
|
fis->setFilename(filename);
|
||||||
is = fis;
|
is = fis;
|
||||||
dump_tokens(is, "FILE", max_len, include_ignorable, true, false, false);
|
dump_tokens(is, "FILE", max_len, include_ignorable, true, false);
|
||||||
|
|
||||||
// Tokenize content streams, skipping inline images
|
// Tokenize content streams, skipping inline images
|
||||||
QPDF qpdf;
|
QPDF qpdf;
|
||||||
@ -232,7 +225,7 @@ static void process(char const* filename, bool include_ignorable,
|
|||||||
"content data", content_data.getPointer());
|
"content data", content_data.getPointer());
|
||||||
is = bis;
|
is = bis;
|
||||||
dump_tokens(is, "PAGE " + QUtil::int_to_string(pageno),
|
dump_tokens(is, "PAGE " + QUtil::int_to_string(pageno),
|
||||||
max_len, include_ignorable, false, true, old_ei);
|
max_len, include_ignorable, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tokenize object streams
|
// Tokenize object streams
|
||||||
@ -251,7 +244,7 @@ static void process(char const* filename, bool include_ignorable,
|
|||||||
is = bis;
|
is = bis;
|
||||||
dump_tokens(is, "OBJECT STREAM " +
|
dump_tokens(is, "OBJECT STREAM " +
|
||||||
QUtil::int_to_string((*iter).getObjectID()),
|
QUtil::int_to_string((*iter).getObjectID()),
|
||||||
max_len, include_ignorable, false, false, false);
|
max_len, include_ignorable, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,7 +269,6 @@ int main(int argc, char* argv[])
|
|||||||
char const* filename = 0;
|
char const* filename = 0;
|
||||||
size_t max_len = 0;
|
size_t max_len = 0;
|
||||||
bool include_ignorable = true;
|
bool include_ignorable = true;
|
||||||
bool old_ei = false;
|
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
if (argv[i][0] == '-')
|
if (argv[i][0] == '-')
|
||||||
@ -293,10 +285,6 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
include_ignorable = false;
|
include_ignorable = false;
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], "-old-ei") == 0)
|
|
||||||
{
|
|
||||||
old_ei = true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usage();
|
usage();
|
||||||
@ -318,7 +306,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
process(filename, include_ignorable, max_len, old_ei);
|
process(filename, include_ignorable, max_len);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user