Skip to content

Commit

Permalink
Allow only one optional parameter to 'input'
Browse files Browse the repository at this point in the history
Python only allows zero or one parameters to the input function. Check
for more than one and emit an error.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Dec 19, 2022
1 parent 2e09601 commit 4783829
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions snek-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ snek_builtin_input(uint8_t nposition, uint8_t nnamed, snek_poly_t *args)
int c;
snek_poly_t s = snek_string_to_poly(snek_alloc(1));

while (nposition--) {
snek_poly_t arg = *args++;
snek_poly_print(stdout, arg, 's');
if (nposition)
putc(' ', stdout);
/* print out an optional parameter */
if (nposition) {
if (nposition > 1)
return snek_error_args(1, nposition);
snek_poly_print(stdout, *args, 's');
}
(void) nnamed;
snek_in_input = true;
Expand Down

0 comments on commit 4783829

Please sign in to comment.