Return values of strcmp

Thu May 14 15:30:00 GMT 2009


I am writing a tiny implementation of glibc in asm x86 and I have a
question about return values of strcmp.

FreeBSD manpages tells us this:
     The strcmp() and strncmp() return an integer greater than, equal to, or
     less than 0, according as the string s1 is greater than, equal to, or
     less than the string s2.

My implementation returns, -1, 0 or 1.
My question is simple: Is this an acceptable solution ?

P.S.: It technically works (Firefox, xeyes, etc...) but I am wondering
if it corresponds to what strcmp has been originally created for.

Thank you,
Arnaud Granal

More information about the Libc-help mailing list