Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh PR/50827: Richard Hansen: Fix default variable assign...
details: https://anonhg.NetBSD.org/src/rev/2a97e90a7e00
branches: trunk
changeset: 343656:2a97e90a7e00
user: christos <christos%NetBSD.org@localhost>
date: Fri Feb 19 13:50:37 2016 +0000
description:
PR/50827: Richard Hansen: Fix default variable assignment with arithmetic,
from kre.
diffstat:
bin/sh/parser.c | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diffs (75 lines):
diff -r 9a34a3caf0b7 -r 2a97e90a7e00 bin/sh/parser.c
--- a/bin/sh/parser.c Fri Feb 19 13:49:01 2016 +0000
+++ b/bin/sh/parser.c Fri Feb 19 13:50:37 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parser.c,v 1.93 2014/08/29 09:35:19 christos Exp $ */
+/* $NetBSD: parser.c,v 1.94 2016/02/19 13:50:37 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
#else
-__RCSID("$NetBSD: parser.c,v 1.93 2014/08/29 09:35:19 christos Exp $");
+__RCSID("$NetBSD: parser.c,v 1.94 2016/02/19 13:50:37 christos Exp $");
#endif
#endif /* not lint */
@@ -931,6 +931,15 @@
else \
dblquotep[(varnest / 32) - 1] &= ~(1 << (varnest % 32))
+#define INCREASENEST() \
+ do { \
+ if (varnest++ >= maxnest) { \
+ dblquotep = ckrealloc(dblquotep, maxnest / 8); \
+ dblquotep[(maxnest / 32) - 1] = 0; \
+ maxnest += 32; \
+ } \
+ } while (/*CONSTCOND*/0)
+
STATIC int
readtoken1(int firstc, char const *syn, char *eofmark, int striptabs)
{
@@ -1106,13 +1115,11 @@
--parenlevel;
} else {
if (pgetc() == ')') {
+ if (varnest > 0) /* always */
+ varnest--;
if (--arinest == 0) {
USTPUTC(CTLENDARI, out);
syntax = prevsyntax;
- if (syntax == DQSYNTAX)
- SETDBLQUOTE();
- else
- CLRDBLQUOTE();
} else
USTPUTC(')', out);
} else {
@@ -1377,14 +1384,8 @@
if (ISDBLQUOTE() || arinest)
flags |= VSQUOTE;
*(stackblock() + typeloc) = subtype | flags;
- if (subtype != VSNORMAL) {
- varnest++;
- if (varnest >= maxnest) {
- dblquotep = ckrealloc(dblquotep, maxnest / 8);
- dblquotep[(maxnest / 32) - 1] = 0;
- maxnest += 32;
- }
- }
+ if (subtype != VSNORMAL)
+ INCREASENEST();
}
goto parsesub_return;
}
@@ -1562,6 +1563,7 @@
*/
USTPUTC('(', out);
}
+ INCREASENEST();
goto parsearith_return;
}
Home |
Main Index |
Thread Index |
Old Index