aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2020-10-16 20:35:18 +0200
committerJay Berkenbilt <ejb@ql.org>2020-10-16 23:15:39 +0200
commit18b34a564906c7ef36daefab081b44ebfd9ee64b (patch)
treeebbbd6805f2efa41e80897f338e4bbf8ca366e36
parent9a4d3534a10ce1984567a4f79b70cfa2aa024676 (diff)
downloadqpdf-18b34a564906c7ef36daefab081b44ebfd9ee64b.tar.zst
InputSource::unreadCh -- only unread most recently read character
This is all that ever worked. The test suite was trying to do something different from ClosedFileInputSource.
-rw-r--r--TODO6
-rw-r--r--include/qpdf/InputSource.hh3
-rw-r--r--libtests/closed_file_input_source.cc4
3 files changed, 11 insertions, 2 deletions
diff --git a/TODO b/TODO
index 05d497e4..cbd317e8 100644
--- a/TODO
+++ b/TODO
@@ -315,6 +315,12 @@ I find it useful to make reference to them in this list
* Investigate whether there is a way to automate the memory checker
tests for Windows.
+ * Part of closed_file_input_source.cc is disabled on Windows because
+ of odd failures. It might be worth investigating so we can fully
+ exercise this in the test suite. That said, ClosedFileInputSource
+ is exercised elsewhere in qpdf's test suite, so this is not that
+ pressing.
+
* Support user-pluggable stream filters. This would enable external
code to provide interpretation for filters that are missing from
qpdf. Make it possible for user-provided filters to override
diff --git a/include/qpdf/InputSource.hh b/include/qpdf/InputSource.hh
index 896a2559..8850828d 100644
--- a/include/qpdf/InputSource.hh
+++ b/include/qpdf/InputSource.hh
@@ -83,6 +83,9 @@ class QPDF_DLL_CLASS InputSource
virtual void seek(qpdf_offset_t offset, int whence) = 0;
virtual void rewind() = 0;
virtual size_t read(char* buffer, size_t length) = 0;
+
+ // Note: you can only unread the character you just read. The
+ // specific character is ignored by some implementations.
virtual void unreadCh(char ch) = 0;
protected:
diff --git a/libtests/closed_file_input_source.cc b/libtests/closed_file_input_source.cc
index 7309ca31..f3e4f2ac 100644
--- a/libtests/closed_file_input_source.cc
+++ b/libtests/closed_file_input_source.cc
@@ -38,9 +38,9 @@ void do_tests(InputSource* is)
is->seek(521, SEEK_SET);
is->read(b, 1);
#else
- is->unreadCh('Q');
+ is->unreadCh('\n');
check("read unread character", 1 == is->read(b, 1));
- check("got character", 'Q' == b[0]);
+ check("got character", '\n' == b[0]);
#endif
check("last offset after read unread", 521 == is->getLastOffset());
is->seek(0, SEEK_END);