/[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 86 by nigel, Sat Feb 24 21:40:45 2007 UTC revision 87 by nigel, Sat Feb 24 21:41:21 2007 UTC
# Line 30  Line 30 
30  // Author: Sanjay Ghemawat  // Author: Sanjay Ghemawat
31    
32  #include <vector>  #include <vector>
 #include <algorithm>     // for count()  
33  #include <assert.h>  #include <assert.h>
34  #include "config.h"  #include "config.h"
35  #include "pcre_scanner.h"  #include "pcre_scanner.h"
# Line 90  void Scanner::EnableSkip() { Line 89  void Scanner::EnableSkip() {
89  int Scanner::LineNumber() const {  int Scanner::LineNumber() const {
90    // TODO: Make it more efficient by keeping track of the last point    // TODO: Make it more efficient by keeping track of the last point
91    // where we computed line numbers and counting newlines since then.    // where we computed line numbers and counting newlines since then.
92    return 1 + std::count(data_.data(), input_.data(), '\n');    // We could use std:count, but not all systems have it. :-(
93      int count = 1;
94      for (const char* p = data_.data(); p < input_.data(); ++p)
95        if (*p == '\n')
96          ++count;
97      return count;
98  }  }
99    
100  int Scanner::Offset() const {  int Scanner::Offset() const {

Legend:
Removed from v.86  
changed lines
  Added in v.87

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12