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

Diff of /code/trunk/pcre_scanner.cc

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

revision 92 by nigel, Sat Feb 24 21:41:21 2007 UTC revision 93 by nigel, Sat Feb 24 21:41:42 2007 UTC
# Line 43  Scanner::Scanner() Line 43  Scanner::Scanner()
43      input_(data_),      input_(data_),
44      skip_(NULL),      skip_(NULL),
45      should_skip_(false),      should_skip_(false),
46        skip_repeat_(false),
47      save_comments_(false),      save_comments_(false),
48      comments_(NULL),      comments_(NULL),
49      comments_offset_(0) {      comments_offset_(0) {
# Line 53  Scanner::Scanner(const string& in) Line 54  Scanner::Scanner(const string& in)
54      input_(data_),      input_(data_),
55      skip_(NULL),      skip_(NULL),
56      should_skip_(false),      should_skip_(false),
57        skip_repeat_(false),
58      save_comments_(false),      save_comments_(false),
59      comments_(NULL),      comments_(NULL),
60      comments_offset_(0) {      comments_offset_(0) {
# Line 63  Scanner::~Scanner() { Line 65  Scanner::~Scanner() {
65    delete comments_;    delete comments_;
66  }  }
67    
68    void Scanner::SetSkipExpression(const char* re) {
69      delete skip_;
70      if (re != NULL) {
71        skip_ = new RE(re);
72        should_skip_ = true;
73        skip_repeat_ = true;
74        ConsumeSkip();
75      } else {
76        skip_ = NULL;
77        should_skip_ = false;
78        skip_repeat_ = false;
79      }
80    }
81    
82  void Scanner::Skip(const char* re) {  void Scanner::Skip(const char* re) {
83    delete skip_;    delete skip_;
84    if (re != NULL) {    if (re != NULL) {
85      skip_ = new RE(re);      skip_ = new RE(re);
86      should_skip_ = true;      should_skip_ = true;
87        skip_repeat_ = false;
88      ConsumeSkip();      ConsumeSkip();
89    } else {    } else {
90      skip_ = NULL;      skip_ = NULL;
91      should_skip_ = false;      should_skip_ = false;
92        skip_repeat_ = false;
93    }    }
94  }  }
95    
# Line 118  bool Scanner::Consume(const RE& re, Line 136  bool Scanner::Consume(const RE& re,
136    
137  // helper function to consume *skip_ and honour save_comments_  // helper function to consume *skip_ and honour save_comments_
138  void Scanner::ConsumeSkip() {  void Scanner::ConsumeSkip() {
139      const char* start_data = input_.data();
140      while (skip_->Consume(&input_)) {
141        if (!skip_repeat_) {
142          // Only one skip allowed.
143          break;
144        }
145      }
146    if (save_comments_) {    if (save_comments_) {
147      if (NULL == comments_) {      if (comments_ == NULL) {
148        comments_ = new vector<StringPiece>;        comments_ = new vector<StringPiece>;
149      }      }
     const char *start_data = input_.data();  
     skip_->Consume(&input_);  
150      // already pointing one past end, so no need to +1      // already pointing one past end, so no need to +1
151      int length = input_.data() - start_data;      int length = input_.data() - start_data;
152      if (length > 0) {      if (length > 0) {
153        comments_->push_back(StringPiece(start_data, length));        comments_->push_back(StringPiece(start_data, length));
154      }      }
   } else {  
     skip_->Consume(&input_);  
155    }    }
156  }  }
157    

Legend:
Removed from v.92  
changed lines
  Added in v.93

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12