fixes for man page bugs reported by Hugh Redelmeier.
[oss-qm-packages.git] / lib / nstrcmp.c
blob2c78a41f2b52d078b387e67af613a457512c3c63
1 /*
2 * Copyright 1998 by Andi Kleen. Subject to the GPL.
3 * Copyright 2002 by Bruno Hall who contributed a shorter rewrite
4 * which actually works
6 * $Id: nstrcmp.c,v 1.3 2002/12/10 00:37:33 ecki Exp $
7 */
8 #include <ctype.h>
9 #include <stdlib.h>
10 #include "util.h"
13 /* like strcmp(), but knows about numbers */
14 int nstrcmp(const char *a, const char *b)
16 while (*a == *b && !isdigit(*a)) {
17 if (*a++ == 0)
18 return 0;
19 b++;
21 if (isdigit(*a) && isdigit(*b))
22 return atoi(a) - atoi(b);
23 return *(const unsigned char *)a - *(const unsigned char *)b;