zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: Typeset with array
Date: Tue, 23 Jun 2015 17:47:19 +0100	[thread overview]
Message-ID: <20150623174719.43eaa1e2@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20150621213842.621886e0@ntlworld.com>

Some more tests and one quite subtle fix.

I think this is now basically working.  Any more comments, or should I
roll this out and see what happens?

pws

diff --git a/Src/parse.c b/Src/parse.c
index 5357851..477f8a0 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1898,10 +1898,18 @@ par_simple(int *cmplx, int nr)
 	    parr = ecadd(0);
 	    ecstr(tokstr);
 	    cmdpush(CS_ARRAY);
+	    /*
+	     * Careful here: this must be the typeset case,
+	     * but we need to tell the lexer not to look
+	     * for assignments until we've finished the
+	     * present one.
+	     */
+	    intypeset = 0;
 	    zshlex();
 	    n = par_nl_wordlist();
 	    ecbuf[parr] = WCB_ASSIGN(WC_ASSIGN_ARRAY, WC_ASSIGN_NEW, n);
 	    cmdpop();
+	    intypeset = 1;
 	    if (tok != OUTPAR)
 		YYERROR(oecused);
 	    zshlex();
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 75c475c..e5c4310 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -22,6 +22,8 @@
 
 %prep
 
+  mkdir typeset.tmp && cd typeset.tmp
+
   setopt noglob
 
   scalar=scalar
@@ -517,6 +519,7 @@
      print -l $one $two $three $four $five
   }
   fn
+  print -l $one $two $three $four $five
 0:typeset reserved word interface: basic
 >      eins
 >zwei
@@ -525,3 +528,82 @@
 >      vier
 >cinq
 >cinque
+>hidden
+>hidden
+>hidden
+>hidden
+>hidden
+
+  (
+  setopt glob
+  mkdir -p arrayglob
+  touch arrayglob/{one,two,three,four,five,six,seven}
+  fn() {
+    typeset array=(arrayglob/[tf]*)
+    print -l ${array:t}
+    #
+    typeset {first,second,third}=the_same_value array=(
+    extends
+    over
+    multiple
+    lines
+    )
+    print -l $first $second $third "$array"
+    #
+    integer i=$(echo 1 + 2 + 3 + 4)
+    print $i
+    #
+    # only noted by accident this was broken..
+    # we need to turn off special recognition
+    # of assignments within assignments...
+    typeset careful=( i=1 j=2 k=3 )
+    print -l $careful
+  }
+  fn
+  )
+0:typeset reserved word, more complicated cases
+>five
+>four
+>three
+>two
+>the_same_value
+>the_same_value
+>the_same_value
+>extends over multiple lines
+>10
+>i=1
+>j=2
+>k=3
+
+  (
+     # reserved word is recognised at parsing.
+     # yes, this is documented.
+     # anyway, that means we need to
+     # re-eval the function...
+     fn='
+     fn() {
+        typeset foo=`echo one word=two`
+        print $foo
+        print $word
+     }
+     '
+     print reserved
+     eval $fn; fn
+     print builtin
+     disable -r typeset
+     eval $fn; fn
+     enable -r typeset
+     disable typeset
+     print reserved
+     eval $fn;fn
+  )
+0:reserved word and builtin interfaces
+>reserved
+>one word=two
+>
+>builtin
+>one
+>two
+>reserved
+>one word=two
+>


  reply	other threads:[~2015-06-23 16:57 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5578996E.3080700@thequod.de>
     [not found] ` <150610191427.ZM30841@torch.brasslantern.com>
     [not found]   ` <5579C247.1060800@thequod.de>
     [not found]     ` <150611183639.ZM32247@torch.brasslantern.com>
     [not found]       ` <20150612094237.338f79d5@pwslap01u.europe.root.pri>
2015-06-19 11:39         ` Peter Stephenson
2015-06-19 14:06           ` Peter Stephenson
2015-06-19 18:54             ` Bart Schaefer
2015-06-19 20:16               ` Peter Stephenson
2015-06-19 21:11               ` Eric Cook
2015-06-19 16:09           ` Bart Schaefer
2015-06-19 20:32             ` Peter Stephenson
2015-06-20  3:50               ` Bart Schaefer
2015-06-20 17:05                 ` Peter Stephenson
2015-06-19 17:36           ` Oliver Kiddle
2015-06-19 18:40             ` Bart Schaefer
2015-06-25  9:29             ` Peter Stephenson
2015-06-25 15:16               ` Bart Schaefer
2015-06-25 15:39                 ` Peter Stephenson
2015-06-25 16:08                   ` Bart Schaefer
2015-06-25 16:34                     ` Peter Stephenson
2015-06-26 13:51               ` PATCH: array slice Peter Stephenson
2015-06-26 23:07                 ` Bart Schaefer
2015-06-27 19:42                   ` Peter Stephenson
2015-06-27 20:09                     ` Bart Schaefer
2015-06-26 16:46               ` PATCH: typeset completion Peter Stephenson
2015-06-26 19:14               ` Typeset with array Oliver Kiddle
2015-06-27 16:33                 ` Peter Stephenson
2015-06-21 20:05           ` Peter Stephenson
2015-06-21 20:38             ` Peter Stephenson
2015-06-23 16:47               ` Peter Stephenson [this message]
2015-06-23 17:52                 ` Mikael Magnusson
2015-06-23 20:17                   ` Bart Schaefer
2015-06-23 20:21                     ` Peter Stephenson
2015-06-23 20:24                     ` Mikael Magnusson
2015-06-24  1:35                       ` typeset -p with assoc array (was Re: Typeset with array) Bart Schaefer
2015-06-24  6:03                         ` Bart Schaefer
2015-06-23 20:25                 ` Typeset with array Bart Schaefer
2015-06-24  9:14                   ` Peter Stephenson
2015-06-24  9:29                     ` Peter Stephenson
2015-06-24 10:35                       ` Roman Neuhauser
2015-06-24 13:00                       ` Mikael Magnusson
2015-06-24 13:20                         ` Peter Stephenson
2015-06-24 15:03                     ` 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=20150623174719.43eaa1e2@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).