mirror of
https://github.com/sheumann/hush.git
synced 2024-11-05 06:07:00 +00:00
awk: fix length(array)
function old new delta evaluate 3526 3548 +22 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
1d30b3f1f6
commit
7985bc109e
@ -2784,8 +2784,16 @@ static var *evaluate(node *op, var *res)
|
||||
break;
|
||||
|
||||
case F_le:
|
||||
if (!op1)
|
||||
debug_printf_eval("length: L.s:'%s'\n", L.s);
|
||||
if (!op1) {
|
||||
L.s = getvar_s(intvar[F0]);
|
||||
debug_printf_eval("length: L.s='%s'\n", L.s);
|
||||
}
|
||||
else if (L.v->type & VF_ARRAY) {
|
||||
R_d = L.v->x.array->nel;
|
||||
debug_printf_eval("length: array_len:%d\n", L.v->x.array->nel);
|
||||
break;
|
||||
}
|
||||
R_d = strlen(L.s);
|
||||
break;
|
||||
|
||||
|
@ -274,6 +274,11 @@ testing "awk large integer" \
|
||||
"2147483647 2147483647 0 2147483648 2147483648 0\n" \
|
||||
"" ""
|
||||
|
||||
testing "awk length(array)" \
|
||||
"awk 'BEGIN{ A[1]=2; A["qwe"]="asd"; print length(A)}'" \
|
||||
"2\n" \
|
||||
"" ""
|
||||
|
||||
# testing "description" "command" "result" "infile" "stdin"
|
||||
|
||||
exit $FAILCOUNT
|
||||
|
Loading…
Reference in New Issue
Block a user