diff options
author | Hampus <hampus@hampusmat.com> | 2022-01-05 21:45:49 +0100 |
---|---|---|
committer | Hampus <hampus@hampusmat.com> | 2022-01-05 21:45:49 +0100 |
commit | dc78467ebc7df9bfad81ed6e30f74139440ab159 (patch) | |
tree | ccabc47e358bfe09fb71aca6352f499713e24479 | |
parent | 6b1f6cf3b7685eed5fb9e24b18c479d842c4043c (diff) |
fix: add better number handling
-rw-r--r-- | src/mazerator.c | 11 | ||||
-rw-r--r-- | src/utils.c | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/mazerator.c b/src/mazerator.c index 8224fb9..593d518 100644 --- a/src/mazerator.c +++ b/src/mazerator.c @@ -72,6 +72,9 @@ int main(int argc, char *argv[]) if (err != NULL) optarg_error(arg, err); + if (maze_width == 0) + optarg_error(arg, "It should not be 0"); + break; case 'h': maze_height = str_to_uint(optarg, &err); @@ -79,6 +82,9 @@ int main(int argc, char *argv[]) if (err != NULL) optarg_error(arg, err); + if (maze_height == 0) + optarg_error(arg, "It should not be 0"); + break; case 'x': start_x = malloc_s(sizeof(unsigned int *)); @@ -106,6 +112,9 @@ int main(int argc, char *argv[]) if (err != NULL) optarg_error(arg, err); + if (*seed == 0) + optarg_error(arg, "It should not be 0"); + break; case 0: printf("Usage: %s [OPTION]...\n\n" @@ -119,7 +128,7 @@ int main(int argc, char *argv[]) " -W, --wall WALL Single character used as maze walls " "(Default: '█')\n" " -s, --seed SEED The randomization seed used for maze " - "generation (Any number)\n" + "generation\n" " --help Displays usage information\n", argv[0]); exit(0); diff --git a/src/utils.c b/src/utils.c index 69ce55d..da48ef6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -33,7 +33,7 @@ unsigned int str_to_uint(char *str, char **err) { if (*str == '-') { - *err = "Not greater than 0"; + *err = "Less than 0"; return 0; } |