From 8b53f4e022eff4c54ce1916aefec8a04cad6be97 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 1 Dec 2019 18:18:08 +0100 Subject: [PATCH] glr.c: style changes * data/skeletons/glr.c (yysplitStack): Reduce scopes. * tests/atlocal.in: Formatting changes. --- data/skeletons/glr.c | 47 ++++++++++++++++++++++---------------------- tests/atlocal.in | 4 ++-- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c index cc08ee4f..ceb8116d 100644 --- a/data/skeletons/glr.c +++ b/data/skeletons/glr.c @@ -1510,41 +1510,42 @@ yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk) YYASSERT (yyk == 0); yystackp->yysplitPoint = yystackp->yytops.yystates[yyk]; } - if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity) + if (yystackp->yytops.yycapacity <= yystackp->yytops.yysize) { - yyGLRState** yynewStates = YY_NULLPTR; - yybool* yynewLookaheadNeeds; - ptrdiff_t state_size = sizeof yynewStates[0]; + ptrdiff_t state_size = sizeof yystackp->yytops.yystates[0]; ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size; - if (half_max_capacity < yystackp->yytops.yycapacity) yyMemoryExhausted (yystackp); yystackp->yytops.yycapacity *= 2; - yynewStates - = YY_CAST (yyGLRState**, - YYREALLOC (yystackp->yytops.yystates, - (YY_CAST (size_t, yystackp->yytops.yycapacity) - * sizeof yynewStates[0]))); - if (yynewStates == YY_NULLPTR) - yyMemoryExhausted (yystackp); - yystackp->yytops.yystates = yynewStates; + { + yyGLRState** yynewStates + = YY_CAST (yyGLRState**, + YYREALLOC (yystackp->yytops.yystates, + (YY_CAST (size_t, yystackp->yytops.yycapacity) + * sizeof yynewStates[0]))); + if (yynewStates == YY_NULLPTR) + yyMemoryExhausted (yystackp); + yystackp->yytops.yystates = yynewStates; + } - yynewLookaheadNeeds - = YY_CAST (yybool*, - YYREALLOC (yystackp->yytops.yylookaheadNeeds, - (YY_CAST (size_t, yystackp->yytops.yycapacity) - * sizeof yynewLookaheadNeeds[0]))); - if (yynewLookaheadNeeds == YY_NULLPTR) - yyMemoryExhausted (yystackp); - yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds; + { + yybool* yynewLookaheadNeeds + = YY_CAST (yybool*, + YYREALLOC (yystackp->yytops.yylookaheadNeeds, + (YY_CAST (size_t, yystackp->yytops.yycapacity) + * sizeof yynewLookaheadNeeds[0]))); + if (yynewLookaheadNeeds == YY_NULLPTR) + yyMemoryExhausted (yystackp); + yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds; + } } yystackp->yytops.yystates[yystackp->yytops.yysize] = yystackp->yytops.yystates[yyk]; yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize] = yystackp->yytops.yylookaheadNeeds[yyk]; yystackp->yytops.yysize += 1; - return yystackp->yytops.yysize-1; + return yystackp->yytops.yysize - 1; } /** True iff YYY0 and YYY1 represent identical options at the top level. @@ -1578,7 +1579,7 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) int yyn; for (yys0 = yyy0->yystate, yys1 = yyy1->yystate, yyn = yyrhsLength (yyy0->yyrule); - yyn > 0; + 0 < yyn; yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1) { if (yys0 == yys1) diff --git a/tests/atlocal.in b/tests/atlocal.in index 1a2e4613..8f2c64c4 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -117,9 +117,9 @@ fi : ${DC='@DC@'} : ${DCFLAGS='@DCFLAGS@'} if test x"$DC" = x; then - BISON_DC_WORKS=false + BISON_DC_WORKS=false else - BISON_DC_WORKS=true + BISON_DC_WORKS=true fi # Empty if no javac was found