mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
I did not realize that lvalue->nosub and lvalue->sub variables are not reset when another assignment occurs later down the line. Example: (( arr[0][1]+=1, arr[2]=7 )) src/cmd/ksh93/sh/arith.c: arith(): - For assignment operations, reset lvalue's nosub and sub variables so the target for the next assignment is not redirected. src/cmd/ksh93/tests/arrays2.sh: - Add in a few regression tests that utilize compound arithmetic expressions having at least an assignment operation (+=) followed by a normal assignment (=).
This commit is contained in:
parent
a197b0427a
commit
655c4be1c1
2 changed files with 7 additions and 1 deletions
|
|
@ -234,10 +234,13 @@ static Sfdouble_t arith(const char **ptr, struct lval *lvalue, int type, Sfdoubl
|
|||
case ASSIGN:
|
||||
{
|
||||
register Namval_t *np;
|
||||
if (lvalue->nosub > 0 && lvalue->sub) /* indexed array ARITH_ASSIGNOP */
|
||||
if (lvalue->sub && lvalue->nosub > 0) /* indexed array ARITH_ASSIGNOP */
|
||||
{
|
||||
np = (Namval_t*)lvalue->sub; /* use saved subscript reference instead of last worked value */
|
||||
nv_putsub(np, NIL(char*), lvalue->nosub-1);
|
||||
/* reset nosub and sub for next assignment in a compound arithmetic expression */
|
||||
lvalue->nosub = 0;
|
||||
lvalue->sub = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue