From: Ben Pfaff Date: Sun, 18 Sep 2022 23:42:26 +0000 (-0700) Subject: lexer: Make lex_error_expecting_valist() support a longer list. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=625e8f648793d63b3b601660c5f4bc9962b0aca1;p=pspp lexer: Make lex_error_expecting_valist() support a longer list. --- diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index f9236af19f..a2a0da9713 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -519,18 +519,22 @@ void void lex_error_expecting_valist (struct lexer *lexer, va_list args) { - enum { MAX_OPTIONS = 9 }; - const char *options[MAX_OPTIONS]; - int n = 0; - while (n < MAX_OPTIONS) + const char **options = NULL; + size_t allocated = 0; + size_t n = 0; + + for (;;) { const char *option = va_arg (args, const char *); if (!option) break; + if (n >= allocated) + options = x2nrealloc (options, &allocated, sizeof *options); options[n++] = option; } lex_error_expecting_array (lexer, options, n); + free (options); } void