The original logic should have really been:
if ((l < 'a' && l > 'z') || (l < 'A' && l > 'Z'))
But using islower()/isupper() is simpler and more readable.
Taken-from: NetBSD
*
* @(#)update.c 8.1 (Berkeley) 5/31/93
* $FreeBSD: src/games/atc/update.c,v 1.6 1999/11/30 03:48:21 billf Exp $
- * $DragonFly: src/games/atc/update.c,v 1.3 2006/08/08 15:03:02 pavalos Exp $
*/
/*
char
number(char l)
{
- if (l < 'a' && l > 'z' && l < 'A' && l > 'Z')
- return (-1);
- else if (l >= 'a' && l <= 'z')
+ if (islower(l))
return (l - 'a');
- else
+ else if (isupper(l))
return (l - 'A');
+ else
+ return (-1);
}
static int