diff options
author | Albert Astals Cid <aacid@kde.org> | 2022-08-19 22:20:17 +0200 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2022-08-19 22:20:17 +0200 |
commit | 5bec49749b9a2a9b4779a977f673531b42470264 (patch) | |
tree | 722e2b2a552d60bf7e7939fe553915d4e564e803 | |
parent | 03c7bbd6216cbfac257243b59453084f5f52e354 (diff) |
We can use isnan now
-rw-r--r-- | poppler/Function.cc | 4 | ||||
-rw-r--r-- | poppler/MarkedContentOutputDev.cc | 6 | ||||
-rw-r--r-- | poppler/TextOutputDev.cc | 3 |
3 files changed, 6 insertions, 7 deletions
diff --git a/poppler/Function.cc b/poppler/Function.cc index b97ad71e..043ae8e9 100644 --- a/poppler/Function.cc +++ b/poppler/Function.cc @@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2006, 2008-2010, 2013-2015, 2017-2020 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2008-2010, 2013-2015, 2017-2020, 2022 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com> @@ -463,7 +463,7 @@ void SampledFunction::transform(const double *in, double *out) const // map input values into sample array for (int i = 0; i < m; ++i) { x = (in[i] - domain[i][0]) * inputMul[i] + encode[i][0]; - if (x < 0 || x != x) { // x!=x is a more portable version of isnan(x) + if (x < 0 || std::isnan(x)) { x = 0; } else if (x > sampleSize[i] - 1) { x = sampleSize[i] - 1; diff --git a/poppler/MarkedContentOutputDev.cc b/poppler/MarkedContentOutputDev.cc index 9a6f315b..e3a4cdce 100644 --- a/poppler/MarkedContentOutputDev.cc +++ b/poppler/MarkedContentOutputDev.cc @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright 2013 Igalia S.L. -// Copyright 2018-2020 Albert Astals Cid <aacid@kde.org> +// Copyright 2018-2020, 2022 Albert Astals Cid <aacid@kde.org> // Copyright 2021 Adrian Johnson <ajohnson@redneon.com> // Copyright 2022 Oliver Sander <oliver.sander@tu-dresden.de> // @@ -17,6 +17,7 @@ #include "GfxState.h" #include "GfxFont.h" #include "Annot.h" +#include <cmath> #include <vector> MarkedContentOutputDev::MarkedContentOutputDev(int mcidA, const Object &stmObj) : currentFont(nullptr), currentText(nullptr), mcid(mcidA), pageWidth(0.0), pageHeight(0.0), unicodeMap(nullptr) @@ -181,8 +182,7 @@ void MarkedContentOutputDev::drawChar(GfxState *state, double xx, double yy, dou return; } - // Make a sanity check on character size. Note: (x != x) <-> isnan(x) - if (x1 != x1 || y1 != y1 || w1 != w1 || h1 != h1) { + if (std::isnan(x1) || std::isnan(y1) || std::isnan(w1) || std::isnan(h1)) { return; } diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc index 3ed1c90d..06fc3078 100644 --- a/poppler/TextOutputDev.cc +++ b/poppler/TextOutputDev.cc @@ -2666,8 +2666,7 @@ void TextPage::addChar(const GfxState *state, double x, double y, double dx, dou // throw away chars that aren't inside the page bounds // (and also do a sanity check on the character size) state->transform(x, y, &x1, &y1); - if (x1 + w1 < 0 || x1 > pageWidth || y1 + h1 < 0 || y1 > pageHeight || x1 != x1 || y1 != y1 || // IEEE way of checking for isnan - w1 != w1 || h1 != h1) { + if (x1 + w1 < 0 || x1 > pageWidth || y1 + h1 < 0 || y1 > pageHeight || std::isnan(x1) || std::isnan(y1) || std::isnan(w1) || std::isnan(h1)) { charPos += nBytes; return; } |