zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] declarednull: rename DECLARED to NULL
@ 2020-12-28 22:13 Felipe Contreras
  2021-01-03  1:18 ` Bart Schaefer
  0 siblings, 1 reply; 16+ messages in thread
From: Felipe Contreras @ 2020-12-28 22:13 UTC (permalink / raw)
  To: zsh-workers; +Cc: Bart Schaefer, Felipe Contreras

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@gmail.com>
---
 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



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-04-10 22:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 22:13 [PATCH] declarednull: rename DECLARED to NULL Felipe Contreras
2021-01-03  1:18 ` Bart Schaefer
2021-01-03  2:38   ` Felipe Contreras
2021-01-03 18:26     ` Bart Schaefer
2021-01-04  6:17       ` Daniel Shahaf
2021-01-04 21:57         ` Bart Schaefer
2021-01-06 16:02           ` Daniel Shahaf
2021-01-06 17:33             ` Bart Schaefer
2021-01-07 15:48               ` Daniel Shahaf
2021-01-07 22:29                 ` Bart Schaefer
2021-03-27 19:24               ` Lawrence Velázquez
2021-03-27 20:42                 ` Bart Schaefer
2021-03-29  0:44                   ` Oliver Kiddle
2021-04-10 18:56                     ` Bart Schaefer
2021-04-10 21:58                       ` Oliver Kiddle
2021-04-10 22:35                         ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).