ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Matcher.cpp
(Generate patch)

Comparing trunk/Matcher.cpp (file contents):
Revision 33 by douglas, 2004-07-10T17:01:15-07:00 vs.
Revision 34 by douglas, 2004-07-20T16:49:06-07:00

# Line 6 | Line 6
6  
7   #include "Matcher.hpp"
8  
9 Matcher::Matcher(const ext::String& expression) : expression(NULL)
10 {
11        (*this)(expression);
12 }
13
14 Matcher::~Matcher()
15 {
16        if (expression != NULL)
17        {
18                pcre_free(expression);
19        }
20 }
21
9   bool Matcher::match(const ext::String& stuff)
10   {
11          substrings.clear();
# Line 30 | Line 17 | bool Matcher::match(const ext::String& s
17                  pcre_fullinfo(expression, NULL, PCRE_INFO_CAPTURECOUNT, &length);
18  
19                  int* substrings(new int[(++length *= 3)]);
20 <                int count(pcre_exec(expression, NULL, stuff.c_str(), stuff.length(), 0, 0,
34 <                        substrings, length));
20 >                int count(pcre_exec(expression, NULL, stuff.NullTerminate(), stuff.GetSize(), 0, 0, substrings, length));
21  
22                  if (count > 0)
23                  {
# Line 39 | Line 25 | bool Matcher::match(const ext::String& s
25  
26                          for (int index(0); index < count; ++index)
27                          {
28 <                                pcre_copy_substring(stuff.c_str(), substrings, count, index,
43 <                                        substring, stuff.length() + 1);
28 >                                pcre_copy_substring(stuff.NullTerminate(), substrings, count, index, substring, stuff.GetSize() + 1);
29  
30                                  this->substrings.push_back(substring);
31                          }
# Line 60 | Line 45 | Matcher& Matcher::operator()(const ext::
45   {
46          substrings.clear();
47  
48 <        if (this->expression != NULL)
64 <        {
65 <                pcre_free(this->expression);
66 <        }
48 >        if (this->expression != NULL) pcre_free(this->expression);
49  
50          const char* error;
51          int offset;
52  
53 <        this->expression = pcre_compile(expression.c_str(), 0, &error,
72 <                &offset, NULL);
53 >        this->expression = pcre_compile(expression.NullTerminate(), 0, &error, &offset, NULL);
54  
55          return *this;
56   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines