From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6262 invoked from network); 12 Dec 2005 18:58:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Dec 2005 18:58:41 -0000 Received: (qmail 88814 invoked from network); 12 Dec 2005 18:58:34 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Dec 2005 18:58:34 -0000 Received: (qmail 27653 invoked by alias); 12 Dec 2005 18:58:28 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9788 Received: (qmail 27644 invoked from network); 12 Dec 2005 18:58:27 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Dec 2005 18:58:27 -0000 Received: (qmail 87766 invoked from network); 12 Dec 2005 18:58:27 -0000 Received: from cluster-c.mailcontrol.com (HELO rly17c.srv.mailcontrol.com) (168.143.177.190) by a.mx.sunsite.dk with SMTP; 12 Dec 2005 18:58:26 -0000 Received: from exchange03.csr.com (uuk202166.uk.customer.alter.net [62.189.241.194] (may be forged)) by rly17c.srv.mailcontrol.com (MailControl) with ESMTP id jBCIuWFK000445 for ; Mon, 12 Dec 2005 18:58:23 GMT Received: from news01 ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 12 Dec 2005 18:56:54 +0000 Date: Mon, 12 Dec 2005 18:56:53 +0000 From: Peter Stephenson To: zsh-users@sunsite.dk Subject: Re: Adding Text to Each Match Message-Id: <20051212185653.008a770b.pws@csr.com> In-Reply-To: <1051212162111.ZM21491@candle.brasslantern.com> References: <20051212153946.GA2836@namib.cs.utk.edu> <1051212162111.ZM21491@candle.brasslantern.com> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 12 Dec 2005 18:56:54.0446 (UTC) FILETIME=[D1A0ACE0:01C5FF4D] X-Scanned-By: MailControl A-05-40-01 (www.mailcontrol.com) on 10.67.0.127 Bart Schaefer wrote: > Try searching for "mutt". The thread is "globbing with interposition" > from back in April, and the short-and-sweet answer is that mutt doesn't > care whether there's a space between the -a and the file name, so you > can run them together as -afile1 -afile2 etc., which means you can use > brace expansion. See zsh-users/8707. Do we still want to have a glob qualifer to specify no reordering? Index: Doc/Zsh/expn.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v retrieving revision 1.58 diff -u -r1.58 expn.yo --- Doc/Zsh/expn.yo 4 Nov 2005 16:20:34 -0000 1.58 +++ Doc/Zsh/expn.yo 12 Dec 2005 18:54:30 -0000 @@ -1958,11 +1958,13 @@ inode change respectively; if tt(d), files in subdirectories appear before those in the current directory at each level of the search DASH()- this is best combined with other criteria, for example `tt(odon)' to sort on names for -files within the same directory. Note that tt(a), tt(m), and tt(c) compare +files within the same directory; if tt(N), no sorting is performed. +Note that tt(a), tt(m), and tt(c) compare the age against the current time, hence the first name in the list is the youngest file. Also note that the modifiers tt(^) and tt(-) are used, so `tt(*(^-oL))' gives a list of all files sorted by file size in descending -order, following any symbolic links. +order, following any symbolic links. Unless tt(oN) is used, multiple order +specifiers may occur to resolve ties. ) item(tt(O)var(c))( like `tt(o)', but sorts in descending order; i.e. `tt(*(^oc))' is the Index: Src/glob.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/glob.c,v retrieving revision 1.48 diff -u -r1.48 glob.c --- Src/glob.c 13 Oct 2005 16:30:14 -0000 1.48 +++ Src/glob.c 12 Dec 2005 18:54:31 -0000 @@ -56,11 +56,14 @@ #define GS_NAME 1 #define GS_DEPTH 2 -#define GS_SIZE 4 -#define GS_ATIME 8 -#define GS_MTIME 16 -#define GS_CTIME 32 -#define GS_LINKS 64 + +#define GS_SHIFT_BASE 4 + +#define GS_SIZE (GS_SHIFT_BASE) +#define GS_ATIME (GS_SHIFT_BASE << 1) +#define GS_MTIME (GS_SHIFT_BASE << 2) +#define GS_CTIME (GS_SHIFT_BASE << 3) +#define GS_LINKS (GS_SHIFT_BASE << 4) #define GS_SHIFT 5 #define GS__SIZE (GS_SIZE << GS_SHIFT) @@ -69,7 +72,8 @@ #define GS__CTIME (GS_CTIME << GS_SHIFT) #define GS__LINKS (GS_LINKS << GS_SHIFT) -#define GS_DESC 4096 +#define GS_DESC (GS_SHIFT_BASE << (2*GS_SHIFT)) +#define GS_NONE (GS_SHIFT_BASE << (2*GS_SHIFT+1)) #define GS_NORMAL (GS_SIZE | GS_ATIME | GS_MTIME | GS_CTIME | GS_LINKS) #define GS_LINKED (GS_NORMAL << GS_SHIFT) @@ -1414,6 +1418,7 @@ case 'm': t = GS_MTIME; break; case 'c': t = GS_CTIME; break; case 'd': t = GS_DEPTH; break; + case 'N': t = GS_NONE; break; default: zerr("unknown sort specifier", NULL, 0); restore_globstate(saved); @@ -1622,10 +1627,13 @@ matchct = 1; } } - /* Sort arguments in to lexical (and possibly numeric) order. * - * This is reversed to facilitate insertion into the list. */ - qsort((void *) & matchbuf[0], matchct, sizeof(struct gmatch), - (int (*) _((const void *, const void *)))gmatchcmp); + + if (!(gf_sortlist[0] & GS_NONE)) { + /* Sort arguments in to lexical (and possibly numeric) order. * + * This is reversed to facilitate insertion into the list. */ + qsort((void *) & matchbuf[0], matchct, sizeof(struct gmatch), + (int (*) _((const void *, const void *)))gmatchcmp); + } if (first < 0) { first += matchct; @@ -1637,10 +1645,21 @@ else if (end > matchct) end = matchct; if ((end -= first) > 0) { - matchptr = matchbuf + matchct - first - end; - while (end-- > 0) { /* insert matches in the arg list */ - insertlinknode(list, node, matchptr->name); - matchptr++; + if (gf_sortlist[0] & GS_NONE) { + /* Match list was never reversed, so insert back to front. */ + matchptr = matchbuf + matchct - first - 1; + while (end-- > 0) { + /* insert matches in the arg list */ + insertlinknode(list, node, matchptr->name); + matchptr--; + } + } else { + matchptr = matchbuf + matchct - first - end; + while (end-- > 0) { + /* insert matches in the arg list */ + insertlinknode(list, node, matchptr->name); + matchptr++; + } } } free(matchbuf); -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com