From 558c14cccdf2749647983537d3c0d1ad3aeca247 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sat, 20 Aug 2022 08:23:58 +0300 Subject: [PATCH] =?UTF-8?q?fix=20fill=20of=20empty=20=F0=9D=95=A8=E2=8A=8F?= =?UTF-8?q?=F0=9D=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/select.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/builtins/select.c b/src/builtins/select.c index ade808a6..85781311 100644 --- a/src/builtins/select.c +++ b/src/builtins/select.c @@ -45,18 +45,20 @@ B select_c2(B t, B w, B x) { if (xr==1) { if (wia==0) { decG(x); - if (isVal(xf)) { - Arr* ra = m_fillarrp(0); - arr_shCopy(ra, w); - fillarr_setFill(ra, xf); - r = taga(ra); - } else if (rnk(w)==1) { - r = isNum(xf)? emptyIVec() : emptyCVec(); - } else { - Arr* ra = m_arr(sizeof(TyArr), isNum(xf)? t_i8arr : t_c8arr, 0); - arr_shCopy(ra, w); - r = taga(ra); + if (rnk(w)==1) { + if (isNum(xf)) { r = emptyIVec(); goto ret; } + if (isC32(xf)) { r = emptyCVec(); goto ret; } } + Arr* ra; + if (isNum(xf) || isC32(xf)) { + ra = m_arr(sizeof(TyArr), isNum(xf)? t_i8arr : t_c8arr, 0); + } else { + ra = m_fillarrp(0); + fillarr_setFill(ra, xf); + } + arr_shCopy(ra, w); + r = taga(ra); + ret: decG(w); return r; }