Ignore:
Timestamp:
Jan 8, 2008, 3:40:37 PM (14 years ago)
Author:
Peter Johansson
Message:

fixes linetype Copyright

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/lib/LineTypeParser.cc

    r550 r552  
    2222*/
    2323
    24 #include "Parser.h"
     24#include "LineTypeParser.h"
    2525#include "Configuration.h"
    2626#include "utility.h"
     
    3939
    4040
    41   Parser::Parser(std::string path)
    42     : mode_(0)
     41  LineTypeParser::LineTypeParser(std::string path)
     42    : mode_(0), post_copyright_(false), copyright_found_(false)
    4343  {
    4444    codon_ = Configuration::instance().codon(path);
     
    4646
    4747
    48   Parser::line_type Parser::parse(const std::string& line)
     48  LineTypeParser::line_type LineTypeParser::parse(std::string line)
    4949  {
    50     if (codon_)
     50    if (!post_copyright_) {
     51      if (copyright_found_) {
     52        // check if line is end of copyright statement, i.e. contains
     53        // no alphanumerical character (except in copyright_prefix).
     54        for (size_t i=0; i<line.size()&&post_copyright_; ++i)
     55          if (isalnum(line[i]) &&
     56              !(i<copyright_prefix_.size() && copyright_prefix_[i]==line[i])){
     57            post_copyright_ = false;
     58            block_ += line + "\n";
     59          }
     60        if (post_copyright_)
     61          end_line_ = type_.size()+1;
     62      }
     63      else {
     64        // check whether copyright starts on this line
     65        std::string::iterator i=search(line.begin(),line.end(),"Copyright (C)");
     66        if (i!=line.end()) {
     67          start_line_ = type_.size()+1;
     68          copyright_prefix_ = line.substr(0, distance(line.begin(), i));
     69          copyright_found_ = true;
     70          block_ = line+"\n";
     71        }
     72      }
     73    }
     74    // we are in copyright block
     75    if (copyright_found_ && !post_copyright_)
     76      type_.push_back(LineTypeParser::copyright);
     77
     78    else if (codon_)
    5179      type_.push_back(code_mode(line));
    5280    else
     
    5785
    5886
    59   Parser::line_type Parser::code_mode(const std::string& str)
     87  LineTypeParser::line_type LineTypeParser::code_mode(const std::string& str)
    6088  {
    6189    // mode zero means we are currently not in a comment
     
    99127
    100128
    101   Parser::line_type Parser::text_mode(const std::string& str)
     129  LineTypeParser::line_type LineTypeParser::text_mode(const std::string& str)
    102130  {
    103131    for (std::string::const_iterator iter=str.begin(); iter!=str.end(); ++iter)
Note: See TracChangeset for help on using the changeset viewer.