dfilter: Replace global variable
This commit is contained in:
parent
5d8f495233
commit
f5bfe89785
|
@ -70,6 +70,7 @@ typedef struct {
|
|||
*/
|
||||
typedef struct {
|
||||
dfwork_t *dfw;
|
||||
stnode_t *df_lval;
|
||||
GString* quoted_string;
|
||||
gboolean raw_string;
|
||||
df_loc_t string_loc;
|
||||
|
|
|
@ -438,7 +438,6 @@ dfilter_compile_real(const gchar *text, dfilter_t **dfp,
|
|||
#endif
|
||||
|
||||
while (1) {
|
||||
df_lval = stnode_new_empty(STTYPE_UNINITIALIZED);
|
||||
token = df_yylex(scanner);
|
||||
|
||||
/* Check for scanner failure */
|
||||
|
@ -456,12 +455,12 @@ dfilter_compile_real(const gchar *text, dfilter_t **dfp,
|
|||
|
||||
ws_noisy("(%u) Token %d %s %s",
|
||||
++token_count, token, tokenstr(token),
|
||||
stnode_token(df_lval));
|
||||
stnode_token(state.df_lval));
|
||||
|
||||
/* Give the token to the parser */
|
||||
Dfilter(ParserObj, token, df_lval, dfw);
|
||||
Dfilter(ParserObj, token, state.df_lval, dfw);
|
||||
/* The parser has freed the lval for us. */
|
||||
df_lval = NULL;
|
||||
state.df_lval = NULL;
|
||||
|
||||
if (dfw->parse_failure) {
|
||||
failure = TRUE;
|
||||
|
@ -472,9 +471,9 @@ dfilter_compile_real(const gchar *text, dfilter_t **dfp,
|
|||
|
||||
/* If we created a df_lval_t but didn't use it, free it; the
|
||||
* parser doesn't know about it and won't free it for us. */
|
||||
if (df_lval) {
|
||||
stnode_free(df_lval);
|
||||
df_lval = NULL;
|
||||
if (state.df_lval) {
|
||||
stnode_free(state.df_lval);
|
||||
state.df_lval = NULL;
|
||||
}
|
||||
|
||||
/* Tell the parser that we have reached the end of input; that
|
||||
|
|
|
@ -75,8 +75,6 @@
|
|||
*/
|
||||
DIAG_OFF_FLEX()
|
||||
|
||||
stnode_t *df_lval;
|
||||
|
||||
WS_WARN_UNUSED static int set_lval_simple(df_scanner_state_t *state, int token, const char *token_value, sttype_id_t type_id);
|
||||
#define simple(token) (update_location(yyextra, yytext), set_lval_simple(yyextra, token, yytext, STTYPE_UNINITIALIZED))
|
||||
#define test(token) (update_location(yyextra, yytext), set_lval_simple(yyextra, token, yytext, STTYPE_TEST))
|
||||
|
@ -508,28 +506,28 @@ update_string_loc(df_scanner_state_t *state, const char *text)
|
|||
static int
|
||||
set_lval_simple(df_scanner_state_t *state, int token, const char *token_value, sttype_id_t type_id)
|
||||
{
|
||||
stnode_init(df_lval, type_id, NULL, g_strdup(token_value), state->location);
|
||||
state->df_lval = stnode_new(type_id, NULL, g_strdup(token_value), state->location);
|
||||
return token;
|
||||
}
|
||||
|
||||
static int
|
||||
set_lval_literal(df_scanner_state_t *state, const char *token_value)
|
||||
{
|
||||
stnode_init(df_lval, STTYPE_LITERAL, g_strdup(token_value), g_strdup(token_value), state->location);
|
||||
state->df_lval = stnode_new(STTYPE_LITERAL, g_strdup(token_value), g_strdup(token_value), state->location);
|
||||
return TOKEN_LITERAL;
|
||||
}
|
||||
|
||||
static int
|
||||
set_lval_identifier(df_scanner_state_t *state, const char *token_value)
|
||||
{
|
||||
stnode_init(df_lval, STTYPE_LITERAL, g_strdup(token_value), g_strdup(token_value), state->location);
|
||||
state->df_lval = stnode_new(STTYPE_LITERAL, g_strdup(token_value), g_strdup(token_value), state->location);
|
||||
return TOKEN_IDENTIFIER;
|
||||
}
|
||||
|
||||
static int
|
||||
set_lval_constant(df_scanner_state_t *state, const char *token_value)
|
||||
{
|
||||
stnode_init(df_lval, STTYPE_LITERAL, g_strdup(token_value), g_strdup(token_value), state->location);
|
||||
state->df_lval = stnode_new(STTYPE_LITERAL, g_strdup(token_value), g_strdup(token_value), state->location);
|
||||
return TOKEN_CONSTANT;
|
||||
}
|
||||
|
||||
|
@ -549,7 +547,7 @@ set_lval_quoted_string(df_scanner_state_t *state, GString *quoted_string)
|
|||
char *token_value;
|
||||
|
||||
token_value = ws_escape_string_len(NULL, quoted_string->str, quoted_string->len, true);
|
||||
stnode_init(df_lval, STTYPE_STRING, quoted_string, token_value, state->string_loc);
|
||||
state->df_lval = stnode_new(STTYPE_STRING, quoted_string, token_value, state->string_loc);
|
||||
return TOKEN_STRING;
|
||||
}
|
||||
|
||||
|
@ -565,14 +563,14 @@ set_lval_charconst(df_scanner_state_t *state, GString *quoted_string)
|
|||
g_free(token_value);
|
||||
return SCAN_FAILED;
|
||||
}
|
||||
stnode_init(df_lval, STTYPE_CHARCONST, g_memdup2(&number, sizeof(number)), token_value, state->string_loc);
|
||||
state->df_lval = stnode_new(STTYPE_CHARCONST, g_memdup2(&number, sizeof(number)), token_value, state->string_loc);
|
||||
return TOKEN_CHARCONST;
|
||||
}
|
||||
|
||||
static int
|
||||
set_lval_field(df_scanner_state_t *state, const char *token_value, const header_field_info *hfinfo)
|
||||
{
|
||||
stnode_init(df_lval, STTYPE_FIELD, (gpointer)hfinfo, g_strdup(token_value), state->location);
|
||||
state->df_lval = stnode_new(STTYPE_FIELD, (gpointer)hfinfo, g_strdup(token_value), state->location);
|
||||
return TOKEN_FIELD;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue