Discussion:
[ast-developers] bool assignments not working with ?: operator
Wendy Lin
2013-07-23 07:48:13 UTC
Permalink
I found a critical issue with using bool and assigning a value using
the ?: operator:

ksh -c 'set -o nounset ; bool -a b ; integer i=1 ; ((
b[4][i]=((i==1)?(true):(false)) ))'
/home/wlin/bin/ksh: true: parameter not se

Any patch or workaround would be very welcome. I need it urgently.

ksh --version
version sh (AT&T Research) 93v- 2013-07-18

Wendy
David Korn
2013-07-23 18:20:52 UTC
Permalink
cc: ast-developers at research.att.com
Subject: Re: bool assignments not working with ?: operator
--------

Try the following patch:
====================cut here======================
--- old/sh/streval.c Tue Jun 18 15:07:11 2013
+++ new/sh/streval.c Tue Jul 23 14:06:52 2013
@@ -238,6 +238,8 @@
node.level = level;
node.nosub = 0;
node.nextop = *cp;
+ if(node.nextop == A_JMP)
+ node.nextop = ((unsigned char*)ep)[*((short*)roundptr(ep,cp,short))];
num = (*ep->fun)(&ptr,&node,VALUE,num);
if(node.emode&ARITH_ASSIGNOP)
{
====================cut here======================

David Korn
dgk at research.att.com
David Korn
2013-07-23 18:49:35 UTC
Permalink
cc: ast-developers at research.att.com
Subject: Re: bool assignments not working with ?: operator
--------

There was a mistake in the patch I sent. Here is the corrected version.

===============cut here=====================
--- old/sh/streval.c Tue Jun 18 15:07:11 2013
+++ new/sh/streval.c Tue Jul 23 14:06:52 2013
@@ -238,6 +238,8 @@
node.level = level;
node.nosub = 0;
node.nextop = *cp;
+ if(node.nextop == A_JMP)
+ node.nextop = ((unsigned char*)ep)[*((short*)roundptr(ep,cp+1,short))];
num = (*ep->fun)(&ptr,&node,VALUE,num);
if(node.emode&ARITH_ASSIGNOP)
{
===============cut here=====================

David Korn
dgk at research.att.com
Roland Mainz
2013-07-25 00:54:08 UTC
Permalink
Post by David Korn
cc: ast-developers at research.att.com
Subject: Re: bool assignments not working with ?: operator
--------
There was a mistake in the patch I sent. Here is the corrected version.
===============cut here=====================
--- old/sh/streval.c Tue Jun 18 15:07:11 2013
+++ new/sh/streval.c Tue Jul 23 14:06:52 2013
@@ -238,6 +238,8 @@
node.level = level;
node.nosub = 0;
node.nextop = *cp;
+ if(node.nextop == A_JMP)
+ node.nextop = ((unsigned char*)ep)[*((short*)roundptr(ep,cp+1,short))];
num = (*ep->fun)(&ptr,&node,VALUE,num);
if(node.emode&ARITH_ASSIGNOP)
{
===============cut here=====================
The 2nd patch fixes the problem... :-)
... I'll add a test to the "bool.sh" test module...

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Wendy Lin
2013-07-25 10:41:16 UTC
Permalink
Post by Roland Mainz
Post by David Korn
cc: ast-developers at research.att.com
Subject: Re: bool assignments not working with ?: operator
--------
There was a mistake in the patch I sent. Here is the corrected version.
===============cut here=====================
--- old/sh/streval.c Tue Jun 18 15:07:11 2013
+++ new/sh/streval.c Tue Jul 23 14:06:52 2013
@@ -238,6 +238,8 @@
node.level = level;
node.nosub = 0;
node.nextop = *cp;
+ if(node.nextop == A_JMP)
+ node.nextop = ((unsigned char*)ep)[*((short*)roundptr(ep,cp+1,short))];
num = (*ep->fun)(&ptr,&node,VALUE,num);
if(node.emode&ARITH_ASSIGNOP)
{
===============cut here=====================
The 2nd patch fixes the problem... :-)
... I'll add a test to the "bool.sh" test module...
Roland, thank you for testing this

Wendy

Loading...