ref: 6a68c2399bb251ec4d1c28a103272fc0cb7b0dbe
parent: 12b6d1368404f9297bd4637372220b0cd82a2ea0
author: cancel <cancel@cancel.fm>
date: Fri Sep 13 06:02:09 EDT 2019
Change --seed to use atoi, change init_seed to int This avoids using `long` in orca-c, which had previous been avoided. Using `long` comes with some baggage. It would be best to avoid it where possible, especially since there are no other uses of it orca-c. If explicit sizes are needed, use the types from stdint.h. The only reason `int` is used for argument handling in orca-c's TUI is that `atoi` requires it. `atol` doesn't provide any advantage over `atoi`, except to allow the `--seed` option to be larger on some platforms and some configurations. But I think it's better to have consistent argument handling, and have `--seed` always have a range of `0..INT_MAX`, which is going to be signed 32-bit max on almost every platform, unlike `long`. This change also allows init_seed to be set to 0, where it previously was not allowed. The default still remains 1.
--- a/tui_main.c
+++ b/tui_main.c
@@ -1880,7 +1880,7 @@
char const* osc_port = NULL;
bool strict_timing = false;
int init_bpm = 120;
- long init_seed = 1;
+ int init_seed = 1;
int init_grid_dim_y = 25;
int init_grid_dim_x = 57;
Midi_mode midi_mode;
@@ -1930,11 +1930,11 @@
}
} break;
case Argopt_seed: {
- init_seed = atol(optarg);
- if (init_seed < 1) {
+ init_seed = atoi(optarg);
+ if (init_seed < 0 || (init_seed == 0 && strcmp(optarg, "0"))) {
fprintf(stderr,
"Bad seed argument %s.\n"
- "Must be positive integer.\n",
+ "Must be 0 or positive integer.\n",
optarg);
exit(1);
}