diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | README-maintainer | 2 | ||||
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | include/qpdf/QPDF.hh | 2 | ||||
-rw-r--r-- | libqpdf/QPDF_Real.cc | 25 | ||||
-rw-r--r-- | libqpdf/QUtil.cc | 12 | ||||
-rw-r--r-- | libtests/json.cc | 6 | ||||
-rw-r--r-- | qpdf/qtest/qpdf.test | 1 |
8 files changed, 53 insertions, 6 deletions
@@ -1,3 +1,8 @@ +2019-03-11 Jay Berkenbilt <ejb@ql.org> + + * JSON serialization: add missing leading 0 to decimal values + between -1 and 1. Fixes #308. + 2019-02-01 Jay Berkenbilt <ejb@ql.org> * 8.4.0: release diff --git a/README-maintainer b/README-maintainer index ec257178..4b47a809 100644 --- a/README-maintainer +++ b/README-maintainer @@ -129,7 +129,7 @@ gpg --detach-sign --armor qpdf-$version.tar.gz \rm -f *.{md5,sha1,sha512} files=(*) for i in md5 sha1 sha512; do - ${i}sum $files >| qpdf-$version.$i + ${i}sum ${files[*]} >| qpdf-$version.$i gpg --clearsign --armor qpdf-$version.$i mv qpdf-$version.$i.asc qpdf-$version.$i done @@ -1,3 +1,9 @@ +Before Next Release +=================== + + * Make sure it is clear to downloaders where they can find my public + key for verifying downloads. + Soon ==== diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 634c9bd1..286d305b 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -30,8 +30,10 @@ #include <map> #include <list> #include <iostream> +#include <vector> #include <qpdf/QPDFExc.hh> +#include <qpdf/QPDFObjectHandle.hh> #include <qpdf/QPDFObjGen.hh> #include <qpdf/QPDFXRefEntry.hh> #include <qpdf/QPDFObjectHandle.hh> diff --git a/libqpdf/QPDF_Real.cc b/libqpdf/QPDF_Real.cc index b28c2f70..b4c8283f 100644 --- a/libqpdf/QPDF_Real.cc +++ b/libqpdf/QPDF_Real.cc @@ -25,7 +25,30 @@ QPDF_Real::unparse() JSON QPDF_Real::getJSON() { - return JSON::makeNumber(this->val); + // While PDF allows .x or -.x, JSON does not. Rather than + // convering from string to double and back, just handle this as a + // special case for JSON. + std::string result; + if (this->val.length() == 0) + { + // Can't really happen... + result = "0"; + } + else if (this->val.at(0) == '.') + { + result = "0" + this->val; + } + else if ((this->val.length() >= 2) && + (this->val.at(0) == '-') && + (this->val.at(1) == '.')) + { + result = "-0." + this->val.substr(2); + } + else + { + result = this->val; + } + return JSON::makeNumber(result); } QPDFObject::object_type_e diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 58646ade..7ea3f5e7 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -529,7 +529,9 @@ QUtil::hex_decode(std::string const& input) void QUtil::binary_stdout() { -#ifdef _WIN32 +#if defined(_WIN32) && defined(__BORLANDC__) + setmode(_fileno(stdout), _O_BINARY); +#elif defined(_WIN32) _setmode(_fileno(stdout), _O_BINARY); #endif } @@ -537,7 +539,9 @@ QUtil::binary_stdout() void QUtil::binary_stdin() { -#ifdef _WIN32 +#if defined(_WIN32) && defined(__BORLANDC__) + setmode(_fileno(stdin), _O_BINARY); +#elif defined(_WIN32) _setmode(_fileno(stdin), _O_BINARY); #endif } @@ -918,7 +922,9 @@ QUtil::read_lines_from_file(std::istream& in) int QUtil::strcasecmp(char const *s1, char const *s2) { -#ifdef _WIN32 +#if defined(_WIN32) && defined(__BORLANDC__) + return stricmp(s1, s2); +#elif defined(_WIN32) return _stricmp(s1, s2); #else return ::strcasecmp(s1, s2); diff --git a/libtests/json.cc b/libtests/json.cc index 1a9123ad..e3086c18 100644 --- a/libtests/json.cc +++ b/libtests/json.cc @@ -3,7 +3,7 @@ #include <iostream> #include <assert.h> -static void check(JSON& j, std::string const& exp) +static void check(JSON const& j, std::string const& exp) { if (exp != j.unparse()) { @@ -69,6 +69,10 @@ static void test_main() " ],\n" " \"yes\": false\n" "}"); + check(QPDFObjectHandle::newReal("0.12").getJSON(), "0.12"); + check(QPDFObjectHandle::newReal(".34").getJSON(), "0.34"); + check(QPDFObjectHandle::newReal("-0.56").getJSON(), "-0.56"); + check(QPDFObjectHandle::newReal("-.78").getJSON(), "-0.78"); } static void check_schema(JSON& obj, JSON& schema, bool exp, diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index b6b33977..e1da340a 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -1675,6 +1675,7 @@ $n_tests += 4; for (my $i = 1; $i <= 201; ++$i) { open(F, sprintf(">%03d-kfo.pdf", $i)) or die; + binmode F; print F $content; close(F); } |