From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24461 invoked from network); 3 Jul 2001 16:40:36 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 3 Jul 2001 16:40:36 -0000 Received: (qmail 14955 invoked by alias); 3 Jul 2001 16:39:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15233 Received: (qmail 14929 invoked from network); 3 Jul 2001 16:39:36 -0000 Date: Tue, 3 Jul 2001 12:40:26 -0400 From: Clint Adams To: Bart Schaefer Cc: zsh-workers@sunsite.dk Subject: Re: pcre_study Message-ID: <20010703124026.C4396@dman.com> References: <1010703162628.ZM14584@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i In-Reply-To: <1010703162628.ZM14584@candle.brasslantern.com>; from schaefer@candle.brasslantern.com on Tue, Jul 03, 2001 at 04:26:28PM +0000 > Does `study' mean something completely different in PCRE than in Perl? Yes, though I'd be happy if we could rename the builtin to something less confusing. > In Perl, `study' means to examine the *string that is to be searched* to > increase the speed of matching. It has no effect at all on the pattern > that was compiled. Hence in Perl, a `study' at the point where zpgrep > calls `pcre_study' would be completely useless as no input has been read > yet. (And calling `study' on every line would be a waste anyway.) This is from Philip Hazel's PCRE library v3: STUDYING A PATTERN When a pattern is going to be used several times, it is worth spending more time analyzing it in order to speed up the time taken for matching. The function pcre_study() takes a pointer to a compiled pattern as its first argu­ ment, and returns a pointer to a pcre_extra block (another void typedef) containing additional information about the pattern; this can be passed to pcre_exec(). If no addi­ tional information is available, NULL is returned. The second argument contains option bits. At present, no options are defined for pcre_study(), and this argument should always be zero. The third argument for pcre_study() is a pointer to an error message. If studying succeeds (even if no data is returned), the variable it points to is set to NULL. Oth­ erwise it points to a textual error message. At present, studying a pattern is useful only for non- anchored patterns that do not have a single fixed starting character. A bitmap of possible starting characters is created.