Ángel Ortega


ex-writer, ex-programmer, ex-musician, ex-illustrator
ex-escritor, ex-programador, ex-músico, ex-dibujante
1 ★ 0 ↺

Ángel Ortega »

Linux's strcmp() For The m68k Has Always Been Broken:

The m68 hand-written assembler version of strcmp() has always been broken: it returns the difference between the first non-matching byte done as a 8-bit subtraction.

That is _almost_ right, but is broken for the overflow case. The strcmp() function should indeed return the sign of the difference between the first byte that differs, but the subtraction needs to be done in a wider type than 'char'. Otherwise the ordering isn't actually stable.