[Freeciv-Dev] Re: [Patch] strcmp
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Dear diary, on Mon, Feb 11, 2002 at 08:59:42PM CET, I got a letter,
where Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> told me, that...
> 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.
Oops, shame on me, I managed to mess the things up somewhat in my mind... ;)
Sorry.
--
Petr "Pasky" Baudis
* UN*X programmer && admin * IPv6 guy (XS26 co-coordinator)
* elinks maintainer * FreeCiv AI hacker
* IRCnet operator
.
I love deadlines.
I love the whooshing sound they make as they fly by.
-- Douglas Adams.
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/
|
|