diff options
author | Jay Berkenbilt <ejb@ql.org> | 2018-01-29 00:28:45 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2018-02-19 02:18:40 +0100 |
commit | d97474868d7fa6a94bab49d89af5dd82fd5e3a41 (patch) | |
tree | 754e4741adf505081e81a30bcd3c4395acb066f9 /libqpdf/FileInputSource.cc | |
parent | bb9e91adbd75d05d0d60227b2d419d7ee12e1b42 (diff) | |
download | qpdf-d97474868d7fa6a94bab49d89af5dd82fd5e3a41.tar.zst |
Lexer enhancements: EOF, comment, space
Significant enhancements to the lexer to improve EOF handling and to
support comments and spaces as tokens. Various other minor issues were
fixed as well.
Diffstat (limited to 'libqpdf/FileInputSource.cc')
-rw-r--r-- | libqpdf/FileInputSource.cc | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libqpdf/FileInputSource.cc b/libqpdf/FileInputSource.cc index a1b1ced5..4e4a34bf 100644 --- a/libqpdf/FileInputSource.cc +++ b/libqpdf/FileInputSource.cc @@ -120,15 +120,23 @@ FileInputSource::rewind() size_t FileInputSource::read(char* buffer, size_t length) { - this->last_offset = QUtil::tell(this->file); + this->last_offset = this->tell(); size_t len = fread(buffer, 1, length, this->file); - if ((len == 0) && ferror(this->file)) + if (len == 0) { - throw QPDFExc(qpdf_e_system, - this->filename, "", - this->last_offset, - std::string("read ") + - QUtil::int_to_string(length) + " bytes"); + if (ferror(this->file)) + { + throw QPDFExc(qpdf_e_system, + this->filename, "", + this->last_offset, + std::string("read ") + + QUtil::int_to_string(length) + " bytes"); + } + else if (length > 0) + { + this->seek(0, SEEK_END); + this->last_offset = this->tell(); + } } return len; } |