Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] declarednull: rename DECLARED to NULL



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