forked from osmocom/wireshark
dfilter: Minor flex clean up
Replace flex prefix to improve readability. Remove two no-longer-needed workarounds to suppress warnings.
This commit is contained in:
parent
f2218ae5f0
commit
5d8f495233
|
@ -413,20 +413,20 @@ dfilter_compile_real(const gchar *text, dfilter_t **dfp,
|
||||||
ws_noisy("Verbatim text: %s", dfw->expanded_text);
|
ws_noisy("Verbatim text: %s", dfw->expanded_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (df_lex_init(&scanner) != 0) {
|
if (df_yylex_init(&scanner) != 0) {
|
||||||
dfw_error_set_msg(errpp, "Can't initialize scanner: %s", g_strerror(errno));
|
dfw_error_set_msg(errpp, "Can't initialize scanner: %s", g_strerror(errno));
|
||||||
goto FAILURE;
|
goto FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_buffer = df__scan_string(dfw->expanded_text, scanner);
|
in_buffer = df_yy_scan_string(dfw->expanded_text, scanner);
|
||||||
|
|
||||||
memset(&state, 0, sizeof(state));
|
memset(&state, 0, sizeof(state));
|
||||||
state.dfw = dfw;
|
state.dfw = dfw;
|
||||||
|
|
||||||
df_set_extra(&state, scanner);
|
df_yyset_extra(&state, scanner);
|
||||||
|
|
||||||
/* Enable/disable debugging for Flex. */
|
/* Enable/disable debugging for Flex. */
|
||||||
df_set_debug(flags & DF_DEBUG_FLEX, scanner);
|
df_yyset_debug(flags & DF_DEBUG_FLEX, scanner);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
/* Enable/disable debugging for Lemon. */
|
/* Enable/disable debugging for Lemon. */
|
||||||
|
@ -439,7 +439,7 @@ dfilter_compile_real(const gchar *text, dfilter_t **dfp,
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
df_lval = stnode_new_empty(STTYPE_UNINITIALIZED);
|
df_lval = stnode_new_empty(STTYPE_UNINITIALIZED);
|
||||||
token = df_lex(scanner);
|
token = df_yylex(scanner);
|
||||||
|
|
||||||
/* Check for scanner failure */
|
/* Check for scanner failure */
|
||||||
if (token == SCAN_FAILED) {
|
if (token == SCAN_FAILED) {
|
||||||
|
@ -492,8 +492,8 @@ dfilter_compile_real(const gchar *text, dfilter_t **dfp,
|
||||||
/* Free scanner state */
|
/* Free scanner state */
|
||||||
if (state.quoted_string != NULL)
|
if (state.quoted_string != NULL)
|
||||||
g_string_free(state.quoted_string, TRUE);
|
g_string_free(state.quoted_string, TRUE);
|
||||||
df__delete_buffer(in_buffer, scanner);
|
df_yy_delete_buffer(in_buffer, scanner);
|
||||||
df_lex_destroy(scanner);
|
df_yylex_destroy(scanner);
|
||||||
|
|
||||||
if (failure)
|
if (failure)
|
||||||
goto FAILURE;
|
goto FAILURE;
|
||||||
|
|
|
@ -46,10 +46,10 @@
|
||||||
%option never-interactive
|
%option never-interactive
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prefix scanner routines with "df_" rather than "yy", so this scanner
|
* Prefix scanner routines with "df_yy" rather than "yy", so this scanner
|
||||||
* can coexist with other scanners.
|
* can coexist with other scanners.
|
||||||
*/
|
*/
|
||||||
%option prefix="df_"
|
%option prefix="df_yy"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're reading from a string, so we don't need yywrap.
|
* We're reading from a string, so we don't need yywrap.
|
||||||
|
@ -61,19 +61,6 @@
|
||||||
*/
|
*/
|
||||||
%option extra-type="df_scanner_state_t *"
|
%option extra-type="df_scanner_state_t *"
|
||||||
|
|
||||||
/*
|
|
||||||
* We have to override the memory allocators so that we don't get
|
|
||||||
* "unused argument" warnings from the yyscanner argument (which
|
|
||||||
* we don't use, as we have a global memory allocator).
|
|
||||||
*
|
|
||||||
* We provide, as macros, our own versions of the routines generated by Flex,
|
|
||||||
* which just call malloc()/realloc()/free() (as the Flex versions do),
|
|
||||||
* discarding the extra argument.
|
|
||||||
*/
|
|
||||||
%option noyyalloc
|
|
||||||
%option noyyrealloc
|
|
||||||
%option noyyfree
|
|
||||||
|
|
||||||
%{
|
%{
|
||||||
/*
|
/*
|
||||||
* Wireshark - Network traffic analyzer
|
* Wireshark - Network traffic analyzer
|
||||||
|
@ -116,18 +103,6 @@ static void update_string_loc(df_scanner_state_t *state, const char *text);
|
||||||
dfilter_fail(yyextra->dfw, DF_ERROR_GENERIC, yyextra->location, __VA_ARGS__); \
|
dfilter_fail(yyextra->dfw, DF_ERROR_GENERIC, yyextra->location, __VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
|
||||||
* Sleazy hack to suppress compiler warnings in yy_fatal_error().
|
|
||||||
*/
|
|
||||||
#define YY_EXIT_FAILURE ((void)yyscanner, 2)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros for the allocators, to discard the extra argument.
|
|
||||||
*/
|
|
||||||
#define df_alloc(size, yyscanner) (void *)malloc(size)
|
|
||||||
#define df_realloc(ptr, size, yyscanner) (void *)realloc((char *)(ptr), (size))
|
|
||||||
#define df_free(ptr, yyscanner) free((char *)ptr)
|
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
Identifier [[:alnum:]_][[:alnum:]_-]*(\.[[:alnum:]_-]+)*
|
Identifier [[:alnum:]_][[:alnum:]_-]*(\.[[:alnum:]_-]+)*
|
||||||
|
|
Loading…
Reference in New Issue