Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: [Patch] strcmp
Home

[Freeciv-Dev] Re: [Patch] strcmp

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Petr Baudis <pasky@xxxxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] strcmp
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 11 Feb 2002 20:59:42 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Feb 11, 2002 at 08:53:21PM +0100, Petr Baudis wrote:
> Dear diary, on Mon, Feb 11, 2002 at 08:21:43PM CET, I got a letter,
> where Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> told me, that...
> > The return values of str(n)cmp and mystr(n)casecmp are used as
> > boolean. This is bad. Attached patch fixes this.
> 
> This is bad. str[n]cmp() returns pointer, thus first you have to compare it
> against NULL and second IIRC we don't make explicit compares against NULLs for
> pointer return values.

We must speak about different strcmps. From the manpage:

       int strcmp(const char *s1, const char *s2);
       int strncmp(const char *s1, const char *s2, size_t n);

RETURN VALUE
       The strcmp() and strncmp() functions return an integer less
       than, equal to, or greater than zero if s1 (or the first n
       bytes thereof) is found, respectively, to be less than, to
       match, or be greater than s2.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "Heuer's Law: Any feature is a bug unless it can be turned off."


[Prev in Thread] Current Thread [Next in Thread]