From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6454 invoked from network); 11 Sep 2008 17:12:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,MISSING_HEADERS autolearn=no version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Sep 2008 17:12:29 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 88509 invoked from network); 11 Sep 2008 17:12:18 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Sep 2008 17:12:18 -0000 Received: (qmail 18154 invoked by alias); 11 Sep 2008 17:12:03 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25651 Received: (qmail 18124 invoked from network); 11 Sep 2008 17:12:00 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 11 Sep 2008 17:12:00 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id BCE4680271A5 for ; Thu, 11 Sep 2008 19:11:49 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly16d.srv.mailcontrol.com (MailControl) with ESMTP id m8BHBm7h019815 for ; Thu, 11 Sep 2008 18:11:48 +0100 Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 11 Sep 2008 18:11:48 +0100 Date: Thu, 11 Sep 2008 18:11:42 +0100 From: Peter Stephenson Cc: "Zsh Hackers' List" Subject: PATCH: indent in code output (was Re: preventing the leading space ...) Message-ID: <20080911181142.17e9be1e@news01> In-Reply-To: <20080911155416.643a84d3@news01> References: <20080909144101.GA30693@lapse.rw.madduck.net> <200809101124.m8ABOlKI005063@news01.csr.com> <080910074842.ZM19151@torch.brasslantern.com> <200809101510.m8AFAajX007203@news01.csr.com> <080910090554.ZM19272@torch.brasslantern.com> <6cd6de210809101151q4d0a2a35p452fe656e0ee7dd5@mail.gmail.com> <20080911130005.7c5e2b7c@news01> <6cd6de210809110544u569838dk5a93a739fa267822@mail.gmail.com> <20080911140505.6c040bf4@news01> <080911073531.ZM24010@torch.brasslantern.com> <20080911155416.643a84d3@news01> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 11 Sep 2008 17:11:48.0135 (UTC) FILETIME=[7982FB70:01C91431] X-Scanned-By: MailControl A-08-50-13 (www.mailcontrol.com) on 10.68.0.126 X-Virus-Scanned: ClamAV 0.92.1/8219/Thu Sep 11 17:02:39 2008 on bifrost X-Virus-Status: Clean On Thu, 11 Sep 2008 15:54:16 +0100 Peter Stephenson wrote: > I note that $ZSH_DEBUG_CMD has strange (overlarge) indentation for the > elements of (...) after the opening parenthesis. I think that needs > revisiting. I don't quite understand why the default indentation is 1 > instead of 0; obviously that's right for outputting the bodies of > functions, but the code has many other uses. I think it's simply never been right for uses other than outputting functions for the reason that usually in other case the indentation doesn't show up. I can't believe % (trap '(echo foo); echo bar' DEBUG; trap) foo bar trap -- '( echo foo ) echo bar' DEBUG was ever the intention. (It's certainly not the case that the code is indented to match the code before the opening quote, that's not taken into account.) This makes the output code trap -- '( echo foo ) echo bar' DEBUG and fixes other pieces of code (including $ZSH_DEBUG_CMD) similarly. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.204 diff -u -r1.204 builtin.c --- Src/builtin.c 3 Sep 2008 09:08:22 -0000 1.204 +++ Src/builtin.c 11 Sep 2008 17:05:32 -0000 @@ -5725,7 +5725,7 @@ if (!siglists[sig]) printf("trap -- '' %s\n", name); else { - s = getpermtext(siglists[sig], NULL); + s = getpermtext(siglists[sig], NULL, 0); printf("trap -- "); quotedzputs(s, stdout); printf(" %s\n", name); Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.150 diff -u -r1.150 exec.c --- Src/exec.c 11 Sep 2008 14:47:33 -0000 1.150 +++ Src/exec.c 11 Sep 2008 17:05:32 -0000 @@ -1084,7 +1084,7 @@ noerrexit = 1; if (ltype & Z_SIMPLE) /* skip the line number */ pc2++; - pm = setsparam("ZSH_DEBUG_CMD", getpermtext(state->prog, pc2)); + pm = setsparam("ZSH_DEBUG_CMD", getpermtext(state->prog, pc2, 0)); exiting = donetrap; ret = lastval; Index: Src/hashtable.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v retrieving revision 1.28 diff -u -r1.28 hashtable.c --- Src/hashtable.c 11 Aug 2008 19:22:54 -0000 1.28 +++ Src/hashtable.c 11 Sep 2008 17:05:32 -0000 @@ -887,7 +887,7 @@ if (f->node.flags & PM_UNDEFINED) printf("%c undefined\n\t", hashchar); else - t = getpermtext(f->funcdef, NULL); + t = getpermtext(f->funcdef, NULL, 1); if (f->node.flags & PM_TAGGED) printf("%c traced\n\t", hashchar); if (!t) { Index: Src/init.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/init.c,v retrieving revision 1.95 diff -u -r1.95 init.c --- Src/init.c 3 Sep 2008 09:08:22 -0000 1.95 +++ Src/init.c 11 Sep 2008 17:05:32 -0000 @@ -168,7 +168,7 @@ else addlinknode(args, ""); addlinknode(args, dupstring(getjobtext(prog, NULL))); - addlinknode(args, cmdstr = getpermtext(prog, NULL)); + addlinknode(args, cmdstr = getpermtext(prog, NULL, 0)); callhookfunc("preexec", args, 1, NULL); Index: Src/text.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/text.c,v retrieving revision 1.23 diff -u -r1.23 text.c --- Src/text.c 5 Sep 2008 09:05:23 -0000 1.23 +++ Src/text.c 11 Sep 2008 17:05:32 -0000 @@ -118,7 +118,7 @@ /**/ mod_export char * -getpermtext(Eprog prog, Wordcode c) +getpermtext(Eprog prog, Wordcode c, int start_indent) { struct estate s; @@ -131,6 +131,7 @@ s.pc = c; s.strs = prog->strs; + tindent = start_indent; tnewlins = 1; tbuf = (char *)zalloc(tsiz = 32); tptr = tbuf; @@ -162,6 +163,7 @@ s.pc = c; s.strs = prog->strs; + tindent = 0; tnewlins = 0; tbuf = NULL; tptr = jbuf; @@ -245,16 +247,6 @@ int stack = 0; wordcode code; - /* - * Hack for parsing "simple" format of function definitions. - * In this case there is no surrounding context so the initial - * indent should be zero. - */ - if (wc_code(*state->pc) == WC_FUNCDEF) - tindent = 0; - else - tindent = 1; - while (1) { if (stack) { if (!(s = tstack)) Index: Src/Modules/parameter.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/parameter.c,v retrieving revision 1.48 diff -u -r1.48 parameter.c --- Src/Modules/parameter.c 3 Sep 2008 09:08:22 -0000 1.48 +++ Src/Modules/parameter.c 11 Sep 2008 17:05:32 -0000 @@ -390,7 +390,7 @@ ((shf->node.flags & PM_TAGGED) ? "Ut" : "U") : ((shf->node.flags & PM_TAGGED) ? "t" : ""))); } else { - char *t = getpermtext(shf->funcdef, NULL), *n, *h; + char *t = getpermtext(shf->funcdef, NULL, 1), *n, *h; if (shf->funcdef->flags & EF_RUN) { n = nicedupstring(name); @@ -455,7 +455,8 @@ ((shf->node.flags & PM_TAGGED) ? "Ut" : "U") : ((shf->node.flags & PM_TAGGED) ? "t" : ""))); } else { - char *t = getpermtext(((Shfunc) hn)->funcdef, NULL), *n; + char *t = getpermtext(((Shfunc) hn)->funcdef, NULL, 1); + char *n; if (((Shfunc) hn)->funcdef->flags & EF_RUN) { n = nicedupstring(hn->nam); -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070