diff options
author | João Valverde <j@v6e.pt> | 2022-04-07 13:57:39 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2022-04-10 10:09:51 +0100 |
commit | 4d9470e7dd9df596e531373fb20221d82b09ca9b (patch) | |
tree | a5dec5106f71e784dedb377dd35735fd2f93942f /epan/dfilter/dfilter-int.h | |
parent | da19379eb52113155749049d2a0d2fbcb184482b (diff) |
dfilter: Add location tracking to scanner and use it to report errors
Add location tracking as a column offset and length from offset
to the scanner. Our input is a single line only so we don't need
to track line offset.
Record that information in the syntax tree. Return the error location
in dfilter_compile(). Use it in dftest to mark the location of the
error in the filter string. Later it would be nice to use the location
in the GUI as well.
$ dftest "ip.proto == aaaaaa and tcp.port == 123"
Filter: ip.proto == aaaaaa and tcp.port == 123
dftest: "aaaaaa" cannot be found among the possible values for ip.proto.
ip.proto == aaaaaa and tcp.port == 123
^~~~~~
Diffstat (limited to 'epan/dfilter/dfilter-int.h')
-rw-r--r-- | epan/dfilter/dfilter-int.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/epan/dfilter/dfilter-int.h b/epan/dfilter/dfilter-int.h index 346f6f6804..dc50f6a75a 100644 --- a/epan/dfilter/dfilter-int.h +++ b/epan/dfilter/dfilter-int.h @@ -44,6 +44,8 @@ typedef struct { GPtrArray *deprecated; GHashTable *references; /* hfinfo -> pointer to GSList of fvalues */ GHashTable *loaded_references; + char *expanded_text; + stloc_t err_loc; } dfwork_t; /* @@ -53,6 +55,8 @@ typedef struct { dfwork_t *dfw; GString* quoted_string; gboolean raw_string; + stloc_t string_loc; + stloc_t location; } df_scanner_state_t; /* Constructor/Destructor prototypes for Lemon Parser */ @@ -66,14 +70,20 @@ void Dfilter(void*, int, stnode_t*, dfwork_t*); #define SCAN_FAILED -1 /* not 0, as that means end-of-input */ void -dfilter_vfail(dfwork_t *dfw, const char *format, va_list args); +dfilter_vfail(dfwork_t *dfw, stloc_t *err_loc, + const char *format, va_list args); void -dfilter_fail(dfwork_t *dfw, const char *format, ...) G_GNUC_PRINTF(2, 3); +dfilter_fail(dfwork_t *dfw, stloc_t *err_loc, + const char *format, ...) G_GNUC_PRINTF(3, 4); WS_NORETURN void -dfilter_fail_throw(dfwork_t *dfw, long code, const char *format, ...) G_GNUC_PRINTF(3, 4); +dfilter_fail_throw(dfwork_t *dfw, stloc_t *err_loc, + long code, const char *format, ...) G_GNUC_PRINTF(4, 5); + +void +dfw_set_error_location(dfwork_t *dfw, stloc_t *err_loc); void add_deprecated_token(dfwork_t *dfw, const char *token); |