/[pcre]/code/trunk/pcrecpp.cc
ViewVC logotype

Diff of /code/trunk/pcrecpp.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 137 by ph10, Thu Mar 29 13:56:00 2007 UTC revision 179 by ph10, Wed Jun 13 08:53:45 2007 UTC
# Line 77  void RE::Init(const string& pat, const R Line 77  void RE::Init(const string& pat, const R
77    
78    re_partial_ = Compile(UNANCHORED);    re_partial_ = Compile(UNANCHORED);
79    if (re_partial_ != NULL) {    if (re_partial_ != NULL) {
80      // Check for complicated patterns.  The following change is      re_full_ = Compile(ANCHOR_BOTH);
     // conservative in that it may treat some "simple" patterns  
     // as "complex" (e.g., if the vertical bar is in a character  
     // class or is escaped).  But it seems good enough.  
     if (strchr(pat.c_str(), '|') == NULL) {  
       // Simple pattern: we can use position-based checks to perform  
       // fully anchored matches  
       re_full_ = re_partial_;  
     } else {  
       // We need a special pattern for anchored matches  
       re_full_ = Compile(ANCHOR_BOTH);  
     }  
81    }    }
82  }  }
83    
84  void RE::Cleanup() {  void RE::Cleanup() {
85    if (re_full_ != NULL && re_full_ != re_partial_) (*pcre_free)(re_full_);    if (re_full_ != NULL)         (*pcre_free)(re_full_);
86    if (re_partial_ != NULL)                         (*pcre_free)(re_partial_);    if (re_partial_ != NULL)      (*pcre_free)(re_partial_);
87    if (error_ != &empty_string)                     delete error_;    if (error_ != &empty_string)  delete error_;
88  }  }
89    
90    
# Line 507  int RE::TryMatch(const StringPiece& text Line 496  int RE::TryMatch(const StringPiece& text
496      rc = vecsize / 2;      rc = vecsize / 2;
497    }    }
498    
   if ((anchor == ANCHOR_BOTH) && (re_full_ == re_partial_)) {  
     // We need an extra check to make sure that the match extended  
     // to the end of the input string  
     assert(vec[0] == 0);                 // PCRE_ANCHORED forces starting match  
     if (vec[1] != text.size()) return 0; // Did not get ending match  
   }  
   
499    return rc;    return rc;
500  }  }
501    

Legend:
Removed from v.137  
changed lines
  Added in v.179

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12