fix postun in not evaluated side of e.g. ternary operator (LP#1187729)
This commit is contained in:
parent
bd795a83ae
commit
3bc3e8665a
18
check.t
18
check.t
|
@ -1,4 +1,4 @@
|
||||||
# $MirOS: src/bin/mksh/check.t,v 1.617 2013/07/21 18:35:57 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.618 2013/07/21 18:38:53 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
|
@ -292,6 +292,22 @@ stdin:
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
= 4 2 =
|
= 4 2 =
|
||||||
---
|
---
|
||||||
|
name: arith-lazy-4
|
||||||
|
description:
|
||||||
|
Check that preun/postun not done on non-evaluated side of ternary
|
||||||
|
operator
|
||||||
|
stdin:
|
||||||
|
(( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
|
||||||
|
echo "($n, $m)"
|
||||||
|
m=0; echo $(( 0 ? ++m : 2 )); echo $m
|
||||||
|
m=0; echo $(( 0 ? m++ : 2 )); echo $m
|
||||||
|
expected-stdout:
|
||||||
|
(1, 0)
|
||||||
|
2
|
||||||
|
0
|
||||||
|
2
|
||||||
|
0
|
||||||
|
---
|
||||||
name: arith-ternary-prec-1
|
name: arith-ternary-prec-1
|
||||||
description:
|
description:
|
||||||
Check precedence of ternary operator vs assignment
|
Check precedence of ternary operator vs assignment
|
||||||
|
|
12
expr.c
12
expr.c
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.71 2013/05/31 23:27:13 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.72 2013/07/21 18:38:56 tg Exp $");
|
||||||
|
|
||||||
/* the order of these enums is constrained by the order of opinfo[] */
|
/* the order of these enums is constrained by the order of opinfo[] */
|
||||||
enum token {
|
enum token {
|
||||||
|
@ -321,10 +321,12 @@ do_ppmm(Expr_state *es, enum token op, struct tbl *vasn, bool is_prefix)
|
||||||
++vl->val.u;
|
++vl->val.u;
|
||||||
else
|
else
|
||||||
--vl->val.u;
|
--vl->val.u;
|
||||||
if (vasn->flag & INTEGER)
|
if (!es->noassign) {
|
||||||
setint_v(vasn, vl, es->arith);
|
if (vasn->flag & INTEGER)
|
||||||
else
|
setint_v(vasn, vl, es->arith);
|
||||||
setint(vasn, vl->val.i);
|
else
|
||||||
|
setint(vasn, vl->val.i);
|
||||||
|
}
|
||||||
if (!is_prefix)
|
if (!is_prefix)
|
||||||
/* undo the increment/decrement */
|
/* undo the increment/decrement */
|
||||||
vl->val.u = oval;
|
vl->val.u = oval;
|
||||||
|
|
Loading…
Reference in New Issue