* Parameter scope nuisance with strftime
@ 2016-01-06 11:39 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2016-01-06 11:39 UTC (permalink / raw)
To: Zsh Hackers' List
This:
Author: Barton E. Schaefer <schaefer@zsh.org>
Date: Sat Apr 25 10:57:44 2015 -0700
34961: $TZ is implicitly local in builtin strftime (originally workers/34602 from workers/34596)
causes us to start parameter scope (as if creating parameters in a
function) for the strftime builtin in zsh/datetime.
This produces a bogus WARNCREATEGLOBAL warning at the command line:
% strftime -s date %Y%m%d%H%M $EPOCHSECONDS
./zsh:4: scalar parameter date created globally in function
However, the warning code is sort of working correctly: we are indeed
creating a global parameter from a local scope. What we don't have is a
function on the funcstack --- possibly the warning is redundant in this
case. I may have been unnecessarily conservative about this when I
created check_warn_create().
pws
diff --git a/Src/params.c b/Src/params.c
index 054fb1f..b2e8897 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2705,30 +2705,18 @@ static void
check_warn_create(Param pm, const char *pmtype)
{
Funcstack i;
- const char *name;
if (pm->level != 0 || (pm->node.flags & PM_SPECIAL))
return;
- name = NULL;
for (i = funcstack; i; i = i->prev) {
if (i->tp == FS_FUNC) {
DPUTS(!i->name, "funcstack entry with no name");
- name = i->name;
+ zwarn("%s parameter %s created globally in function %s",
+ pmtype, pm->node.nam, i->name);
break;
}
}
-
- if (name)
- {
- zwarn("%s parameter %s created globally in function %s",
- pmtype, pm->node.nam, name);
- }
- else
- {
- zwarn("%s parameter %s created globally in function",
- pmtype, pm->node.nam);
- }
}
/**/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-01-06 11:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-06 11:39 Parameter scope nuisance with strftime Peter Stephenson
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).