From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4762 invoked by alias); 13 Feb 2010 20:22:16 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27708 Received: (qmail 29363 invoked from network); 13 Feb 2010 20:22:08 -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=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received-SPF: pass (ns1.primenet.com.au: SPF record at ntlworld.com designates 81.103.221.49 as permitted sender) From: Peter Stephenson To: zsh-workers@zsh.org (Zsh hackers list) Subject: Improve job text for ( ... ) and { ... } X-Mailer: MH-E 8.2; nmh 1.3; GNU Emacs 23.1.1 Date: Sat, 13 Feb 2010 20:21:51 +0000 Message-ID: <14443.1266092511@pws-pc> X-Cloudmark-Analysis: v=1.1 cv=ZtHxNT4mZm3rCuM0SmWmgWxeBwJsziC8EqOrwwVkrhA= c=1 sm=0 a=c_p0QOhmU0AA:10 a=NLZqzBF-AAAA:8 a=f_84cUTOq-BMZf2OLFEA:9 a=tQBZ24cnJJXN9soozOYA:7 a=e6kJz4yEE6W1LEQ26XkMH9dphLAA:4 a=_dQi-Dcv4p4A:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 The unnecessary and rather confusing first semicolon in % ( sleep 10 ) & [1] 9520 % jobs [1] + running (; sleep 10; ) is entirely cosmetic but nonetheless has been annoying me for a while now. This removes it. Shout if you see any similar cases I missed. I realise the ";" after the "sleep 10" is also optional in zsh, but it's standard and I don't think it's distracting in the same way as the one before, so I've left it. The alternative would be to make it optional on some POSIX option, but I don't see the point. Index: Src/text.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/text.c,v retrieving revision 1.24 diff -u -r1.24 text.c --- Src/text.c 11 Sep 2008 17:14:39 -0000 1.24 +++ Src/text.c 13 Feb 2010 20:13:29 -0000 @@ -102,7 +102,7 @@ /**/ static void -taddnl(void) +taddnl(int no_semicolon) { int t0; @@ -110,8 +110,11 @@ taddchr('\n'); for (t0 = 0; t0 != tindent; t0++) taddchr('\t'); - } else + } else if (no_semicolon) { + taddstr(" "); + } else { taddstr("; "); + } } /* get a permanent textual representation of n */ @@ -275,7 +278,7 @@ } if (!(stack = (WC_LIST_TYPE(code) & Z_END))) { if (tnewlins) - taddnl(); + taddnl(0); else taddstr((WC_LIST_TYPE(code) & Z_ASYNC) ? " " : "; "); s->code = *state->pc++; @@ -355,7 +358,7 @@ if (!s) { taddstr("("); tindent++; - taddnl(); + taddnl(1); n = tpush(code, 1); n->u._subsh.end = state->pc + WC_SUBSH_SKIP(code); /* skip word only use for try/always */ @@ -363,7 +366,8 @@ } else { state->pc = s->u._subsh.end; dec_tindent(); - taddnl(); + /* semicolon is optional here but more standard */ + taddnl(0); taddstr(")"); stack = 1; } @@ -372,7 +376,7 @@ if (!s) { taddstr("{"); tindent++; - taddnl(); + taddnl(1); n = tpush(code, 1); n->u._subsh.end = state->pc + WC_CURSH_SKIP(code); /* skip word only use for try/always */ @@ -380,7 +384,8 @@ } else { state->pc = s->u._subsh.end; dec_tindent(); - taddnl(); + /* semicolon is optional here but more standard */ + taddnl(0); taddstr("}"); stack = 1; } @@ -412,7 +417,7 @@ } else { taddstr(" () {"); tindent++; - taddnl(); + taddnl(1); n = tpush(code, 1); n->u._funcdef.strs = state->strs; n->u._funcdef.end = end; @@ -423,7 +428,7 @@ state->strs = s->u._funcdef.strs; state->pc = s->u._funcdef.end; dec_tindent(); - taddnl(); + taddnl(0); taddstr("}"); stack = 1; } @@ -445,15 +450,15 @@ taddstr(" in "); taddlist(state, *state->pc++); } - taddnl(); + taddnl(0); taddstr("do"); } tindent++; - taddnl(); + taddnl(0); tpush(code, 1); } else { dec_tindent(); - taddnl(); + taddnl(0); taddstr("done"); stack = 1; } @@ -467,11 +472,11 @@ taddlist(state, *state->pc++); } tindent++; - taddnl(); + taddnl(0); tpush(code, 1); } else { dec_tindent(); - taddnl(); + taddnl(0); taddstr("done"); stack = 1; } @@ -484,14 +489,14 @@ tpush(code, 0); } else if (!s->pop) { dec_tindent(); - taddnl(); + taddnl(0); taddstr("do"); tindent++; - taddnl(); + taddnl(0); s->pop = 1; } else { dec_tindent(); - taddnl(); + taddnl(0); taddstr("done"); stack = 1; } @@ -500,14 +505,14 @@ if (!s) { taddstr("repeat "); taddstr(ecgetstr(state, EC_NODUP, NULL)); - taddnl(); + taddnl(0); taddstr("do"); tindent++; - taddnl(); + taddnl(0); tpush(code, 1); } else { dec_tindent(); - taddnl(); + taddnl(0); taddstr("done"); stack = 1; } @@ -522,7 +527,7 @@ if (state->pc >= end) { if (tnewlins) - taddnl(); + taddnl(0); else taddchr(' '); taddstr("esac"); @@ -530,7 +535,7 @@ } else { tindent++; if (tnewlins) - taddnl(); + taddnl(0); else taddchr(' '); taddstr("("); @@ -559,7 +564,7 @@ break; } if (tnewlins) - taddnl(); + taddnl(0); else taddchr(' '); taddstr("("); @@ -588,7 +593,7 @@ } dec_tindent(); if (tnewlins) - taddnl(); + taddnl(0); else taddchr(' '); taddstr("esac"); @@ -610,14 +615,14 @@ stack = 1; } else if (s->u._if.cond) { dec_tindent(); - taddnl(); + taddnl(0); taddstr("then"); tindent++; - taddnl(); + taddnl(0); s->u._if.cond = 0; } else if (state->pc < s->u._if.end) { dec_tindent(); - taddnl(); + taddnl(0); code = *state->pc++; if (WC_IF_TYPE(code) == WC_IF_ELIF) { taddstr("elif "); @@ -626,12 +631,12 @@ } else { taddstr("else"); tindent++; - taddnl(); + taddnl(0); } } else { s->pop = 1; dec_tindent(); - taddnl(); + taddnl(0); taddstr("fi"); stack = 1; } @@ -762,7 +767,7 @@ if (!s) { taddstr("{"); tindent++; - taddnl(); + taddnl(0); n = tpush(code, 0); state->pc++; /* this is the end of the try block alone */ @@ -770,14 +775,14 @@ } else if (!s->pop) { state->pc = s->u._subsh.end; dec_tindent(); - taddnl(); + taddnl(0); taddstr("} always {"); tindent++; - taddnl(); + taddnl(0); s->pop = 1; } else { dec_tindent(); - taddnl(); + taddnl(0); taddstr("}"); stack = 1; } -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/