summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2010-06-29 05:00:06 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2010-06-29 05:00:06 +0000
commite0a3b8e51d24b584910ba4006b8df28b77437df3 (patch)
tree026097017d91e62df5ed897e40c294211074812c
parente6720e42d915e2cc7d989e9844bbff3b29e6d76f (diff)
isdigit() is more readable than comparing ascii codes
-rw-r--r--usr.bin/radioctl/radioctl.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.bin/radioctl/radioctl.c b/usr.bin/radioctl/radioctl.c
index c6dbd414d79..2e6f971d2c0 100644
--- a/usr.bin/radioctl/radioctl.c
+++ b/usr.bin/radioctl/radioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radioctl.c,v 1.16 2008/10/16 14:32:57 jmc Exp $ */
+/* $OpenBSD: radioctl.c,v 1.17 2010/06/29 05:00:05 tedu Exp $ */
/* $RuOBSD: radioctl.c,v 1.4 2001/10/20 18:09:10 pva Exp $ */
/*
@@ -37,6 +37,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <ctype.h>
#define RADIO_ENV "RADIODEVICE"
#define RADIODEVICE "/dev/radio"
@@ -429,7 +430,7 @@ parse_opt(char *s, struct opt_t *o) {
slen -= ++optlen;
- if ((topt = (char *)malloc(optlen)) == NULL) {
+ if ((topt = malloc(optlen)) == NULL) {
warn("memory allocation error");
return 0;
}
@@ -465,11 +466,11 @@ parse_opt(char *s, struct opt_t *o) {
break;
case 'o':
if (strncmp(topt, offchar,
- slen > OFFCHAR_LEN ? slen : OFFCHAR_LEN) == 0)
+ slen > OFFCHAR_LEN ? slen : OFFCHAR_LEN) == 0)
o->value = 0;
else if (strncmp(topt, onchar,
- slen > ONCHAR_LEN ? slen : ONCHAR_LEN) == 0)
- o->value = 1;
+ slen > ONCHAR_LEN ? slen : ONCHAR_LEN) == 0)
+ o->value = 1;
break;
case 'u':
if (strncmp(topt, "up", slen > 2 ? slen : 2) == 0)
@@ -480,7 +481,7 @@ parse_opt(char *s, struct opt_t *o) {
o->value = 0;
break;
default:
- if (*topt > 47 && *topt < 58)
+ if (isdigit(*topt))
o->value = str_to_int(topt, o->option);
break;
}