Just a preparation patch. Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- src/scanner.l | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/scanner.l b/src/scanner.l index 56f6e9956791..9584f61c489c 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -707,19 +707,16 @@ static void scanner_pop_buffer(yyscan_t scanner) scanner_pop_indesc(state); } -static void scanner_push_file(struct nft_ctx *nft, void *scanner, - FILE *f, const char *filename, - const struct location *loc) +static struct input_descriptor * +scanner_push_file(struct nft_ctx *nft, void *scanner, FILE *f, + const char *filename, const struct location *loc) { - struct parser_state *state = yyget_extra(scanner); - struct input_descriptor *indesc; YY_BUFFER_STATE b; b = yy_create_buffer(f, YY_BUF_SIZE, scanner); yypush_buffer_state(b, scanner); - indesc = indesc_file_alloc(f, filename, loc); - scanner_push_indesc(state, indesc); + return indesc_file_alloc(f, filename, loc); } static FILE *include_file(struct nft_ctx *nft, void *scanner, @@ -805,6 +802,7 @@ static int include_glob(struct nft_ctx *nft, void *scanner, const char *pattern, /* reverse alphabetical order due to stack */ for (i = glob_data.gl_pathc; i > 0; i--) { + struct input_descriptor *indesc; path = glob_data.gl_pathv[i-1]; @@ -817,7 +815,8 @@ static int include_glob(struct nft_ctx *nft, void *scanner, const char *pattern, if (!f) goto err; - scanner_push_file(nft, scanner, f, path, loc); + indesc = scanner_push_file(nft, scanner, f, path, loc); + scanner_push_indesc(state, indesc); } globfree(&glob_data); @@ -852,13 +851,17 @@ err: int scanner_read_file(struct nft_ctx *nft, const char *filename, const struct location *loc) { + struct parser_state *state = yyget_extra(nft->scanner); + struct input_descriptor *indesc; FILE *f; f = include_file(nft, nft->scanner, filename, loc); if (!f) return -1; - scanner_push_file(nft, nft->scanner, f, filename, loc); + indesc = scanner_push_file(nft, nft->scanner, f, filename, loc); + scanner_push_indesc(state, indesc); + return 0; } -- 2.11.0