diff options
-rw-r--r-- | analyzer/ppmhist.c | 44 | ||||
-rw-r--r-- | doc/HISTORY | 3 |
2 files changed, 28 insertions, 19 deletions
diff --git a/analyzer/ppmhist.c b/analyzer/ppmhist.c index c4ab3581..62345fa1 100644 --- a/analyzer/ppmhist.c +++ b/analyzer/ppmhist.c @@ -120,25 +120,6 @@ cmpUint(unsigned int const a, #ifndef LITERAL_FN_DEF_MATCH -static qsort_comparison_fn countcompare; -#endif - - -static int -countcompare(const void * const a, - const void * const b) { -/*---------------------------------------------------------------------------- - This is a 'qsort' collation function. ------------------------------------------------------------------------------*/ - const struct colorhist_item * const histItem1P = a; - const struct colorhist_item * const histItem2P = b; - - return cmpUint(histItem2P->value, histItem1P->value); -} - - - -#ifndef LITERAL_FN_DEF_MATCH static qsort_comparison_fn rgbcompare; #endif @@ -167,6 +148,31 @@ rgbcompare(const void * const a, +#ifndef LITERAL_FN_DEF_MATCH +static qsort_comparison_fn countcompare; +#endif + + +static int +countcompare(const void * const a, + const void * const b) { +/*---------------------------------------------------------------------------- + This is a 'qsort' collation function. +-----------------------------------------------------------------------------*/ + const struct colorhist_item * const histItem1P = a; + const struct colorhist_item * const histItem2P = b; + + int const countComparison = cmpUint(histItem2P->value, histItem1P->value); + + if (countComparison == 0) { + /* Counts are the same; use RGB secondary sort */ + return rgbcompare(a, b); + } else + return countComparison; +} + + + static pixval universalMaxval(pixval const maxval, int const format) { diff --git a/doc/HISTORY b/doc/HISTORY index b73c1938..a4783184 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -6,6 +6,9 @@ CHANGE HISTORY not yet BJH Release 10.88.00 + ppmhist: sort secondarily by RGB with -sort=frequency, so + output is repeatable. + pnmtorle, rletopnm: fix wild pointer dereference when memory allocation fails. Always broken (programs were added to Netpbm in Release 9.0 (April 2000). |