Commit d5bfd49cb2c9e62557a06dee3c4e33fc0c091170
1 parent
34a9b835
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.
Showing
1 changed file
with
8 additions
and
4 deletions
libqpdf/Pl_PNGFilter.cc
| ... | ... | @@ -3,7 +3,11 @@ |
| 3 | 3 | #include <stdexcept> |
| 4 | 4 | #include <string.h> |
| 5 | 5 | #include <limits.h> |
| 6 | -#include <algorithm> | |
| 6 | + | |
| 7 | +static int abs_diff(int a, int b) | |
| 8 | +{ | |
| 9 | + return a > b ? a - b : b - a; | |
| 10 | +} | |
| 7 | 11 | |
| 8 | 12 | Pl_PNGFilter::Pl_PNGFilter(char const* identifier, Pipeline* next, |
| 9 | 13 | action_e action, unsigned int columns, |
| ... | ... | @@ -218,9 +222,9 @@ int |
| 218 | 222 | Pl_PNGFilter::PaethPredictor(int a, int b, int c) |
| 219 | 223 | { |
| 220 | 224 | int p = a + b - c; |
| 221 | - int pa = std::abs(p - a); | |
| 222 | - int pb = std::abs(p - b); | |
| 223 | - int pc = std::abs(p - c); | |
| 225 | + int pa = abs_diff(p, a); | |
| 226 | + int pb = abs_diff(p, b); | |
| 227 | + int pc = abs_diff(p, c); | |
| 224 | 228 | |
| 225 | 229 | if (pa <= pb && pa <= pc) |
| 226 | 230 | { | ... | ... |