Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] declarednull: rename DECLARED to NULL
- X-seq: zsh-workers 47776
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] declarednull: rename DECLARED to NULL
- Date: Mon, 28 Dec 2020 16:13:42 -0600
- Archived-at: <https://zsh.org/workers/47776>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-12/20201228221342.136199-1-felipe.contreras%40gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-ot1-f42.google.com) smtp.remote-ip=209.85.210.42; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Felipe Contreras <felipe.contreras@xxxxxxxxx>
- 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=Dvv4w5j46rQ1SCgj7Jx439xqDDNIsFNhSkp84fAhoq4=; b=ChsX91eT+1lUGHaZx4C5+D8LnuPjTHL+kpE5ov1VOQnSV49trGPFCSDWTsp01/L8fU 0uJ7KMJJPJYuPUHT7+wM4XAMW5erxD3WArj+7u6GvCAutlRXL9/yciZ33x88ivtPVxXo +u9y6vZWAM8as4mhX4Q/w0RDjatsoxYqfpX5efXBCjFVwo9utAqxwOPEnMk+Se7IIBcj ony5Hs/2SjYemYoWP7+scQg/1XfYaR3wN3ro4I/ZAEfkXiWrgh4sVSg/FURS8mNz45vw GnLZodkyyuE44pjLuVDLktkjW8wLnH4gjgkzeODvZFQDJRCcLtMimneJuH+hhaHZdpKb iarA==
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- Sender: zsh-workers-request@xxxxxxx
This way the logic makes more sense:
typeset var <- NULL(on)
unset var <- NULL(off)
var='' <- NULL(off)
NULL means: declared, no value, but still valid even with PM_UNSET.
No functional changes.
Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
Src/builtin.c | 2 +-
Src/params.c | 4 ++--
Src/subst.c | 2 +-
Src/zsh.h | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Src/builtin.c b/Src/builtin.c
index 1e950f122..46d3962bb 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2837,7 +2837,7 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
unqueue_signals();
return 1;
} else if (pm) {
- if ((!(pm->node.flags & PM_UNSET) || pm->node.flags & PM_DECLARED)
+ if ((!(pm->node.flags & PM_UNSET) || pm->node.flags & PM_NULL)
&& (locallevel == pm->level || !(on & PM_LOCAL))) {
if (pm->node.flags & PM_TIED) {
if (PM_TYPE(pm->node.flags) != PM_SCALAR) {
diff --git a/Src/params.c b/Src/params.c
index c09a3eccf..1c587872b 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2094,7 +2094,7 @@ fetchvalue(Value v, char **pptr, int bracks, int flags)
*s = sav;
*pptr = s;
if (!pm || ((pm->node.flags & PM_UNSET) &&
- !(pm->node.flags & PM_DECLARED)))
+ !(pm->node.flags & PM_NULL)))
return NULL;
if (v)
memset(v, 0, sizeof(*v));
@@ -3625,7 +3625,7 @@ unsetparam_pm(Param pm, int altflag, int exp)
else
altremove = NULL;
- pm->node.flags &= ~PM_DECLARED; /* like ksh, not like bash */
+ pm->node.flags &= ~PM_NULL; /* like ksh, not like bash */
if (!(pm->node.flags & PM_UNSET))
pm->gsu.s->unsetfn(pm, exp);
if (pm->env)
diff --git a/Src/subst.c b/Src/subst.c
index 8731297f7..7ac2dd47a 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2541,7 +2541,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
* Handle the (t) flag: value now becomes the type
* information for the parameter.
*/
- if (v && v->pm && ((v->pm->node.flags & PM_DECLARED) ||
+ if (v && v->pm && ((v->pm->node.flags & PM_NULL) ||
!(v->pm->node.flags & PM_UNSET))) {
int f = v->pm->node.flags;
diff --git a/Src/zsh.h b/Src/zsh.h
index 6d7f517c6..c68b47383 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1929,10 +1929,10 @@ struct tieddata {
made read-only by the user */
#define PM_READONLY_SPECIAL (PM_SPECIAL|PM_READONLY|PM_RO_BY_DESIGN)
#define PM_DONTIMPORT (1<<22) /* do not import this variable */
-#define PM_DECLARED (1<<22) /* explicitly named with typeset */
+#define PM_NULL (1<<22) /* declared but null */
#define PM_RESTRICTED (1<<23) /* cannot be changed in restricted mode */
#define PM_UNSET (1<<24) /* has null value */
-#define PM_DECLAREDNULL (PM_DECLARED|PM_UNSET)
+#define PM_DECLAREDNULL (PM_NULL|PM_UNSET)
#define PM_REMOVABLE (1<<25) /* special can be removed from paramtab */
#define PM_AUTOLOAD (1<<26) /* autoloaded from module */
#define PM_NORESTORE (1<<27) /* do not restore value of local special */
--
2.30.0.rc2
Messages sorted by:
Reverse Date,
Date,
Thread,
Author