From 01a21f20276079a41df8242b3ed3d7342b15d31a Mon Sep 17 00:00:00 2001 From: Matthew Wilber Date: Sun, 18 Jan 2004 03:06:59 +0000 Subject: [PATCH] Fixed GetTranslators to return the list of output formats in the order of most capable to least capable instead of before, where the list's order was the reverse of the order in which the translators were loaded. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6125 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/translation/TranslatorRoster.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/kits/translation/TranslatorRoster.cpp b/src/kits/translation/TranslatorRoster.cpp index 22ee1f5017..5b3e7d3a5f 100644 --- a/src/kits/translation/TranslatorRoster.cpp +++ b/src/kits/translation/TranslatorRoster.cpp @@ -632,9 +632,14 @@ BTranslatorRoster::Identify(BPositionIO *inSource, // // Postconditions: // -// Returns: < 0 if a is less desirable than b, -// 0 if a as good as b, -// > 0 if a is more desirable than b +// Returns: +// NOTE: Since qsort sorts lowest to highest, and I want +// the highest quality/capability first, I must do things +// "backwards." +// +// 0 if A and B are equally capable +// -1 if A is more capable than B +// 1 if A is less capable than B // --------------------------------------------------------------- static int compare_data(const void *a, const void *b) @@ -645,8 +650,15 @@ compare_data(const void *a, const void *b) register const translator_info *bi = reinterpret_cast (b); - return static_cast (- ai->quality * ai->capability + - bi->quality * bi->capability); + float acmp, bcmp; + acmp = ai->quality * ai->capability; + bcmp = bi->quality * bi->capability; + if (acmp == bcmp) + return 0; + else if (acmp > bcmp) + return -1; + else + return 1; } // ---------------------------------------------------------------