Skip to content

Commit

Permalink
Show error when step size is out of bound
Browse files Browse the repository at this point in the history
  • Loading branch information
alexxcons authored and t8m committed Oct 9, 2023
1 parent c16fc62 commit 7f59da7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,12 @@ get_range(bitstr_t * bits, int low, int high, const char *names[],
if (state != R_FINISH || ch == EOF)
return (EOF);

/* Make sure the step size makes any sense */
if (step > 1 && step > (high_ - low_)) {
int max = high_ - low_ > 0 ? high_ - low_ : 1;
fprintf(stderr, "Warning: Step size %i higher than possible maximum of %i\n", step, max);
}

for (i = low_; i <= high_; i += step)
if (EOF == set_element(bits, low, high, i)) {
unget_char(ch, file);
Expand Down

0 comments on commit 7f59da7

Please sign in to comment.