From: Felipe Contreras <felipe.contreras@gmail.com>
To: zsh-workers@zsh.org
Cc: Bart Schaefer <schaefer@brasslantern.com>,
Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH] declarednull: rename DECLARED to NULL
Date: Mon, 28 Dec 2020 16:13:42 -0600 [thread overview]
Message-ID: <20201228221342.136199-1-felipe.contreras@gmail.com> (raw)
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
next reply other threads:[~2020-12-28 22:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-28 22:13 Felipe Contreras [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201228221342.136199-1-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).