🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.objective-c
Article #380

What to believe in <objc/hash.h>?

#380
From: bazad
Date: Sat, 20 Nov 2004 11:49
44 lines
2055 bytes
GNU objc/hash.h contains the following text:

/*
 * This data type is the function that compares two hash keys and returns an
 * integer greater than, equal to, or less than 0, according as the first
 * parameter is lexicographically greater than, equal to, or less than the
 * second. 
 */

typedef int (*compare_func_type)(const void *, const void *);

Later on you can find an implementation of this function type.

/* Compare two strings.  */
static inline int 
compare_strings (const void *k1, const void *k2)
{
  if (k1 == k2)
    return 1;
  else if (k1 == 0 || k2 == 0)
    return 0;
  else
    return !strcmp (k1, k2);
}

Now, I an not an expert in C and Objective-C, but I can say that the
original description is not followed at all!

The actual signauture is something like:
return 1 if data is equal
return 0 if data is not equal

Pointers follow the same rule.  It is even more descriptive:

/* Compare two pointers for equality.  */
static inline int 
compare_ptrs (const void *k1, const void *k2)
{
  return !(k1 - k2);
}

I expected better from the core level of the GNU code.

Needless to say I wasted lots and lots of time...
Technical Details
Message-ID: <1100951355.thnHiFaEixBecttg3/J4Ug@teranews>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed-east.nntpserver.com!nntpserver.com!sam.nntpserver.com.POSTED!3e19b6ab!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 1111a3,db1d47314ce1935c,start
X-Google-Thread: f65d0,db1d47314ce1935c,start
X-Google-Attributes: gid1111a3,gidf65d0,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed-east.nntpserver.com!nntpserver.com!sam.nntpserver.com.POSTED!3e19b6ab!not-for-mail
Followup-To: gnu.gcc
Sender: sgnezdov@crow.birds
Newsgroups: comp.lang.objective-c,gnu.gcc
Subject: What to believe in <objc/hash.h>?
From: bazad <nobody@noreply.not>
Lines: 44
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
NNTP-Posting-Date: Sat, 20 Nov 2004 06:49:14 EST
Message-ID: <1100951355.thnHiFaEixBecttg3/J4Ug@teranews>
X-Abuse-Report: http://www.usenetabuse.com
X-Orginal-Message-ID: <86zn1clozf.fsf@crow.birds>
Date: 20 Nov 2004 03:49:24 -0800