Changeset 507 for trunk/lib/utility.cc


Ignore:
Timestamp:
Dec 8, 2007, 4:58:19 AM (14 years ago)
Author:
Peter Johansson
Message:

added function comparing strings with wildcards - needed for #122

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/utility.cc

    r482 r507  
    8989
    9090
     91  bool equal(std::string::const_iterator first1,
     92             std::string::const_iterator end1,
     93             std::string::const_iterator first2,
     94             std::string::const_iterator end2)
     95  {
     96    if (first1==end1 && first2==end2)
     97      return true;
     98    if (first1!=end1 && first2!=end2 &&
     99        (*first1==*first2 || *first1=='*' || *first2=='*') &&
     100        equal(first1+1, end1, first2+1, end2) )
     101      return true;
     102    if (first1!=end1 && *first1=='*' && first2!=end2 &&
     103        equal(first1, end1, first2+1, end2) )
     104      return true;
     105    if (first2!=end2 && *first2=='*' && first1!=end1 &&
     106        equal(first1+1, end1, first2, end2) )
     107      return true;
     108       
     109    return false;
     110  }
     111
     112
    91113  std::string file_name(const std::string& full_path)
    92114  {
Note: See TracChangeset for help on using the changeset viewer.