aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/yawa.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/yawa.c b/src/yawa.c
index d6219e6..7d67fac 100644
--- a/src/yawa.c
+++ b/src/yawa.c
@@ -61,7 +61,6 @@ parse_opt (int key, char *arg, struct argp_state *state)
fprintf(stderr, "No digits were found\n");
exit(-2);
}
-
break;
case 'c':
arguments->clear = true;
@@ -92,7 +91,19 @@ parse_opt (int key, char *arg, struct argp_state *state)
break;
case 'A':
arguments->alpha = true;
- arguments->alpha_amount = atoi(arg);
+ val = strtol(arg, &endptr, 10);
+ arguments->alpha_amount = (int)val;
+
+ if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
+ || (errno != 0 && val == 0)) {
+ perror("strtol");
+ exit(-2);
+ }
+
+ if (endptr == arg) {
+ fprintf(stderr, "No digits were found\n");
+ exit(-2);
+ }
break;
default:
return ARGP_ERR_UNKNOWN;