aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF_Real.cc25
-rw-r--r--libqpdf/QUtil.cc12
2 files changed, 33 insertions, 4 deletions
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);