On Sun, Jan 20, 2013 at 10:43 PM, Roland Mainz <[email protected]> wrote:
> We found some issues with the initalisation of multidimensional
> indexed arrays in ast-ksh.2012-11-21.
> The following example is AFAIK completely correct...
> -- snip --
> $ ksh -c 'compound x ; integer -a x.ar=( [4]=( [9]=7 ) ) ; print -v x'
> (
>         typeset -a -l -i ar=(
>                 [4]=(
>                         [9]=7
>                 )
>         )
> )
> -- snip --
> ... but if I slightly vary the initalisation the output becomes IMO
> corrupted (note the extra "typeset -a [4]" instead of just "[4]"):
> -- snip --
> $ ksh -c 'compound x ; integer -a x.ar=( [4][9]=7 ) ; print -v x'
> (
>         typeset -a -l -i ar=(
>                 typeset -a [4]=(
>                         [9]=7
>                 )
>         )
> )
> -- snip --
>
> Same issue (and wrong output, e.g. "typeset -a [4]=(" instead of the
> expected "[4]=(") happens for this variation:
> -- snip --
> $ ksh -c 'compound x ; integer -a x.ar; x.ar[4][9]=7 ; print -v x'
> (
>         typeset -a -l -i ar=(
>                 typeset -a [4]=(
>                         [9]=7
>                 )
>         )
> )
> -- snip --

Below is a set of testcases for src/cmd/ksh93/tests/arrays.sh ...
expected output is "nothing":
-- snip --
alias err_exit='print -u2 '

x1=$( { compound x ; integer -a x.ar=( [4]=( [9]=7 ) )        ; print
-v x ; } 2>&1 ; )
x2=$( { compound x ; integer -a x.ar=( [4][9]=7 )             ; print
-v x ; } 2>&1 ; )
x3=$( { compound x ; integer -a x.ar ; x.ar=( [4][9]=7 )      ; print
-v x ; } 2>&1 ; )
x4=$( { compound x ; integer -a x.ar ; x.ar=( [4]=( [9]=7 ) ) ; print
-v x ; } 2>&1 ; )

[[ "$x1" == "$x2" ]] || err_exit "multidim arr initalisation x1 != x2"
[[ "$x1" == "$x3" ]] || err_exit "multidim arr initalisation x1 != x3"
[[ "$x1" == "$x4" ]] || err_exit "multidim arr initalisation x1 != x4"
[[ "$x2" == "$x3" ]] || err_exit "multidim arr initalisation x2 != x3"
[[ "$x2" == "$x4" ]] || err_exit "multidim arr initalisation x2 != x4"
[[ "$x3" == "$x4" ]] || err_exit "multidim arr initalisation x3 != x4"
-- snip --

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to