Closed
Description
The docs for strcmp
say:
Return Values ¶
Returns
-1
ifstring1
is less thanstring2
;1
ifstring1
is greater thanstring2
, and0
if they are equal.Changelog ¶
Version Description 8.2.0 This function now returns -1
or1
, where it previously returned a negative or positive integer.
Problems:
- The "Return Values" part is patentenly not true: https://3v4l.org/CXhkE#v8.2.0
- I believe the "Changelog" is refering to when a string is compared to an empty string: https://3v4l.org/UHXcr
I believe the intended logic here is:
- Attempt to calculate the spread between to strings (unpredictable for large spreads)
- If the strings match except for trailing characters, return the difference in characters
Whatever the logic, it seems like it does not return very predicable results other than being contrasted to 0. Here are some interesting return values: https://3v4l.org/FN86s