diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | examples/pdf-bookmarks.cc | 6 | ||||
-rw-r--r-- | fuzz/qpdf_fuzzer.cc | 6 | ||||
-rw-r--r-- | include/qpdf/QPDFOutlineDocumentHelper.hh | 10 | ||||
-rw-r--r-- | include/qpdf/QPDFOutlineObjectHelper.hh | 6 | ||||
-rw-r--r-- | libqpdf/QPDFOutlineDocumentHelper.cc | 8 | ||||
-rw-r--r-- | libqpdf/QPDFOutlineObjectHelper.cc | 2 | ||||
-rw-r--r-- | manual/qpdf-manual.xml | 10 | ||||
-rw-r--r-- | qpdf/qpdf.cc | 8 | ||||
-rw-r--r-- | qpdf/test_driver.cc | 4 |
10 files changed, 45 insertions, 25 deletions
@@ -1,3 +1,13 @@ +2019-07-03 Jay Berkenbilt <ejb@ql.org> + + * Non-compatible API change: change + QPDFOutlineDocumentHelper::getTopLevelOutlines and + QPDFOutlineObjectHelper::getKids to return a std::vector instead + of a std::list of QPDFOutlineObjectHelper objects. This is to work + around bugs with some compilers' STL implementations that are + choking with list here. There's no deep reason for these to be + lists instead of vectors. Fixes #297. + 2019-06-22 Jay Berkenbilt <ejb@ql.org> * Handle encrypted files with missing or invalid /Length entries diff --git a/examples/pdf-bookmarks.cc b/examples/pdf-bookmarks.cc index 807fc02f..20a93078 100644 --- a/examples/pdf-bookmarks.cc +++ b/examples/pdf-bookmarks.cc @@ -135,16 +135,16 @@ void show_bookmark_details(QPDFOutlineObjectHelper outline, std::cout << outline.getTitle() << std::endl; } -void extract_bookmarks(std::list<QPDFOutlineObjectHelper> outlines, +void extract_bookmarks(std::vector<QPDFOutlineObjectHelper> outlines, std::vector<int>& numbers) { numbers.push_back(0); - for (std::list<QPDFOutlineObjectHelper>::iterator iter = outlines.begin(); + for (std::vector<QPDFOutlineObjectHelper>::iterator iter = outlines.begin(); iter != outlines.end(); ++iter) { ++(numbers.back()); show_bookmark_details(*iter, numbers); - std::list<QPDFOutlineObjectHelper>::iterator next = iter; + std::vector<QPDFOutlineObjectHelper>::iterator next = iter; ++next; bool has_next = (next != outlines.end()); if ((style == st_lines) && (! has_next)) diff --git a/fuzz/qpdf_fuzzer.cc b/fuzz/qpdf_fuzzer.cc index ac591637..32b9a0fb 100644 --- a/fuzz/qpdf_fuzzer.cc +++ b/fuzz/qpdf_fuzzer.cc @@ -170,13 +170,13 @@ void FuzzHelper::testOutlines() { PointerHolder<QPDF> q = getQpdf(); - std::list<std::list<QPDFOutlineObjectHelper> > queue; + std::list<std::vector<QPDFOutlineObjectHelper> > queue; QPDFOutlineDocumentHelper odh(*q); queue.push_back(odh.getTopLevelOutlines()); while (! queue.empty()) { - std::list<QPDFOutlineObjectHelper>& outlines = *(queue.begin()); - for (std::list<QPDFOutlineObjectHelper>::iterator iter = + std::vector<QPDFOutlineObjectHelper>& outlines = *(queue.begin()); + for (std::vector<QPDFOutlineObjectHelper>::iterator iter = outlines.begin(); iter != outlines.end(); ++iter) { diff --git a/include/qpdf/QPDFOutlineDocumentHelper.hh b/include/qpdf/QPDFOutlineDocumentHelper.hh index f1920574..45798a47 100644 --- a/include/qpdf/QPDFOutlineDocumentHelper.hh +++ b/include/qpdf/QPDFOutlineDocumentHelper.hh @@ -28,8 +28,8 @@ #include <qpdf/QPDF.hh> #include <map> -#include <list> #include <set> +#include <vector> #include <qpdf/DLL.h> @@ -51,7 +51,7 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper bool hasOutlines(); QPDF_DLL - std::list<QPDFOutlineObjectHelper> getTopLevelOutlines(); + std::vector<QPDFOutlineObjectHelper> getTopLevelOutlines(); // If the name is a name object, look it up in the /Dests key of // the document catalog. If the name is a string, look it up in @@ -64,7 +64,7 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper // Return a list outlines that are known to target the specified // page QPDF_DLL - std::list<QPDFOutlineObjectHelper> getOutlinesForPage(QPDFObjGen const&); + std::vector<QPDFOutlineObjectHelper> getOutlinesForPage(QPDFObjGen const&); class Accessor { @@ -95,11 +95,11 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper Members(); Members(Members const&); - std::list<QPDFOutlineObjectHelper> outlines; + std::vector<QPDFOutlineObjectHelper> outlines; std::set<QPDFObjGen> seen; QPDFObjectHandle dest_dict; PointerHolder<QPDFNameTreeObjectHelper> names_dest; - std::map<QPDFObjGen, std::list<QPDFOutlineObjectHelper> > by_page; + std::map<QPDFObjGen, std::vector<QPDFOutlineObjectHelper> > by_page; }; PointerHolder<Members> m; diff --git a/include/qpdf/QPDFOutlineObjectHelper.hh b/include/qpdf/QPDFOutlineObjectHelper.hh index 9063b86f..a97cf126 100644 --- a/include/qpdf/QPDFOutlineObjectHelper.hh +++ b/include/qpdf/QPDFOutlineObjectHelper.hh @@ -24,7 +24,7 @@ #include <qpdf/QPDFObjectHelper.hh> #include <qpdf/QPDFObjGen.hh> -#include <list> +#include <vector> class QPDFOutlineDocumentHelper; @@ -55,7 +55,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper // Return children as a list. QPDF_DLL - std::list<QPDFOutlineObjectHelper> getKids(); + std::vector<QPDFOutlineObjectHelper> getKids(); // Return the destination, regardless of whether it is named or // explicit and whether it is directly provided or in a GoTo @@ -113,7 +113,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper QPDFOutlineDocumentHelper& dh; PointerHolder<QPDFOutlineObjectHelper> parent; - std::list<QPDFOutlineObjectHelper> kids; + std::vector<QPDFOutlineObjectHelper> kids; }; PointerHolder<Members> m; diff --git a/libqpdf/QPDFOutlineDocumentHelper.cc b/libqpdf/QPDFOutlineDocumentHelper.cc index 411ccf34..b736ff08 100644 --- a/libqpdf/QPDFOutlineDocumentHelper.cc +++ b/libqpdf/QPDFOutlineDocumentHelper.cc @@ -42,7 +42,7 @@ QPDFOutlineDocumentHelper::hasOutlines() return ! this->m->outlines.empty(); } -std::list<QPDFOutlineObjectHelper> +std::vector<QPDFOutlineObjectHelper> QPDFOutlineDocumentHelper::getTopLevelOutlines() { return this->m->outlines; @@ -59,19 +59,19 @@ QPDFOutlineDocumentHelper::initializeByPage() QPDFOutlineObjectHelper oh = queue.front(); queue.pop_front(); this->m->by_page[oh.getDestPage().getObjGen()].push_back(oh); - std::list<QPDFOutlineObjectHelper> kids = oh.getKids(); + std::vector<QPDFOutlineObjectHelper> kids = oh.getKids(); queue.insert(queue.end(), kids.begin(), kids.end()); } } -std::list<QPDFOutlineObjectHelper> +std::vector<QPDFOutlineObjectHelper> QPDFOutlineDocumentHelper::getOutlinesForPage(QPDFObjGen const& og) { if (this->m->by_page.empty()) { initializeByPage(); } - std::list<QPDFOutlineObjectHelper> result; + std::vector<QPDFOutlineObjectHelper> result; if (this->m->by_page.count(og)) { result = this->m->by_page[og]; diff --git a/libqpdf/QPDFOutlineObjectHelper.cc b/libqpdf/QPDFOutlineObjectHelper.cc index 6cdd182e..c06c63d8 100644 --- a/libqpdf/QPDFOutlineObjectHelper.cc +++ b/libqpdf/QPDFOutlineObjectHelper.cc @@ -45,7 +45,7 @@ QPDFOutlineObjectHelper::getParent() return this->m->parent; } -std::list<QPDFOutlineObjectHelper> +std::vector<QPDFOutlineObjectHelper> QPDFOutlineObjectHelper::getKids() { return this->m->kids; diff --git a/manual/qpdf-manual.xml b/manual/qpdf-manual.xml index d991a611..d5ad6466 100644 --- a/manual/qpdf-manual.xml +++ b/manual/qpdf-manual.xml @@ -4316,6 +4316,16 @@ print "\n"; </listitem> <listitem> <para> + Change + <function>QPDFOutlineDocumentHelper::getTopLevelOutlines</function> + and <function>QPDFOutlineObjectHelper::getKids</function> to + return a <type>std::vector</type> instead of a + <type>std::list</type> of + <classname>QPDFOutlineObjectHelper</classname> objects. + </para> + </listitem> + <listitem> + <para> When <command>qpdf --check</command> or <command>qpdf --check-linearization</command> encounters a file with linearization warnings but not errors, it now properly exits diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index da37ac25..a0f7f7ea 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -3493,9 +3493,9 @@ static void do_json_pages(QPDF& pdf, Options& o, JSON& j) "label", pldh.getLabelForPage(pageno).getJSON()); JSON j_outlines = j_page.addDictionaryMember( "outlines", JSON::makeArray()); - std::list<QPDFOutlineObjectHelper> outlines = + std::vector<QPDFOutlineObjectHelper> outlines = odh.getOutlinesForPage(page.getObjGen()); - for (std::list<QPDFOutlineObjectHelper>::iterator oiter = + for (std::vector<QPDFOutlineObjectHelper>::iterator oiter = outlines.begin(); oiter != outlines.end(); ++oiter) { @@ -3543,10 +3543,10 @@ static void do_json_page_labels(QPDF& pdf, Options& o, JSON& j) } static void add_outlines_to_json( - std::list<QPDFOutlineObjectHelper> outlines, JSON& j, + std::vector<QPDFOutlineObjectHelper> outlines, JSON& j, std::map<QPDFObjGen, int>& page_numbers) { - for (std::list<QPDFOutlineObjectHelper>::iterator iter = outlines.begin(); + for (std::vector<QPDFOutlineObjectHelper>::iterator iter = outlines.begin(); iter != outlines.end(); ++iter) { QPDFOutlineObjectHelper& ol = *iter; diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index 7aed39ba..c6ddd715 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -1805,9 +1805,9 @@ void runtest(int n, char const* filename1, char const* arg2) for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin(); iter != pages.end(); ++iter, ++pageno) { - std::list<QPDFOutlineObjectHelper> outlines = + std::vector<QPDFOutlineObjectHelper> outlines = odh.getOutlinesForPage((*iter).getObjectHandle().getObjGen()); - for (std::list<QPDFOutlineObjectHelper>::iterator oiter = + for (std::vector<QPDFOutlineObjectHelper>::iterator oiter = outlines.begin(); oiter != outlines.end(); ++oiter) { |