Browse Source

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.
master
cancel 6 years ago
parent
commit
6a68c2399b
  1. 8
      tui_main.c

8
tui_main.c

@ -1880,7 +1880,7 @@ int main(int argc, char** argv) {
char const* osc_port = NULL; char const* osc_port = NULL;
bool strict_timing = false; bool strict_timing = false;
int init_bpm = 120; int init_bpm = 120;
long init_seed = 1; int init_seed = 1;
int init_grid_dim_y = 25; int init_grid_dim_y = 25;
int init_grid_dim_x = 57; int init_grid_dim_x = 57;
Midi_mode midi_mode; Midi_mode midi_mode;
@ -1930,11 +1930,11 @@ int main(int argc, char** argv) {
} }
} break; } break;
case Argopt_seed: { case Argopt_seed: {
init_seed = atol(optarg); init_seed = atoi(optarg);
if (init_seed < 1) { if (init_seed < 0 || (init_seed == 0 && strcmp(optarg, "0"))) {
fprintf(stderr, fprintf(stderr,
"Bad seed argument %s.\n" "Bad seed argument %s.\n"
"Must be positive integer.\n", "Must be 0 or positive integer.\n",
optarg); optarg);
exit(1); exit(1);
} }

Loading…
Cancel
Save