From f51bad11d70b2548ed2cbf117b90bd9dbf1afedf Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 4 Dec 2015 19:52:51 -0800 Subject: [PATCH] Use noyywrap rather than defining our own yywrap functions. Tweak lemonflex-tail.inc to fix an issue this reveals. It appears that, at least on the buildbots, the Visual Studio compiler no longer issues warnings for the code generated with %option noyywrap. Change-Id: Id64d56f1ae8a79d0336488a4a50518da1f511497 Reviewed-on: https://code.wireshark.org/review/12433 Reviewed-by: Guy Harris --- epan/dfilter/scanner.l | 5 +++++ epan/diam_dict.l | 18 +++++------------- epan/dtd_parse.l | 16 +++++----------- epan/dtd_preparse.l | 16 +++++----------- epan/radius_dict.l | 16 +++++----------- epan/uat_load.l | 18 +++++------------- plugins/mate/mate_parser.l | 16 +++++----------- plugins/wimaxasncp/wimaxasncp_dict.l | 16 +++++----------- text2pcap-scanner.l | 12 +++++------- tools/lemon/lemonflex-tail.inc | 2 ++ ui/text_import_scanner.l | 11 +++++------ wiretap/ascend_scanner.l | 16 +++++----------- wiretap/k12text.l | 16 +++++----------- 13 files changed, 62 insertions(+), 116 deletions(-) diff --git a/epan/dfilter/scanner.l b/epan/dfilter/scanner.l index be45f7390c..c213ac8351 100644 --- a/epan/dfilter/scanner.l +++ b/epan/dfilter/scanner.l @@ -19,6 +19,11 @@ */ %option prefix="df_" +/* + * We're reading from a string, so we don't need yywrap. + */ +%option noyywrap + %{ /* * Wireshark - Network traffic analyzer diff --git a/epan/diam_dict.l b/epan/diam_dict.l index 9a9bdacf36..9dccba9b97 100644 --- a/epan/diam_dict.l +++ b/epan/diam_dict.l @@ -23,6 +23,11 @@ */ %option stack +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * Prefix scanner routines with "DiamDict" rather than "yy", so this scanner * can coexist with other scanners. @@ -820,19 +825,6 @@ ddict_print(FILE* fh, ddict_t* d) } } -/* - * We want to stop processing when we get to the end of the input. - * (%option noyywrap is not used because if used then - * some flex versions (eg: 2.5.35) generate code which causes - * warnings by the Windows VC compiler). - */ - -int -yywrap(void) -{ - return 1; -} - #ifdef TEST_DIAM_DICT_STANDALONE int main(int argc, char** argv) diff --git a/epan/dtd_parse.l b/epan/dtd_parse.l index 14e3b04e99..1c9554478a 100644 --- a/epan/dtd_parse.l +++ b/epan/dtd_parse.l @@ -13,6 +13,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * Prefix scanner routines with "Dtd_Parse_" rather than "yy", so this scanner * can coexist with other scanners. @@ -367,14 +372,3 @@ extern dtd_build_data_t* dtd_parse(GString* s) { return build_data; } - -/* - * We want to stop processing when we get to the end of the input. - * (%option noyywrap is not used because if used then - * some flex versions (eg: 2.5.35) generate code which causes - * warnings by the Windows VC compiler). - */ - -int yywrap(void) { - return 1; -} diff --git a/epan/dtd_preparse.l b/epan/dtd_preparse.l index 306e5d8f5a..5188fbae02 100644 --- a/epan/dtd_preparse.l +++ b/epan/dtd_preparse.l @@ -13,6 +13,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * The language we're scanning is case-insensitive. */ @@ -230,14 +235,3 @@ extern GString* dtd_preparse(const gchar* dname,const gchar* fname, GString* er return output; } - -/* - * We want to stop processing when we get to the end of the input. - * (%option noyywrap is not used because if used then - * some flex versions (eg: 2.5.35) generate code which causes - * warnings by the Windows VC compiler). - */ - -int yywrap(void) { - return 1; -} diff --git a/epan/radius_dict.l b/epan/radius_dict.l index c043856626..ebbf2a060a 100644 --- a/epan/radius_dict.l +++ b/epan/radius_dict.l @@ -13,6 +13,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * The language we're scanning is case-insensitive. */ @@ -640,17 +645,6 @@ gboolean radius_load_dictionary (radius_dictionary_t* d, gchar* dir, const gchar } } -/* - * We want to stop processing when we get to the end of the input. - * (%option noyywrap is not used because if used then - * some flex versions (eg: 2.5.35) generate code which causes - * warnings by the Windows VC compiler). - */ - -int yywrap(void) { - return 1; -} - /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/epan/uat_load.l b/epan/uat_load.l index 5c634f56aa..0f1ef93536 100644 --- a/epan/uat_load.l +++ b/epan/uat_load.l @@ -13,6 +13,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * Prefix scanner routines with "uat_load_" rather than "yy", so this scanner * can coexist with other scanners. @@ -375,16 +380,3 @@ uat_load_str(uat_t *uat_in, char *entry, char **err) *err = NULL; return TRUE; } - -/* - * We want to stop processing when we get to the end of the input. - * (%option noyywrap is not used because if used then - * some flex versions (eg: 2.5.35) generate code which causes - * warnings by the Windows VC compiler). - */ - -int -yywrap(void) -{ - return 1; -} diff --git a/plugins/mate/mate_parser.l b/plugins/mate/mate_parser.l index a3f609e505..865b8d138c 100644 --- a/plugins/mate/mate_parser.l +++ b/plugins/mate/mate_parser.l @@ -13,6 +13,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * Prefix scanner routines with "Mate" rather than "yy", so this scanner * can coexist with other scanners. @@ -339,14 +344,3 @@ extern gboolean mate_load_config(const gchar* filename, mate_config* matecfg) { return state; } - -/* - * We want to stop processing when we get to the end of the input. - * (%option noyywrap is not used because if used then - * some flex versions (eg: 2.5.35) generate code which causes - * warnings by the Windows VC compiler). - */ - -int yywrap(void) { - return 1; -} diff --git a/plugins/wimaxasncp/wimaxasncp_dict.l b/plugins/wimaxasncp/wimaxasncp_dict.l index 2c889b3a61..3953f1fe96 100644 --- a/plugins/wimaxasncp/wimaxasncp_dict.l +++ b/plugins/wimaxasncp/wimaxasncp_dict.l @@ -13,6 +13,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * The language we're scanning is case-insensitive. */ @@ -727,17 +732,6 @@ void wimaxasncp_dict_print(FILE *fh, wimaxasncp_dict_t *d) { } } -/* - * We want to stop processing when we get to the end of the input. - * (%option noyywrap is not used because if used then - * some flex versions (eg: 2.5.35) generate code which causes - * warnings by the Windows VC compiler). - */ - -int yywrap(void) { - return 1; -} - #ifdef TEST_WIMAXASNCP_DICT_STANDALONE int main(int argc, char **argv) { wimaxasncp_dict_t *d; diff --git a/text2pcap-scanner.l b/text2pcap-scanner.l index d1871cdfdd..be68b1b71b 100644 --- a/text2pcap-scanner.l +++ b/text2pcap-scanner.l @@ -15,6 +15,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + %{ /******************************************************************************** @@ -88,10 +93,3 @@ eol \r?\n\r? {directive} { parse_token(T_DIRECTIVE, yytext); } {comment} ; /* ignore comments */ {text} { parse_token(T_TEXT, yytext); } - -%% - -int yywrap(void) -{ - return 1; -} diff --git a/tools/lemon/lemonflex-tail.inc b/tools/lemon/lemonflex-tail.inc index 55af823ac9..5a63fdd3f6 100644 --- a/tools/lemon/lemonflex-tail.inc +++ b/tools/lemon/lemonflex-tail.inc @@ -9,7 +9,9 @@ Prototypes: void CONCAT(MODNAME,_scanner_text(char *text)); void CONCAT(MODNAME,_scanner_file(FILE *fh)); void CONCAT(MODNAME,_scanner_cleanup(void)); +#ifndef YY_SKIP_YYWRAP int CONCAT(MODNAME,_wrap(void)); +#endif #include diff --git a/ui/text_import_scanner.l b/ui/text_import_scanner.l index 625cc050d1..23e6d24adb 100644 --- a/ui/text_import_scanner.l +++ b/ui/text_import_scanner.l @@ -10,6 +10,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * Prefix scanner routines with "text_import" rather than "yy", so this scanner * can coexist with other scanners. @@ -92,9 +97,3 @@ eol \r?\n\r? {text} { parse_token(T_TEXT, yytext); } <> { write_current_packet(); yyterminate(); } - -%% -int yywrap(void) -{ - return 1; -} diff --git a/wiretap/ascend_scanner.l b/wiretap/ascend_scanner.l index ff8b0a1ec8..b7df4cb76a 100644 --- a/wiretap/ascend_scanner.l +++ b/wiretap/ascend_scanner.l @@ -3,6 +3,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * Prefix scanner routines with "ascend" rather than "yy", so this scanner * can coexist with other scanners. @@ -339,14 +344,3 @@ void ascend_init_lexer(FILE_T fh) yy_fh = fh; BEGIN(INITIAL); } - -/* - * We want to stop processing when we get to the end of the input. - * (%option noyywrap is not used because if used then - * some flex versions (eg: 2.5.35) generate code which causes - * warnings by the Windows VC compiler). - */ - -int yywrap(void) { - return 1; -} diff --git a/wiretap/k12text.l b/wiretap/k12text.l index 350393538a..7601b94232 100644 --- a/wiretap/k12text.l +++ b/wiretap/k12text.l @@ -13,6 +13,11 @@ */ %option never-interactive +/* + * We want to stop processing when we get to the end of the input. + */ +%option noyywrap + /* * Prefix scanner routines with "K12Text_" rather than "yy", so this scanner * can coexist with other scanners. @@ -461,14 +466,3 @@ k12text_dump_can_write_encap(int encap) return WTAP_ERR_UNWRITABLE_ENCAP; } } - -/* - * We want to stop processing when we get to the end of the input. - * (%option noyywrap is not used because if used then - * some flex versions (eg: 2.5.35) generate code which causes - * warnings by the Windows VC compiler). - */ - -int yywrap(void) { - return 1; -}