MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Introduction to Library Functions                    PCRESTACK(3)



NAME
     PCRE - Perl-compatible regular expressions

PCRE DISCUSION OF STACK USAGE

     When you call pcreexec(), it makes use of an internal func-
     tion called match(). This calls itself recursively at branch
     points in the pattern, in order to remember the state of the
     match so that it can back up and try a different alternative
     if the first one fails.  As  matching  proceeds  deeper  and
     deeper  into  the tree of possibilities, the recursion depth
     increases.

     Not all calls of match() increase the recursion  depth;  for
     an  item  such  as  a* it may be called several times at the
     same level, after matching different numbers of a's.  Furth-
     ermore,  in a number of cases where the result of the recur-
     sive call would immediately be passed back as the result  of
     the  current call (a "tail recursion"), the function is just
     restarted instead.

     The pcredfaexec() function operates in  an  entirely  dif-
     ferent  way,  and hardly uses recursion at all. The limit on
     its complexity is the amount of workspace it is  given.  The
     comments  that  follow do NOT apply to pcredfaexec(); they
     are relevant only for pcreexec().

     You can set limits on the number of times  that  match()  is
     called,  both  in  total  and  recursively.  If the limit is
     exceeded, an error occurs. For details, see the  section  on
     extra data for pcreexec() in the pcreapi documentation.

     Each time that match() is actually  called  recursively,  it
     uses  memory  from  the  process stack. For certain kinds of
     pattern and data, very large amounts of stack may be needed,
     despite  the recognition of "tail recursion".  You can often
     reduce the amount of recursion, and therefore the amount  of
     stack  used, by modifying the pattern that is being matched.
     Consider, for example, this pattern:

       ([^<]<(?!inet))]

     It matches from  wherever  it  starts  until  it  encounters
     "
OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™