From 34db451c379888fa593268b65518ad191bef21f5 Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Sun, 31 Oct 2010 18:56:34 -0400 Subject: [PATCH 1/1] yysyntax_error: improve invocation readability. * data/yacc.c (yyparse, yypush_parse): For yysyntax_error invocation, get rid of the while loop, which is misleading because there are really at most two iterations. --- ChangeLog | 7 +++++++ data/yacc.c | 50 ++++++++++++++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ea3e5e4..3f7a2ee0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-10-31 Joel E. Denny + + yysyntax_error: improve invocation readability. + * data/yacc.c (yyparse, yypush_parse): For yysyntax_error + invocation, get rid of the while loop, which is misleading + because there are really at most two iterations. + 2010-10-31 Joel E. Denny * ChangeLog: Correct some errors in previous entries. diff --git a/data/yacc.c b/data/yacc.c index e41e2e9c..a3297176 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -1477,28 +1477,34 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (]b4_yyerror_args[YY_("syntax error")); #else - while (1) - { - int yysyntax_error_status = - yysyntax_error (&yymsg_alloc, &yymsg, yystate, yytoken); - if (yysyntax_error_status == 2 && 0 < yymsg_alloc) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (yymsg) - continue; - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - if (yysyntax_error_status == 0) - yyerror (]b4_yyerror_args[yymsg); - else - yyerror (]b4_yyerror_args[YY_("syntax error")); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - break; - } +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, yystate, \ + yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 2 && 0 < yymsg_alloc) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (]b4_yyerror_args[yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR #endif } -- 2.45.2