| 6335 | } |
| 6336 | |
| 6337 | int SortUDF(const void *a1, const void *a2) |
| 6338 | // See comments in prior function for details. |
| 6339 | { |
| 6340 | if (!g_SortFuncResult || g_SortFuncResult == EARLY_EXIT) |
| 6341 | return 0; |
| 6342 | |
| 6343 | // The following isn't necessary because by definition, the current thread isn't paused because it's the |
| 6344 | // thing that called the sort in the first place. |
| 6345 | //g_script.UpdateTrayIcon(); |
| 6346 | |
| 6347 | LPTSTR aStr1 = *(LPTSTR *)a1; |
| 6348 | LPTSTR aStr2 = *(LPTSTR *)a2; |
| 6349 | ExprTokenType param[] = { aStr1, aStr2, __int64(aStr2 - aStr1) }; |
| 6350 | __int64 i64; |
| 6351 | g_SortFuncResult = CallMethod(g_SortFunc, g_SortFunc, nullptr, param, _countof(param), &i64); |
| 6352 | // An alternative to g_SortFuncResult using 'throw' to abort qsort() produced slightly |
| 6353 | // smaller code, but in release builds the program crashed with code 0xC0000409 and the |
| 6354 | // catch() block never executed. |
| 6355 | |
| 6356 | int returned_int; |
| 6357 | if (i64) // Maybe there's a faster/better way to do these checks. Can't simply typecast to an int because some large positives wrap into negative, maybe vice versa. |
| 6358 | returned_int = i64 < 0 ? -1 : 1; |
| 6359 | else // The result was 0 or "". Since returning 0 would make the results less predictable and doesn't seem to have any benefit, |
| 6360 | returned_int = aStr1 < aStr2 ? -1 : 1; // use the relative positions of the items as a tie-breaker. |
| 6361 | |
| 6362 | return returned_int; |
| 6363 | } |
| 6364 | |
| 6365 | |
| 6366 |
nothing calls this directly
no test coverage detected