Hi!

----

The following testcase...
-- snip --
namespace xmlfragmentparser
{
typeset -T parser_t=(
        typeset -a data  # "raw" data from .sh.match
        compound -a context     # parsed tag data

        function build_context
        {
                typeset dummy
                typeset attrdata # data after "<tag" ...

                integer i
                for (( i = 0 ; i < ${#_.data[@]} ; i++ )) ; do
                        nameref currc=_.context[i] # current context

                        dummy="${_.data[i]/~(El)<([:_[:alnum:]-]+)(.*)>/X}"
                        currc.tagname="${.sh.match[1]}"
                        attrdata="${.sh.match[2]}"

                        if [[ "${attrdata}" != ~(Elr)[[:space:]]* ]] ; then
                                dummy="${attrdata//~(Ex-p)(?:
                                                [[:space:]]+
                                                ( # four different types of 
name=value syntax
                                                        
(?:([:_[:alnum:]-]+)=([^\"\'[:space:]]+?))|     #x='foo=bar huz=123'
                                                        
(?:([:_[:alnum:]-]+)=\"([^\"]*?)\")|        #x='foo="ba=r o" huz=123'
                                                        
(?:([:_[:alnum:]-]+)=\'([^\']*?)\')|        #x="foox huz=123"
                                                        (?:([:_[:alnum:]-]+))   
                   #x="foox huz=123"
                                                )
                                        )/D}"

                                integer j k numadded
                                compound -a currc.attrs
                                nameref attrs=currc.attrs
                                for (( j=0 ; j < ${#.sh.match[0][@]} ; j++ )) ; 
do
                                        if [[ -v .sh.match[2][j] && -v 
.sh.match[3][j] ]] ; then
                                                attrs+=( 
name="${.sh.match[2][j]}" value="${.sh.match[3][j]}" )
                                                (( numadded++ ))
                                        elif [[ -v .sh.match[4][j] && -v 
.sh.match[5][j] ]] ; then
                                                attrs+=( 
name="${.sh.match[4][j]}" value="${.sh.match[5][j]}" )
                                                (( numadded++ ))
                                        elif [[ -v .sh.match[6][j] && -v 
.sh.match[7][j] ]] ; then
                                                attrs+=( 
name="${.sh.match[6][j]}" value="${.sh.match[7][j]}" )
                                                (( numadded++ ))
                                        fi
                                done

                                [[ "$(print -v _.context[i])"     == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print -v _.context[i] does not have member variable
attrs\n'
                                [[ "$(print -C _.context[i])"     == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print -C _.context[i] does not have member variable
attrs\n'
                                [[ "$(print -v xd.context[i])"    == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print -v xd.context[i] does not have member variable
attrs\n'
                                [[ "$(print -C xd.context[i])"    == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print -C xd.context[i] does not have member variable
attrs\n'
                                [[ "$(print "${_.context[i]}")"   == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print ${_.context[i]} does not have member variable
attrs\n'
                                [[ "$(print "${xd.context[i]}")"  == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print ${xd.context[i]} does not have member variable
attrs\n'
                                [[ "$(print -v _.context[$i])"    == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print -v _.context[$i] does not have member variable
attrs\n'
                                [[ "$(print -C _.context[$i])"    == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print -C _.context[$i] does not have member variable
attrs\n'
                                [[ "$(print "${_.context[$i]}")"  == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print ${_.context[$i]} does not have member variable
attrs\n'
                                [[ "$(print "${xd.context[$i]}")" == *attrs* ]] 
|| print -u2 -f
'Assertion fail: print ${xd.context[$i]} does not have member variable
attrs\n'
                                [[ "$(print -v currc)"   == *attrs* ]] || print 
-u2 -f 'Assertion
fail: print -v currc does not have member variable attrs\n'
                                [[ "$(print -C currc)"   == *attrs* ]] || print 
-u2 -f 'Assertion
fail: print -C currc does not have member variable attrs\n'
                                [[ "$(print "${currc}")" == *attrs* ]] || print 
-u2 -f 'Assertion
fail: print $currc does not have member variable attrs\n'
                                (( ${#_.context[$i].attrs[@]} == numadded )) || 
print -u2 -f
'Assertion fail: #_.context[$i].attrs[@] %d!=%d\n'
"${#currc.attrs[@]}" numadded
                                (( ${#_.context[i].attrs[@]} == numadded )) || 
print -u2 -f
'Assertion fail: #_.context[i].attrs[@] %d!=%d\n' "${#currc.attrs[@]}"
numadded
                                (( ${#currc.attrs[@]} == numadded )) || print 
-u2 -f 'Assertion
fail: #currc.attrs[@] %d!=%d\n' "${#currc.attrs[@]}" numadded
                                (( ${#attrs[@]}       == numadded )) || print 
-u2 -f 'Assertion
fail: #attrs[@] %d!=%d\n' "${#currc.attrs[@]}" numadded

                                ( ulimit -c 0; eval 'integer 
_.context[$i].a_number=1' ) || print
-u2 -f 'Assertion fail: integer _.context[$i].a_number=1 triggered
syntax error\n'
                        fi
                done

        }
)
}

# main
set -o nounset

.xmlfragmentparser.parser_t xd # xml document
xd.data=( "<foo x='1' y='2' />" "<bar a='1' b='2' />" )
xd.build_context

#print "$xd"
-- snip --

... should AFAIK print nothing...

... but ast-ksh.2012-08-31 (ksh93v- alpha) triggers a lot of asserts
in the code:
-- snip --
Assertion fail: print -v _.context[i] does not have member variable attrs
Assertion fail: print -C _.context[i] does not have member variable attrs
Assertion fail: print -v xd.context[i] does not have member variable attrs
Assertion fail: print -C xd.context[i] does not have member variable attrs
Assertion fail: print ${_.context[i]} does not have member variable attrs
Assertion fail: print ${xd.context[i]} does not have member variable attrs
Assertion fail: print -v _.context[$i] does not have member variable attrs
Assertion fail: print -C _.context[$i] does not have member variable attrs
Assertion fail: print ${_.context[$i]} does not have member variable attrs
Assertion fail: print ${xd.context[$i]} does not have member variable attrs
Assertion fail: print -v currc does not have member variable attrs
Assertion fail: print -C currc does not have member variable attrs
Assertion fail: print $currc does not have member variable attrs
Assertion fail: #_.context[$i].attrs[@] 2!=4
Assertion fail: #_.context[i].attrs[@] 2!=4
Assertion fail: #currc.attrs[@] 2!=4
Assertion fail: #attrs[@] 2!=4
ksh93_typeset_T_nameref_indexed_array_test004.sh[78]:
xd.build_context[65]: eval[1]: typeset: $i: arithmetic syntax error
Assertion fail: integer _.context[$i].a_number=1 triggered syntax error
Assertion fail: integer _.context[$i].a_number=1 triggered syntax error
etc. etc.
-- snip --

I've attached the testcase as
"ksh93v_typeset_T_nameref_indexed_array_test004.sh.gz", too...

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.ma...@nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)

Attachment: ksh93v_typeset_T_nameref_indexed_array_test004.sh.gz
Description: GNU Zip compressed data

_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to