Hi Mohan,

I have attached the patch file .

Hope it helps .

Thanks
Rohith
On Thursday 14 November 2013 03:51 PM, Mohan Gorai wrote:
Hi Josh,

Thanks for the response.

From the output below, I see that we do have the arrary elements with the strings as index created. But, an extra array member is being created for every multidimensional associative array.

$ echo "${.sh.version}"
Version JM 93u 2011-02-08
$ typeset -A foo
$ typeset -A foo[bar]
$ typeset -A foo[baz]
$ foo[bar][cat]=1
$ foo[bar][dog]=2
$ foo[baz][mouse]=3
$ foo[baz][fish]=4
$ set | fgrep foo
_='foo[baz]'
foo=([bar]=([0]='' [cat]=1 [dog]=2) [baz]=([0]='' [fish]=4 [mouse]=3) )
$


But with the alpha release, I don't see the extra element.

$ echo "${.sh.version}"
Version AIJMP 93v- 2013-10-08
$ typeset -A foo
$ typeset -A foo[bar]
$ typeset -A foo[baz]
$ foo[bar][cat]=1
$ foo[bar][dog]=2
$ foo[baz][mouse]=3
$ foo[baz][fish]=4
$ set | fgrep foo
_='foo[baz]'
foo=([bar]=([cat]=1 [dog]=2) [baz]=([fish]=4 [mouse]=3) )
$

So it looks to me that ksh93 does support the associative arrays with more than one dimension.

Am I missing something here?

Thanks,
~gmr



On Thu, Nov 14, 2013 at 3:16 PM, Joshuah Hurst <[email protected] <mailto:[email protected]>> wrote:

    On Thu, Nov 14, 2013 at 8:26 AM, Mohan Gorai <[email protected]
    <mailto:[email protected]>> wrote:
    > Hi ,
    >
    > I'm using to ksh93 scripts in my application to do various jobs
    . while
    > using double associative arrays i found the below :
    >
    > # typeset -A foo
    > # typeset -A foo[bar]
    > # typeset -A foo[baz]
    > # foo[bar][cat]=1
    > # foo[bar][dog]=2
    > # foo[baz][mouse]=3
    > # foo[baz][fish]=4
    > # set | fgrep foo
    > _='foo[baz]'
    > foo=([bar]=([cat]=1 [dog]=2) [baz]=([0]='' [fish]=4 [mouse]=3) )
    >
    > <<== foo[baz][0] is inserted unexpectedly
    >
    > Found that it's being fixed in alpha release as part of the below
    >
    > 12-08-20  A bug in which creating a two dimemsional associative
    array could
    >  add an extra 0 element to the second subscript has been fixed.
    >
    > could someone help me the patch file so that i can patch my binary
    > accordingly .

    ksh93 does not support multidimensional associative arrays.
    Only indexed multidimensional arrays are supported. If you wish to do
    the same for associative arrays just append the strings.

    The 12-08-20 issue you're referring to was a bug which tried to create
    multidimensional indexed arrays using string as index, which are
    equivalent to the arithmetic value 0 if they are not defined variables
    yet and set -o nounset was not set.

    Arguably the right fix here is that ksh93 should throw an error if
    someone tried to use an associative array with more than one
    dimension.

    Josh




_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

--- a/src/cmd/ksh93/sh/array.c    2013-11-15 16:48:32.816237858 +0530
+++ b/src/cmd/ksh93/sh/array.c    2013-11-15 16:47:26.360240354 +0530
@@ -1003,7 +1003,7 @@
                ap->nelem = nelem;
                ap->fun = fun;
                nv_onattr(np,NV_ARRAY);
-               if(fp || value) 
+               if(fp || (value && value!=Empty))
                {
                        nv_putsub(np, "0", ARRAY_ADD);
                        if(value)

_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to