zsh-workers
 help / color / mirror / code / Atom feed
* pcre_study
@ 2001-07-03 16:26 Bart Schaefer
  2001-07-03 16:40 ` pcre_study Clint Adams
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2001-07-03 16:26 UTC (permalink / raw)
  To: zsh-workers

Does `study' mean something completely different in PCRE than in Perl?

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.)

I really don't know, having never used PCRE except as a side-effect of PHP,
but if we're going to include this then the doc (and the zpgrep example)
ought to be correct.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: pcre_study
  2001-07-03 16:26 pcre_study Bart Schaefer
@ 2001-07-03 16:40 ` Clint Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Clint Adams @ 2001-07-03 16:40 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

> 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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-03 16:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-03 16:26 pcre_study Bart Schaefer
2001-07-03 16:40 ` pcre_study Clint Adams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).