3 ms·
Plain ASCII is 7-bit so it won't overflow with signed char. There are many extensions that use that extra bit to increase the number of characters, but they are
by pavon 4y ago
Plain ASCII is 7-bit so it won't overflow with signed char. There are many extensions that use that extra bit to increase the number of characters, but they aren't ASCII, they are ISO 8859-*, or ANSI, or UTF-8 etc.
- loeg 4y agoAs the article notes, Linux does not validate strings for 7-bit cleanness, so the routine needs to work on strings that use the high bit.
- layer8 4y agoThe problem is not just that it results in a wrong order for 8-bit encodings, but that it doesn’t result in a well-defined order at all. For example, you get: -2 > 127 > 64 > -2 This can make sorting algorithms loop infinitely or crash.
- koverstreet 4y agoBuggy comparison functions that don't correctly define an ordering is one of my favorite classes of bugs.
- layer8 4y agoIt’s also something that is difficult to unit-test.