Skip to content

Commit

Permalink
games/atc: Fix a logic bug.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Sascha Wildner committed Feb 7, 2013
1 parent 6a8649c commit a33bbb6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions games/atc/update.c
Expand Up @@ -31,7 +31,6 @@
*
* @(#)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 $
*/

/*
Expand Down Expand Up @@ -253,12 +252,12 @@ name(const PLANE *p)
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
Expand Down

0 comments on commit a33bbb6

Please sign in to comment.