From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24467 invoked from network); 13 Dec 2007 22:37:17 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) 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.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Dec 2007 22:37:17 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 36426 invoked from network); 13 Dec 2007 22:37:12 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Dec 2007 22:37:12 -0000 Received: (qmail 13685 invoked by alias); 13 Dec 2007 22:37:09 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24243 Received: (qmail 13666 invoked from network); 13 Dec 2007 22:37:08 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 13 Dec 2007 22:37:08 -0000 Received: from virusfilter.dotsrc.org (bifrost [127.0.0.1]) by spamfilter.dotsrc.org (Postfix) with ESMTP id 58CED8058F54 for ; Thu, 13 Dec 2007 23:34:23 +0100 (CET) Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP for ; Thu, 13 Dec 2007 23:34:22 +0100 (CET) Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com with ESMTP id <20071213223733.PGWV13570.mtaout01-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com>; Thu, 13 Dec 2007 22:37:33 +0000 Received: from pws-pc ([82.6.96.116]) by aamtaout04-winn.ispmail.ntl.com with SMTP id <20071213223704.WPAX29112.aamtaout04-winn.ispmail.ntl.com@pws-pc>; Thu, 13 Dec 2007 22:37:04 +0000 Date: Thu, 13 Dec 2007 22:35:16 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk, 185228@bugs.debian.org Subject: Re: [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generation with glob qualifier mh+] Message-Id: <20071213223516.c0f18f3e.p.w.stephenson@ntlworld.com> In-Reply-To: <20071213182503.GA29544@scowler.net> References: <20030318031615.GG29480@acolyte.scowler.net> <1030318162510.ZM28121@candle.brasslantern.com> <20050711121700.GA16217@dixsept.loria.fr> <20071213182503.GA29544@scowler.net> X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 13 Dec 2007 13:25:03 -0500 Clint Adams wrote: > On Mon, Jul 11, 2005 at 02:17:00PM +0200, Vincent Lefevre wrote: > > BTW, could zsh define n, that would have the intuitive > > meaning? e.g. echo *(ah>5) would display the files accessed more > > that 5 hours (= 18000 seconds) ago. > > Sounds unlikely. It turns out not to be too difficult, although I had to make < and > in parentheses no longer be parse errors. There's no good reason why they should be parse errors there that I can see and we already do similar things in lots of other cases. I'll let everyone worry about this overnight while I finally get some rest. Index: Doc/Zsh/expn.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v retrieving revision 1.85 diff -u -r1.85 expn.yo --- Doc/Zsh/expn.yo 13 Dec 2007 21:57:18 -0000 1.85 +++ Doc/Zsh/expn.yo 13 Dec 2007 22:33:48 -0000 @@ -2069,7 +2069,7 @@ item(tt(g)var(id))( like tt(u)var(id) but with group IDs or names ) -item(tt(a)[tt(Mwhms)][tt(-)|tt(PLUS())]var(n))( +item(tt(a)[tt(Mwhms)][tt(-)|tt(PLUS())|tt(<)|tt(>)]var(n))( files accessed exactly var(n) days ago. Files accessed within the last var(n) days are selected using a negative value for var(n) (tt(-)var(n)). Files accessed more than var(n) days ago are selected by a positive var(n) @@ -2079,11 +2079,18 @@ instead of days, respectively. Any fractional part of the difference between the access time and the -current part in the appropriate units is ignored in the comparison. For +current time in the appropriate units is ignored in the comparison. For instance, `tt(echo *(ah-5))' would echo files accessed within the last five hours, while `tt(echo *(ah+5))' would echo files accessed at least -six hours ago, as times strictly between five and six hours are treated -as five hours. +six hours ago, as times between five and six hours are treated as five +hours. + +To perform comparisons strictly rather than using the truncated value, +tt(<) and tt(>) may be used in place of tt(-) and tt(PLUS()). The test +with tt(<) is true if the time difference is less than the given period; +this is equivalent to tt(-) because of the manner of truncation. The +test with tt(>) is true if the time difference is strictly greater than +the period specified. ) item(tt(m)[tt(Mwhms)][tt(-)|tt(PLUS())]var(n))( like the file access qualifier, except that it uses the file modification Index: Src/glob.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/glob.c,v retrieving revision 1.61 diff -u -r1.61 glob.c --- Src/glob.c 1 Nov 2007 17:57:57 -0000 1.61 +++ Src/glob.c 13 Dec 2007 22:33:50 -0000 @@ -1440,7 +1440,32 @@ g_units = TT_SECONDS, ++s; } /* See if it's greater than, equal to, or less than */ - if ((g_range = *s == '+' ? 1 : *s == '-' ? -1 : 0)) + switch (*s) { + /* integer greater than */ + case '+': + g_range = 1; + break; + + case '>': + case OUTPAR: + /* strictly greater than */ + g_range = 2; + break; + + case '-': + case '<': + case INANG: + /* integer less than, same as strictly less than */ + g_range = -1; + break; + + default: + /* integer match */ + g_range = 0; + break; + } + + if (g_range) ++s; data = qgetnum(&s); break; @@ -3236,7 +3261,7 @@ static int qualtime(UNUSED(char *name), struct stat *buf, off_t days, UNUSED(char *dummy)) { - time_t now, diff; + time_t now, diff, div, units; time(&now); diff = now - (g_amc == 0 ? buf->st_atime : g_amc == 1 ? buf->st_mtime : @@ -3244,25 +3269,33 @@ /* handle multipliers indicating units */ switch (g_units) { case TT_DAYS: - diff /= 86400l; + units = 86400l; break; case TT_HOURS: - diff /= 3600l; + units = 3600l; break; case TT_MINS: - diff /= 60l; + units = 60l; break; case TT_WEEKS: - diff /= 604800l; + units = 604800l; break; case TT_MONTHS: - diff /= 2592000l; + units = 2592000l; + break; + default: + units = 1l; break; } - return (g_range < 0 ? diff < days : - g_range > 0 ? diff > days : - diff == days); + div = diff / units; + if (g_range == 2) { + /* strictly greater than */ + return div > days || (div == days && diff > div * units); + } + return (g_range < 0 ? div < days : + g_range > 0 ? div > days : + div == days); } /* evaluate a string */ Index: Src/lex.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/lex.c,v retrieving revision 1.41 diff -u -r1.41 lex.c --- Src/lex.c 23 Aug 2007 22:04:25 -0000 1.41 +++ Src/lex.c 13 Dec 2007 22:33:51 -0000 @@ -1099,7 +1099,7 @@ break; case LX2_OUTANG: if (!intpos) { - if (in_brace_param || sub) + if (in_brace_param || pct || sub) break; else goto brk; -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/