-# $MirOS: contrib/hosted/tg/assockit.ksh,v 1.6 2014/11/02 18:05:19 tg Exp $
+# $MirOS: contrib/hosted/tg/assockit.ksh,v 1.6+wip 2014/11/02 18:05:19 tg Exp $
# -*- mode: sh -*-
#-
-# Copyright © 2011, 2013
-# Thorsten “mirabilos” Glaser <tg@mirbsd.org>
-# Copyright © 2013
-# Thorsten Glaser <t.glaser@tarent.de>
+# Copyright © 2011, 2013, 2015
+# mirabilos <m@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
# look up the item, creating paths as needed
asso__lookup 1 "$@"
# if it’s an array, free that recursively
- if (( (_f = asso_f) & ASSO_MASK_ARR )); then
+ if (( ((_f = asso_f) & ASSO_MASK_ARR) == ASSO_MASK_ARR )); then
asso__r_free 1
(( _f &= ~ASSO_MASK_TYPE ))
fi
set -A asso_y
asso__lookup 0 "$@" || return 1
- (( asso_f & ASSO_MASK_ARR )) || return 1
+ (( (asso_f & ASSO_MASK_ARR) == ASSO_MASK_ARR )) || return 1
nameref _keys=${asso_b}${asso_k#16#}_k
set -A asso_y -- "${_keys[@]}"
}
local _f _v
asso__lookup 1 "$@"
- if (( !((_f = asso_f) & ASSO_MASK_ARR) )); then
+ if (( ((_f = asso_f) & ASSO_MASK_ARR) != ASSO_MASK_ARR )); then
nameref _Av=${asso_b}_v
_v=${_Av[asso_k]}
elif (( (_f & ASSO_MASK_TYPE) == ASSO_AIDX )); then
fi
asso__r_free 1
asso__r_setf $ASSO_AIDX
- if (( !(_f & ASSO_MASK_ARR) )); then
+ if (( (_f & ASSO_MASK_ARR) != ASSO_MASK_ARR )); then
asso__lookup 1 "$@" 0
asso__r_setfv $_f "$_v"
fi
local _f
asso__lookup 1 "$@"
- if (( !((_f = asso_f) & ASSO_MASK_ARR) )); then
+ if (( ((_f = asso_f) & ASSO_MASK_ARR) != ASSO_MASK_ARR )); then
asso__r_free 1
asso__r_setf $ASSO_AASS
elif (( (_f & ASSO_MASK_TYPE) == ASSO_AIDX )); then
# look up the item, creating paths as needed
asso__lookup 1 "$@"
# if it’s an array, free that recursively
- if (( (_f = asso_f) & ASSO_MASK_ARR )); then
+ if (( ((_f = asso_f) & ASSO_MASK_ARR) == ASSO_MASK_ARR )); then
asso__r_free 1
fi
(( _f = (_f & ~ASSO_MASK_TYPE) | _t ))
(( $? < 2 ))
return
fi
- (( _t & ASSO_MASK_ARR )) && return 1
+ (( (_t & ASSO_MASK_ARR) == ASSO_MASK_ARR )) && return 1
# ASSO_REAL
[[ $_v = ?(-)@(0|[1-9]*([0-9]))?(.+([0-9]))?([Ee]?([+-])+([0-9])) ]]
}
_r=0
asso_f=$ASSO_AASS
for _k in "$@"; do
- if (( _r || !(asso_f & ASSO_MASK_ARR) )); then
+ if (( _r || (asso_f & ASSO_MASK_ARR) != ASSO_MASK_ARR )); then
(( _r )) || asso__r_free 1
asso__r_setf $ASSO_AASS
elif (( (asso_f & ASSO_MASK_TYPE) == ASSO_AIDX )); then
asso_f=${_Af[asso_k]}
(( asso_f & ASSO_ALLOC )) || return
if (( asso_f & ASSO_ISSET )); then
- if (( asso_f & ASSO_MASK_ARR )); then
+ if (( (asso_f & ASSO_MASK_ARR) == ASSO_MASK_ARR )); then
local _ob=$asso_b _ok=$asso_k
asso_b=$asso_b${asso_k#16#}
nameref _s=${asso_b}_f