From owner-freebsd-ports Tue Feb 6 8:10:30 2001 Delivered-To: freebsd-ports@freebsd.org Received: from ringworld.nanolink.com (pool114-tch-2.Sofia.0rbitel.net [212.95.171.114]) by hub.freebsd.org (Postfix) with SMTP id 4C4D437B401 for ; Tue, 6 Feb 2001 08:10:08 -0800 (PST) Received: (qmail 539 invoked by uid 1000); 6 Feb 2001 16:08:26 -0000 Date: Tue, 6 Feb 2001 18:08:25 +0200 From: Peter Pentchev To: Maxim Sobolev Cc: Jordan Hubbard , ports@FreeBSD.org, jkh@FreeBSD.org, Edwin Groothuis Subject: Re: Request for comments [Fwd: bin/24695: [patch] pkg_info: prefix search for a package] Message-ID: <20010206180825.A406@ringworld.oblivion.bg> Mail-Followup-To: Maxim Sobolev , Jordan Hubbard , ports@FreeBSD.org, jkh@FreeBSD.org, Edwin Groothuis References: <10197.981450491@winston.osd.bsdi.com> <3A7FC36A.1434D2CC@FreeBSD.org> <3A801D32.DE73F780@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3A801D32.DE73F780@FreeBSD.org>; from sobomax@FreeBSD.org on Tue, Feb 06, 2001 at 05:50:10PM +0200 Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Tue, Feb 06, 2001 at 05:50:10PM +0200, Maxim Sobolev wrote: > Maxim Sobolev wrote: > > > Jordan Hubbard wrote: > > > > > > but was away from e-mail) ;). What do you think if I reimplement 'fuzzy' and > > > > 'prefix' options from original proposal into `glob' and `regex' options? So > > > > regex kidz would be able say "-x .*foo.*", while glob-lovers "-g *foo*". > > > > > > I love it. You could even make -g "implicit", e.g. I don't see any > > > reason why "pkg_info emacs*" shouldn't just work, right? The only > > > time you really need to pass a flag is to indicate a particular type > > > of globbing, e.g. regex. > > > > Agreed. I already have globbing in place, so expect patches soon ;). > > Here it is. With this patch pkg_install treats any arguments as shell globs by > default and as regexs with -x, so for example the following is equivalent: > $ pkg_info foo\* > $ pkg_info -x ^foo.\* > > Please let me know what do you think about those patches. > > -Maxim The patches look great! I'll test them in an hour or two.. Just a minor comment: in the rexs_match() function, you compile each pattern time and again, for each package. Not that it would matter a lot (the actual performance bottleneck would be disk I/O, I suppose), but it could fasten things a bit if you precompiled all patterns into a regex_t array at the start. G'luck, Peter -- If the meanings of 'true' and 'false' were switched, then this sentence wouldn't be false. [snip] > Index: perform.c > =================================================================== > RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/perform.c,v > retrieving revision 1.33 [snip] > +/* > + * Return 1 if specified pkgname matches at least one > + * of the RE from patterns. Otherwise return 0 if no > + * matches were found or -1 if RE engine reported an > + * error (usually invalid syntax). > + */ > +static int > +rexs_match(char **patterns, char *pkgname) > +{ > + Boolean matched; > + char errbuf[128]; > + int i; > + int errcode; > + int retval; > + regex_t rex; > + > + errcode = 0; > + retval = 0; > + matched = FALSE; > + for (i = 0; patterns[i]; i++) { > + errcode = regcomp(&rex, patterns[i], REG_BASIC | REG_NOSUB); > + if (errcode != 0) > + break; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message