From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: fasnacht@protonmail.ch
Subject: [PATCH nft 3/4] scanner: call scanner_push_indesc() after scanner_push_file()
Date: Tue, 11 Feb 2020 21:23:07 +0100 [thread overview]
Message-ID: <20200211202308.90575-4-pablo@netfilter.org> (raw)
In-Reply-To: <20200211202308.90575-1-pablo@netfilter.org>
Just a preparation patch.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
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
next prev parent reply other threads:[~2020-02-11 20:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 20:23 [PATCH nft 0/4] glob and maximum number of includes Pablo Neira Ayuso
2020-02-11 20:23 ` [PATCH nft 1/4] scanner: call scanner_push_file() after scanner_push_file() Pablo Neira Ayuso
2020-02-11 20:23 ` [PATCH nft 2/4] scanner: add indesc_file_alloc() helper function Pablo Neira Ayuso
2020-02-11 20:23 ` Pablo Neira Ayuso [this message]
2020-02-11 20:23 ` [PATCH nft 4/4] scanner: multi-level input file stack for glob Pablo Neira Ayuso
2020-02-12 20:44 ` [PATCH nft 0/4] glob and maximum number of includes Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200211202308.90575-4-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=fasnacht@protonmail.ch \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).