Discussion:
[ast-developers] Double Associative arrays patch help request
Mohan Gorai
2013-11-14 07:26:10 UTC
Permalink
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 .


Appreciate any help here .

Thanks!,
~gmr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131114/3cefc57c/attachment.html>
Joshuah Hurst
2013-11-14 09:46:26 UTC
Permalink
Post by Mohan Gorai
Hi ,
I'm using to ksh93 scripts in my application to do various jobs . while
# 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
Mohan Gorai
2013-11-14 10:21:35 UTC
Permalink
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
Post by Mohan Gorai
Hi ,
I'm using to ksh93 scripts in my application to do various jobs . while
# 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
Post by Mohan Gorai
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131114/c55d798d/attachment.html>
Rohith
2013-11-15 18:55:27 UTC
Permalink
Hi Mohan,

I have attached the patch file .

Hope it helps .

Thanks
Rohith
Post by Mohan Gorai
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 <joshhurst at gmail.com
On Thu, Nov 14, 2013 at 8:26 AM, Mohan Gorai <mohangorai at gmail.com
Post by Mohan Gorai
Hi ,
I'm using to ksh93 scripts in my application to do various jobs
. while
Post by Mohan Gorai
# 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
Post by Mohan Gorai
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
ast-developers at lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131116/efa4a0c9/attachment.html>
-------------- next part --------------
--- 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)
David Korn
2013-11-15 21:40:58 UTC
Permalink
That is the correct patch. Thanks.
Post by Rohith
Hi Mohan,
I have attached the patch file .
Hope it helps .
Thanks
Rohith
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
Post by Joshuah Hurst
Post by Mohan Gorai
Hi ,
I'm using to ksh93 scripts in my application to do various jobs . while
# 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
Post by Mohan Gorai
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 listast-developers at lists.research.att.comhttp://lists.research.att.com/mailman/listinfo/ast-developers
_______________________________________________
ast-developers mailing list
ast-developers at lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131115/e469821f/attachment.html>
Mohan Gorai
2013-11-16 01:38:31 UTC
Permalink
Thanks Rohith / David for the patch.

cheers,
~gmr
Post by David Korn
That is the correct patch. Thanks.
Post by Rohith
Hi Mohan,
I have attached the patch file .
Hope it helps .
Thanks
Rohith
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
Post by Joshuah Hurst
Post by Mohan Gorai
Hi ,
I'm using to ksh93 scripts in my application to do various jobs . while
# 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
Post by Mohan Gorai
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 listast-developers at lists.research.att.comhttp://lists.research.att.com/mailman/listinfo/ast-developers
_______________________________________________
ast-developers mailing list
ast-developers at lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131116/4fccfa59/attachment-0001.html>
Rohith
2013-11-18 08:18:57 UTC
Permalink
Hi David ,

I was curious to know . Generally is there a place where one can find
the patches for the relevant bugs ?
Do we maintain it somewhere ?

Thanks In Advance
Rohith
Post by Mohan Gorai
Thanks Rohith / David for the patch.
cheers,
~gmr
On Sat, Nov 16, 2013 at 3:10 AM, David Korn <dgkorn at gmail.com
That is the correct patch. Thanks.
On Fri, Nov 15, 2013 at 1:55 PM, Rohith <rohith.ramesh at oracle.com
Hi Mohan,
I have attached the patch file .
Hope it helps .
Thanks
Rohith
Post by Mohan Gorai
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
On Thu, Nov 14, 2013 at 8:26 AM, Mohan Gorai
Post by Mohan Gorai
Hi ,
I'm using to ksh93 scripts in my application to do
various jobs . while
Post by Mohan Gorai
# 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) )
Post by Mohan Gorai
<<== foo[baz][0] is inserted unexpectedly
Found that it's being fixed in alpha release as part of
the below
Post by Mohan Gorai
12-08-20 A bug in which creating a two dimemsional
associative array could
Post by Mohan Gorai
add an extra 0 element to the second subscript has
been fixed.
Post by Mohan Gorai
could someone help me the patch file so that i can
patch my binary
Post by Mohan Gorai
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
ast-developers at lists.research.att.com <mailto:ast-developers at lists.research.att.com>
http://lists.research.att.com/mailman/listinfo/ast-developers
_______________________________________________
ast-developers mailing list
ast-developers at lists.research.att.com
<mailto:ast-developers at lists.research.att.com>
http://lists.research.att.com/mailman/listinfo/ast-developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131118/d0050635/attachment-0001.html>
Continue reading on narkive:
Search results for '[ast-developers] Double Associative arrays patch help request' (Questions and Answers)
16
replies
help with puppy training!!!?
started 2007-07-06 02:07:17 UTC
dogs
Loading...