From 9ba114c3ad06f0e09c27c5f1af294359acc092bd Mon Sep 17 00:00:00 2001 From: giraffedata Date: Fri, 6 May 2016 01:49:34 +0000 Subject: Remove use of C99 isfinite git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2757 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- analyzer/pnmpsnr.c | 19 +++++++++++++++++-- doc/HISTORY | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/analyzer/pnmpsnr.c b/analyzer/pnmpsnr.c index 19f013a4..1ddefac2 100644 --- a/analyzer/pnmpsnr.c +++ b/analyzer/pnmpsnr.c @@ -2,7 +2,7 @@ * pnmpsnr.c: Compute error (RMSE, PSNR) between images * * - * Derived from pnmpnsmr by Ulrich Hafner, part of his fiasco package, + * Derived from pnmpnsmr by Ullrich Hafner, part of his fiasco package, * On 2001.03.04. * Copyright (C) 1994-2000 Ullrich Hafner @@ -402,6 +402,21 @@ psnrFromSumSqDiff(struct SqDiff const sumSqDiff, +static bool +psnrIsFinite(double const psnr) { + + /* We would just use C standard isfinite(), but that is not standard + before C99. Neither is INFINITY. + + A finite PSNR, in this program, cannot be anywhere near 1,000,000, + because of limits of the program, so we just compare to that. + */ + + return psnr < 1000000.0; +} + + + static void reportPsnrHuman(struct Psnr const psnr, ColorSpace const colorSpace, @@ -417,7 +432,7 @@ reportPsnrHuman(struct Psnr const psnr, pm_asprintf(&label, "%s:", colorSpace.componentName[i]); - if (isfinite(psnr.psnr[i])) + if (psnrIsFinite(psnr.psnr[i])) pm_message(" %-6.6s %.2f dB", label, psnr.psnr[i]); else pm_message(" %-6.6s no difference", label); diff --git a/doc/HISTORY b/doc/HISTORY index 0c054876..d0489ffb 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -49,6 +49,9 @@ not yet BJH Release 10.75.00 Build: Remove use of strndup so it compiles on Mac OS X 10.6. Broken in 10.74. + Build: Remove use of isfinite so it compiles with C89 standard + compiler. + 16.03.27 BJH Release 10.74.00 pbmtext: produce same image when you run pbmtext with -width -- cgit 1.4.1