From d5bfd49cb2c9e62557a06dee3c4e33fc0c091170 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 4 Feb 2018 13:51:54 -0500 Subject: [PATCH] Remove use of std::abs (fixes #172) Different compilers want different choices of headers for std::abs. It's easier to just to not use it. --- libqpdf/Pl_PNGFilter.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libqpdf/Pl_PNGFilter.cc b/libqpdf/Pl_PNGFilter.cc index 174e0b51..217a14fa 100644 --- a/libqpdf/Pl_PNGFilter.cc +++ b/libqpdf/Pl_PNGFilter.cc @@ -3,7 +3,11 @@ #include #include #include -#include + +static int abs_diff(int a, int b) +{ + return a > b ? a - b : b - a; +} Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next, action_e action, unsigned int columns, @@ -218,9 +222,9 @@ int Pl_PNGFilter::PaethPredictor(int a, int b, int c) { int p = a + b - c; - int pa = std::abs(p - a); - int pb = std::abs(p - b); - int pc = std::abs(p - c); + int pa = abs_diff(p, a); + int pb = abs_diff(p, b); + int pc = abs_diff(p, c); if (pa <= pb && pa <= pc) {