From 791e0db7627e57d81076606e63786383f80219a3 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 13 Jan 2018 20:05:13 -0500 Subject: [PATCH] Allow trailing . in numeric token (fixes #165) --- ChangeLog | 7 +++++-- libqpdf/QUtil.cc | 7 +------ qpdf/qtest/qpdf/good10.out | 10 +++++++--- qpdf/qtest/qpdf/good10.pdf | 2 +- qpdf/qtest/qpdf/good10.qdf | 4 ++++ 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14a9b92..76cbef3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,13 @@ 2018-01-13 Jay Berkenbilt + * Fix lexical error: the PDF specification allows floating point + numbers to end with ".". Fixes #165. + * Fix link order in the build to avoid conflicts when building - from source while an older version of qpdf is installed. + from source while an older version of qpdf is installed. Fixes #158. * Add support for TIFF predictor for LZW and Flate streams. Now - all predictor functions are supported. + all predictor functions are supported. Fixes #171. 2017-12-25 Jay Berkenbilt diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 32855bb..9337456 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -558,7 +558,7 @@ QUtil::is_digit(char ch) bool QUtil::is_number(char const* p) { - // ^[\+\-]?(\.\d+|\d+(\.\d+)?)$ + // ^[\+\-]?(\.\d*|\d+(\.\d*)?)$ if (! *p) { return false; @@ -578,11 +578,6 @@ QUtil::is_number(char const* p) // only one dot return false; } - if (! *(p+1)) - { - // dot can't be last - return false; - } found_dot = true; } else if (QUtil::is_digit(*p)) diff --git a/qpdf/qtest/qpdf/good10.out b/qpdf/qtest/qpdf/good10.out index 0ae0805..6f76c52 100644 --- a/qpdf/qtest/qpdf/good10.out +++ b/qpdf/qtest/qpdf/good10.out @@ -1,8 +1,12 @@ /QTest is direct and has type array (8) -/QTest is an array with 3 items +/QTest is an array with 7 items item 0 is direct item 1 is direct item 2 is indirect -unparse: [ 1 (2) 8 0 R ] -unparseResolved: [ 1 (2) 8 0 R ] + item 3 is direct + item 4 is direct + item 5 is direct + item 6 is direct +unparse: [ 1 (2) 8 0 R 0.0 -0.0 0. -0. ] +unparseResolved: [ 1 (2) 8 0 R 0.0 -0.0 0. -0. ] test 1 done diff --git a/qpdf/qtest/qpdf/good10.pdf b/qpdf/qtest/qpdf/good10.pdf index 13a8810..a6eb85d 100644 --- a/qpdf/qtest/qpdf/good10.pdf +++ b/qpdf/qtest/qpdf/good10.pdf @@ -73,7 +73,7 @@ xref trailer << /Size 7 /Root 1 0 R - /QTest [1 (2) 8 0 R] + /QTest [1 (2) 8 0 R 0.0 -0.0 0. -0.] >> startxref 556 diff --git a/qpdf/qtest/qpdf/good10.qdf b/qpdf/qtest/qpdf/good10.qdf index 0835c51..957168c 100644 --- a/qpdf/qtest/qpdf/good10.qdf +++ b/qpdf/qtest/qpdf/good10.qdf @@ -96,6 +96,10 @@ trailer << 1 (2) null + 0.0 + -0.0 + 0. + -0. ] /Root 1 0 R /Size 8 -- libgit2 0.21.4