diff options
author | João Valverde <j@v6e.pt> | 2022-11-19 11:14:57 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2022-12-01 22:50:09 +0000 |
commit | 967a3c3df94d09a09306a23ae248ef611f57087b (patch) | |
tree | 7d5da31734eb50d8a87cefd154df81280fc55b3f /epan | |
parent | 5853886d50f2294d4643871878c921a69b8408d5 (diff) |
Qt: Check field autocomplete for syntactical validity
Currently the autocompletion engine always suggests a protocol
field completion, even in places where it isn't syntactically
valid.
Fix that by compiling the preamble to the token under the cursor
and checking the returned error. If it is DF_ERROR_UNEXPECTED_END
that indicates a field or literal value was expected. Otherwise
a field replacement is not valid in this position.
Fixes #12811.
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dfilter/dfilter.h | 1 | ||||
-rw-r--r-- | epan/dfilter/grammar.lemon | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/epan/dfilter/dfilter.h b/epan/dfilter/dfilter.h index 3177300464..c5c8ab64fa 100644 --- a/epan/dfilter/dfilter.h +++ b/epan/dfilter/dfilter.h @@ -53,6 +53,7 @@ dfilter_expand(const char *expr, char **err_ret); */ #define DF_ERROR_GENERIC -1 +#define DF_ERROR_UNEXPECTED_END -2 typedef struct _dfilter_loc { long col_start; diff --git a/epan/dfilter/grammar.lemon b/epan/dfilter/grammar.lemon index 5b841fa90f..4742520ef5 100644 --- a/epan/dfilter/grammar.lemon +++ b/epan/dfilter/grammar.lemon @@ -65,7 +65,7 @@ DIAG_ON_LEMON() any "error" symbols are shifted, if possible. */ %syntax_error { if (!TOKEN) { - dfilter_fail(dfw, DF_ERROR_GENERIC, NULL, "Unexpected end of filter expression."); + dfilter_fail(dfw, DF_ERROR_UNEXPECTED_END, NULL, "Unexpected end of filter expression."); return; } FAIL(dfw, TOKEN, "\"%s\" was unexpected in this context.", stnode_token(TOKEN)); |