From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3346 invoked from network); 1 Dec 2020 09:14:07 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Dec 2020 09:14:07 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1606814047; b=FjuLoEnF20nwwH/LKJBWoAWimnv91BCRV1LccKGEt6Ndoa807gzQXTLPRDdMvUtdT0a/lcNSbR tzsWi411fvrwV/x0J/ppa5Kz7sHGwe4CrcbN4/AZ8JAWTJPPDya8ttaPSjg2+H5/lvmXJ6mp7W ZL5KrUfEJiN0wpHVM5CtmmV6+6NZDaJdR1xIPUuaESOval9JiHx1RpbfgwfSNyQOLZlLRcoVju ROGt4UT6svHTT/l6LtgzO2zw4tO8IHzoFnkangOGBDnkn5wbY/Gc1t6vpyciKdn/jyiNJh9mm/ u5V/vJcrzpwqRuy3eOrA319dAPYamB12swApe9f6RunsDw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f194.google.com) smtp.remote-ip=209.85.167.194; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1606814047; bh=LNVqmI9VskB1isbDRjYR1U9zGArnjdkihc2W16Yx1Nk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:Cc:To:From:DKIM-Signature:DKIM-Signature; b=GbyS5hkUEU4FWyw9GiE9udisA/xOFbHUoa4wHwflMz3ntvDfyr5ZxGYxbL7uQvg3KEWY0TKKpi aWt30I5yHtMeQrFShD2KLNuD2hs/lVN0maeXmj3svBAnvMKPQYeEOSTadwTpXaOyEPxDa13JXG 6ziJbGzVbXadzCoExz3AYzRVmqDg/iAyPHjRLHcZPSOZyJmMOZks4o9ofsxg9tx5RFbpwfmEyo HxQ6kkyswOxc3WUa844C4WeAdDmBOrEpAdR9vc1ZLixKWrkn6hkERtksH6EZEeBe+ZG9QkbjXa 0Hpr7JTwtxxELPusiHoL95SYdAM0Fw6TmKTGg4YdWgA6SQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=qWJbhNNKYpdUnqUdiyY31FlBX96s2hVvtyph0o78I6U=; b=OIHak0tu6d+5IpwbNKjzYDXmlE dqwCRpMHV+ADGGqBPRj7Bk/663UyZTvKcG/Db83AozkxuH/aNoeWBqdMzrr8uFkwIZ1KjdorhR7Jx zgQAgo4Zc5s5ROrgA1jdAjkqtpnL3yKRSZSiqwCqiPboSoZMgZPLTBnSoMAjG5ViBI1jC+xzcqqpD ZODQna0kHaZHJZReG4YM81fj43l2JDN4lzIcYuGjWxCPwOfeJvlg2atjnNAXGdOa8KC2HS6RInbCW 1CJQcQW/QcvqvO6WyVVQlPCwZ0Cd/nr3cfUmtJy62XgXX3J1+CSaSikgMQiTV4so6FHxi9UBbCgD2 xZ3MkRCg==; Received: from authenticated user by zero.zsh.org with local id 1kk1jY-0007A2-7g; Tue, 01 Dec 2020 09:14:04 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f194.google.com) smtp.remote-ip=209.85.167.194; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-oi1-f194.google.com ([209.85.167.194]:42431) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kk1jF-0006EO-R8; Tue, 01 Dec 2020 09:13:46 +0000 Received: by mail-oi1-f194.google.com with SMTP id v202so1038116oia.9 for ; Tue, 01 Dec 2020 01:13:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qWJbhNNKYpdUnqUdiyY31FlBX96s2hVvtyph0o78I6U=; b=k/Z4pkDa2FKb6l86PkrOFb+Eid86HovWOdeN1l+1Bl3y9dXBpLISusH4MVLRJ0ba7I ZFmpkGcbwdtiOF3qNN2T2ul6fndhqXMR4l/n7Z/WRdiNhHuLfA/8Z0EFnp0Xn/wiwztH nqFuOi6YTdo2xMSxjI+zMxq89Hw+vkJdro2Y8HIvZ6yb1eHBWHd3w+1ro7U4MXa3/7qi yJuWNKQp4bJ6vHUJ8d1QZrsBVxqPJHUnUze1wQRsMGc/fAg5eeDnt/xvWrzSU0x3ovps 95+3ljaB1sFXoh3Kl5lHpI9aDVeRLRXQ65UbPFioC0ZTNsgj0YtdcXZj/ksBj+J6EGch Q8Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qWJbhNNKYpdUnqUdiyY31FlBX96s2hVvtyph0o78I6U=; b=YW61BIzJqIUAcX+ym0dImJBhT1PG3wSDUcrEGBDiV/mKSS2GzK3adr/hWh9u3eaHrK FgypRHyYcGhu48NbJiNlRN5BDkhUJJ7KpMK6G8T9d7BWatoxzR5KOEIsFz6HvbZ+WHhO 66YoU8Re1rDHR6ZJ4fJgtRYpUqwLX38ceUmDcWTsHiTiYwXiCv7tm+oEzYfd/ghQZ8BN M4YuPX2KnBPZqp9fNiulWCEHjHnpBw82Q4ZbPCakpCz+9DL3dbESlEYsbSezmIP+vx3Q gsvhEA7PXSSxwYep17zEHF/dP0htz+rCTCV3V1NQix1SZon+YOt7mIZlNiEUjsZuZ3Ed Q2gA== X-Gm-Message-State: AOAM533R9eVYkF4/51MBMtqa2k6T0z/ONIB/kYharahqD4R64fhn8JZW Qyqcluc42akQLpoxLytyGYC8e1Xi3j6JVQ== X-Google-Smtp-Source: ABdhPJwji5zkskg9oxjjwtkLxMrNLosB5hhs2MWYHs7F3HbOOeS4jRZ1SDltfRh52d2bzqxhmDjgTA== X-Received: by 2002:a54:4885:: with SMTP id r5mr1128085oic.34.1606814024397; Tue, 01 Dec 2020 01:13:44 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id y18sm277460oou.15.2020.12.01.01.13.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 01:13:43 -0800 (PST) From: Felipe Contreras To: zsh-workers@zsh.org Cc: Bart Schaefer , Felipe Contreras Subject: [PATCH] First try of null typeset Date: Tue, 1 Dec 2020 03:13:42 -0600 Message-Id: <20201201091342.310763-1-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 47708 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Signed-off-by: Felipe Contreras --- This achieves most of what Bart Schaefer's version achieves, except no extra hacks are needed, and integer and floats are not changed. This most definetly is not close to the final solution, but shows what can be achieved by narrowing down the functional changes to two functions. In my opinion a separate concept of "null" variable will be needed, and should be separate from PM_UNSET, since that changes a lot of behavior. Also, I don't think $empty[(i)] should return nothing, so probably paramsubst() would need to be tuned, not simply set vunset=1. Addtionally, this patch doesn't change the behavior of the private module. Src/params.c | 23 ++++++++++++++++++++++- Src/subst.c | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Src/params.c b/Src/params.c index 122f5da7d..7dbe67bd1 100644 --- a/Src/params.c +++ b/Src/params.c @@ -3697,6 +3697,27 @@ unsetparam_pm(Param pm, int altflag, int exp) return 0; } +/**/ +mod_export int +isnull(Param pm) +{ + switch (PM_TYPE(pm->node.flags)) { + case PM_SCALAR: + if (pm->gsu.s->getfn == strgetfn && !pm->u.str) + return 1; + break; + case PM_ARRAY: + if (pm->gsu.a->getfn == arrgetfn && !pm->u.arr) + return 1; + break; + case PM_HASHED: + if (pm->gsu.h->getfn == hashgetfn && !pm->u.hash) + return 1; + break; + } + return 0; +} + /* Standard function to unset a parameter. This is mostly delegated to * * the specific set function. * @@ -5955,7 +5976,7 @@ printparamnode(HashNode hn, int printflags) } } - if ((printflags & PRINT_NAMEONLY) || + if ((printflags & PRINT_NAMEONLY) || isnull(p) || ((p->node.flags & PM_HIDEVAL) && !(printflags & PRINT_INCLUDEVALUE))) quotedzputs(p->node.nam, stdout); else { diff --git a/Src/subst.c b/Src/subst.c index 8f5bd355e..42d18d58d 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -2532,7 +2532,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, (wantt ? -1 : ((unset(KSHARRAYS) || inbrace) ? 1 : -1)), scanflags)) || - (v->pm && (v->pm->node.flags & PM_UNSET)) || + (v->pm && (v->pm->node.flags & PM_UNSET || isnull(v->pm))) || (v->flags & VALFLAG_EMPTY)) vunset = 1; -- 2.29.2