[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] yysyntax_error: improve invocation readability.
From: |
Joel E. Denny |
Subject: |
[PATCH] yysyntax_error: improve invocation readability. |
Date: |
Sun, 31 Oct 2010 21:42:52 -0400 (EDT) |
User-agent: |
Alpine 1.00 (DEB 882 2007-12-20) |
I pushed this to master and branch 2.5. The real goal of this patch is to
prepare for further fixes of yysyntax_error behavior, which I started
about a year ago.
>From 34db451c379888fa593268b65518ad191bef21f5 Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Sun, 31 Oct 2010 18:56:34 -0400
Subject: [PATCH] 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 1ea3e5e..3f7a2ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-10-31 Joel E. Denny <address@hidden>
+ 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 <address@hidden>
+
* ChangeLog: Correct some errors in previous entries.
2010-10-17 Joel E. Denny <address@hidden>
diff --git a/data/yacc.c b/data/yacc.c
index e41e2e9..a329717 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
}
--
1.7.0.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] yysyntax_error: improve invocation readability.,
Joel E. Denny <=