MCPcopy Create free account
hub / github.com/coreutils/coreutils / human_numcompare

Function human_numcompare

src/sort.c:2088–2099  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2086 <none/unknown> < K/k < M < G < T < P < E < Z < Y < R < Q */
2087
2088ATTRIBUTE_PURE
2089static int
2090human_numcompare (char const *a, char const *b)
2091{
2092 while (blanks[to_uchar (*a)])
2093 a++;
2094 while (blanks[to_uchar (*b)])
2095 b++;
2096
2097 int diff = find_unit_order (a) - find_unit_order (b);
2098 return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep));
2099}
2100
2101/* Compare strings A and B as numbers without explicitly converting them to
2102 machine numbers. Comparatively slow for short strings, but asymptotically

Callers 1

keycompareFunction · 0.85

Calls 3

to_ucharFunction · 0.85
find_unit_orderFunction · 0.85
strnumcmpFunction · 0.85

Tested by

no test coverage detected