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
lex_discard_noninteractive (struct lexer *lexer)
{
struct lex_source *src = lex_source__ (lexer);
-
if (src != NULL)
{
+ if (src->reader->error == LEX_ERROR_IGNORE)
+ return;
+
lex_stage_clear (&src->pp);
lex_stage_clear (&src->merge);
lex_source_clear_parse (src);
: ll_data (ll_head (&lexer->sources), struct lex_source, ll));
}
+const struct lex_source *
+lex_source (const struct lexer *lexer)
+{
+ return lex_source__ (lexer);
+}
+
/* Returns the text of the syntax in SRC for tokens with offsets OFS0 through
OFS1 in the current command, inclusive. (For example, if OFS0 and OFS1 are
both zero, this requests the syntax for the first token in the current
struct lex_reader *
lex_reader_for_string (const char *s, const char *encoding)
{
- struct substring ss;
- ss_alloc_substring (&ss, ss_cstr (s));
- return lex_reader_for_substring_nocopy (ss, encoding);
+ return lex_reader_for_substring_nocopy (ss_clone (ss_cstr (s)), encoding);
}
/* Formats FORMAT as a printf()-like format string and creates and returns a