1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-21 11:13:30 +00:00
freebsd/lib/libmytinfo/compar.c
1994-10-06 23:38:41 +00:00

41 lines
735 B
C

/*
* compar.c
*
* By Ross Ridge
* Public Domain
* 92/06/04 11:36:24
*
*/
#include "defs.h"
#ifdef USE_SCCS_IDS
static const char SCCSid[] = "@(#) mytinfo compar.c 3.3 92/06/04 public domain, By Ross Ridge";
#endif
/* compare two elements a sorted list of pointers to strings */
int
_compar(a, b)
#ifdef USE_ANSIC
void const *a;
void const *b; {
#else
anyptr a, b; {
#endif
register char *aa = **(char ***)a;
register char *bb = **(char ***)b;
/* An optimization trick from C News, compare the first
* two chars of the string here to avoid a the overhead of a
* call to strcmp.
*/
#ifdef __GNUC__
return ((*aa - *bb) ? : strcmp(aa, bb));
#else
if (*aa != *bb)
return *aa - *bb;
return strcmp(aa, bb);
#endif
}