Permalink
Browse files

games/atc: Fix a logic bug.

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...
1 parent 6a8649c commit a33bbb6c241cbfacccc550489091097ccf58eb41 Sascha Wildner committed Feb 7, 2013
Showing with 4 additions and 5 deletions.
  1. +4 −5 games/atc/update.c
View
@@ -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 $
*/
/*
@@ -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

0 comments on commit a33bbb6

Please sign in to comment.