zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: typeset -p with assoc array (was Re: Typeset with array)
Date: Tue, 23 Jun 2015 18:35:20 -0700	[thread overview]
Message-ID: <150623183520.ZM6551@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3R5KBDP+_0Tmxf6QzvENC9qJf4EHupBx+0Lv+-NwN7+3g@mail.gmail.com>

On Jun 23, 10:24pm, Mikael Magnusson wrote:
} 
} > If I were going to "fix" it for no reason other than the consistency,
} > I'd simply add MORE spaces rather than try to squash that one.
} 
} This would also be consistent with xtrace output, so I agree :).

This is not difficult, and doesn't conflict with the typeset-array
branch as far as I can see, so ... patch below.

However, it does point out that the typeset-array branch could update
printparamnode() to emit

    typeset -a a=( b )

instead of the historic two-line format.  (Urk, it'd be kind of ugly
to make that depend on whether the reserved word was enabled.)


diff --git a/Src/params.c b/Src/params.c
index 3b75735..f8d039a 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5091,8 +5091,10 @@ printparamvalue(Param p, int printflags)
 	break;
     case PM_ARRAY:
 	/* array */
-	if (!(printflags & PRINT_KV_PAIR))
+	if (!(printflags & PRINT_KV_PAIR)) {
 	    putchar('(');
+	    putchar(' ');
+	}
 	u = p->gsu.a->getfn(p);
 	if(*u) {
 	    quotedzputs(*u++, stdout);
@@ -5101,13 +5103,17 @@ printparamvalue(Param p, int printflags)
 		quotedzputs(*u++, stdout);
 	    }
 	}
-	if (!(printflags & PRINT_KV_PAIR))
+	if (!(printflags & PRINT_KV_PAIR)) {
+	    putchar(' ');
 	    putchar(')');
+	}
 	break;
     case PM_HASHED:
 	/* association */
-	if (!(printflags & PRINT_KV_PAIR))
+	if (!(printflags & PRINT_KV_PAIR)) {
 	    putchar('(');
+	    putchar(' ');
+	}
 	{
             HashTable ht = p->gsu.h->getfn(p);
             if (ht)


  reply	other threads:[~2015-06-24  1:35 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         ` Typeset with array 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
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                       ` Bart Schaefer [this message]
2015-06-24  6:03                         ` typeset -p with assoc array (was Re: Typeset with array) 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=150623183520.ZM6551@torch.brasslantern.com \
    --to=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).