diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-03-20 09:06:13 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-03-20 16:06:57 +0000 |
commit | 38f348bbb0bc829a5f5cdda5f374f7b73809a160 (patch) | |
tree | f6efea88a8654eb014a2665c9981a257f1cd1f1d /ui | |
parent | 8b8fc662d8e82634bcf5f5d610e5a88419a5a500 (diff) |
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>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/text_import.c | 18 | ||||
-rw-r--r-- | ui/text_import_scanner.h | 3 | ||||
-rw-r--r-- | ui/text_import_scanner.l | 2 |
3 files changed, 19 insertions, 4 deletions
diff --git a/ui/text_import.c b/ui/text_import.c index da67324423..ac679a6423 100644 --- a/ui/text_import.c +++ b/ui/text_import.c @@ -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; } diff --git a/ui/text_import_scanner.h b/ui/text_import_scanner.h index a67b50766d..512203f2fc 100644 --- a/ui/text_import_scanner.h +++ b/ui/text_import_scanner.h @@ -25,7 +25,8 @@ typedef enum { T_OFFSET, T_DIRECTIVE, T_TEXT, - T_EOL + T_EOL, + T_EOF } token_t; diff --git a/ui/text_import_scanner.l b/ui/text_import_scanner.l index 9bc812edc8..d3ec5d067a 100644 --- a/ui/text_import_scanner.l +++ b/ui/text_import_scanner.l @@ -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(); } + %% /* |