This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Return values of strcmp


On Thursday 14 May 2009 11:30:47 Arnaud GRANAL wrote:
> 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:
> RETURN VALUES
>      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.

the acceptable solution is what POSIX dictates:
http://www.opengroup.org/onlinepubs/9699919799/functions/strcmp.html
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]