zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Parameter scope nuisance with strftime
Date: Wed, 06 Jan 2016 11:39:23 +0000	[thread overview]
Message-ID: <20160106113923.27f97b7a@pwslap01u.europe.root.pri> (raw)

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);
-    }
 }
 
 /**/


                 reply	other threads:[~2016-01-06 11:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20160106113923.27f97b7a@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.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).