Put back EOF rule, but without exporting write_current_packet().

Instead, add a new T_EOF token type, call parse_token() with it when we
get an EOF, and, in parse_token(), write the current packet if we get a
T_EOF token.

That's a bit simpler, and would let us treat EOFs in different places
differently, if, for example, we want to report warnings for
half-finished packets.

Change-Id: Ie41a8a1dedf91c34300468e073f18bf806e01892
Reviewed-on: https://code.wireshark.org/review/32489
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2019-03-20 09:06:13 -07:00
parent 8b8fc662d8
commit 38f348bbb0
3 changed files with 19 additions and 4 deletions

View File

@ -863,6 +863,9 @@ parse_token (token_t token, char *str)
state = READ_BYTE;
}
break;
case T_EOF:
write_current_packet();
break;
default:
break;
}
@ -914,6 +917,9 @@ parse_token (token_t token, char *str)
state = READ_BYTE;
}
break;
case T_EOF:
write_current_packet();
break;
default:
break;
}
@ -935,6 +941,9 @@ parse_token (token_t token, char *str)
case T_EOL:
state = START_OF_LINE;
break;
case T_EOF:
write_current_packet();
break;
default:
break;
}
@ -955,6 +964,9 @@ parse_token (token_t token, char *str)
case T_EOL:
state = START_OF_LINE;
break;
case T_EOF:
write_current_packet();
break;
default:
break;
}
@ -966,6 +978,9 @@ parse_token (token_t token, char *str)
case T_EOL:
state = START_OF_LINE;
break;
case T_EOF:
write_current_packet();
break;
default:
break;
}
@ -1117,9 +1132,6 @@ text_import(text_import_info_t *info)
max_offset = info->max_frame_length;
ret = text_import_scan(info->import_text_file);
if (ret == 0) {
write_current_packet();
}
g_free(packet_buf);
return ret;
}

View File

@ -25,7 +25,8 @@ typedef enum {
T_OFFSET,
T_DIRECTIVE,
T_TEXT,
T_EOL
T_EOL,
T_EOF
} token_t;

View File

@ -122,6 +122,8 @@ eol \r?\n\r?
{comment} { parse_token(T_EOL, NULL); }
{text} { parse_token(T_TEXT, yytext); }
<<EOF>> { parse_token(T_EOF, NULL); yyterminate(); }
%%
/*