Ignore:
Timestamp:
Jan 29, 2009, 1:46:49 PM (14 years ago)
Author:
Peter Johansson
Message:

fixes #353

Location:
branches/0.6-stable/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/0.6-stable/lib/Trac.cc

    r731 r761  
    5050
    5151
    52   bool Trac::changeset(std::string::const_iterator& first,
     52  bool Trac::changeset(const std::string::const_iterator& first,
     53                       std::string::const_iterator& iter,
    5354                       const std::string::const_iterator& last,
    5455                       const std::string::const_iterator& last_trunc)
    5556  {
    56     if (changeset1(first, last, last_trunc))
    57       return true;
    58     if (changeset2(first, last, last_trunc))
    59       return true;
    60     if (changeset3(first, last, last_trunc))
     57    if (changeset1(first, iter, last, last_trunc))
     58      return true;
     59    if (changeset2(iter, last, last_trunc))
     60      return true;
     61    if (changeset3(iter, last, last_trunc))
    6162      return true;
    6263    return false;
     
    6465
    6566
    66   bool Trac::changeset1(std::string::const_iterator& first,
     67  bool Trac::changeset1(const std::string::const_iterator& first,
     68                        std::string::const_iterator& iter,
    6769                        const std::string::const_iterator& last,
    6870                        const std::string::const_iterator& last_trunc)
    6971  {
    70     if (first==last)
    71       return false;
    72     if (*first != 'r')
    73       return false;
    74     const std::string::const_iterator first_orig(first);
    75     ++first;
    76     std::string rev = match(first, last, Digit());
    77     if (rev.empty()){
    78       first = first_orig;
     72    if (iter==last)
     73      return false;
     74    if (*iter != 'r')
     75      return false;
     76    if (iter!=first && isalnum(*(iter-1)))
     77      return false;
     78    const std::string::const_iterator iter_orig(iter);
     79    ++iter;
     80    std::string rev = match(iter, last, Digit());
     81    if (rev.empty() || (iter!=last && (std::isalnum(*iter) || *iter==':')) ){
     82      iter = iter_orig;
    7983      return false;
    8084    }
    8185    std::string href(Configuration::instance().trac_root()+"changeset/"+rev);
    82     hs_.stream() << anchor(href, anchor_text(first_orig, first, last_trunc));
     86    hs_.stream() << anchor(href, anchor_text(iter_orig, iter, last_trunc));
    8387    return true;
    8488  }
     
    290294
    291295
    292   bool Trac::log(std::string::const_iterator& first,
     296  bool Trac::log(const std::string::const_iterator& first,
     297                 std::string::const_iterator& iter,
    293298                 const std::string::const_iterator& last,
    294299                 const std::string::const_iterator& last_trunc)
    295300  {
    296     if (log1(first, last, last_trunc))
    297       return true;
    298     if (log2(first, last, last_trunc))
    299       return true;
    300     if (log3(first, last, last_trunc))
     301    if (log1(first, iter, last, last_trunc))
     302      return true;
     303    if (log2(iter, last, last_trunc))
     304      return true;
     305    if (log3(iter, last, last_trunc))
    301306      return true;
    302307    return false;
     
    304309
    305310
    306   bool Trac::log1(std::string::const_iterator& first,
     311  bool Trac::log1(const std::string::const_iterator& first,
     312                  std::string::const_iterator& iter,
    307313                  const std::string::const_iterator& last,
    308314                  const std::string::const_iterator& last_trunc)
    309315  {
    310     if (first==last)
    311       return false;
    312 
    313     const std::string::const_iterator first_orig(first);
    314     if (*first != 'r')
    315       return false;
    316     ++first;
    317 
    318     std::string stop_rev = match(first, last, AlNum());
    319     if (stop_rev.empty() || first == last || *first != ':') {
    320       first = first_orig;
    321       return false;
    322     }
    323     ++first;
    324     std::string rev = match(first, last, AlNum());
    325     if (rev.empty() ) {
    326       first = first_orig;
     316    if (iter==last)
     317      return false;
     318
     319    const std::string::const_iterator iter_orig(iter);
     320    if (*iter != 'r')
     321      return false;
     322    if (iter!=first && isalnum(*(iter-1)))
     323      return false;
     324    ++iter;
     325
     326    std::string stop_rev = match(iter, last, Digit());
     327    if (stop_rev.empty() || iter == last || *iter != ':') {
     328      iter = iter_orig;
     329      return false;
     330    }
     331    ++iter;
     332    std::string rev = match(iter, last, Digit());
     333    if (rev.empty() || (iter!=last && std::isalnum(*iter) ) ){
     334      iter = iter_orig;
    327335      return false;
    328336    }
    329337    std::string href(Configuration::instance().trac_root()+"log/?rev="+
    330338                     rev+"&amp;stop_rev="+stop_rev);
    331     hs_.stream() << anchor(href, anchor_text(first_orig,first, last_trunc));
     339    hs_.stream() << anchor(href, anchor_text(iter_orig,iter, last_trunc));
    332340    return true;
    333341  }
     
    447455      last_trunc = first+width;
    448456    while (first<last_trunc) {
    449       if (log(first, str.end(), last_trunc))
     457      if (log(str.begin(), first, str.end(), last_trunc))
    450458        continue;
    451459      if (comment(first, str.end(), last_trunc))
     
    453461      if (ticket(first, str.end(), last_trunc))
    454462        continue;
    455       if (changeset(first, str.end(), last_trunc))
     463      if (changeset(str.begin(), first, str.end(), last_trunc))
    456464        continue;
    457465      if (diff(first, str.end(), last_trunc))
  • branches/0.6-stable/lib/Trac.h

    r731 r761  
    6060    /// @return true if any of changesetX returns true
    6161    ///
    62     bool changeset(std::string::const_iterator& first,
     62    bool changeset(const std::string::const_iterator& first,
     63                   std::string::const_iterator& iter,
    6364                   const std::string::const_iterator& last,
    6465                   const std::string::const_iterator& last_trunc);
     
    6869    ///
    6970    /// Search in range [\a first, \a last) for expression
    70     /// /r(\d+)/. If expression is found an anchor to
    71     /// trac-root/changeset/123, displaying expression, and first is
    72     /// pointing to character after expression.
    73     ///
    74     /// @return true if expression is found
    75     ///
    76     bool changeset1(std::string::const_iterator& first,
     71    /// /r(\d+)/. In addition character before cannot be
     72    /// alpha-numeric, and character after expression cannot be
     73    /// alpha-numeric or ':' (beginning/end of string is allowed). If
     74    /// expression is found an anchor to trac-root/changeset/123,
     75    /// displaying expression, and first is pointing to character
     76    /// after expression.
     77    ///
     78    /// @return true if expression is found
     79    ///
     80    bool changeset1(const std::string::const_iterator& first,
     81                    std::string::const_iterator& iter,
    7782                    const std::string::const_iterator& last,
    7883                    const std::string::const_iterator& last_trunc);
     
    189194    /// @return true if any of logX returns true
    190195    ///
    191     bool log(std::string::const_iterator& first,
     196    bool log(const std::string::const_iterator& first,
     197             std::string::const_iterator& iter,
    192198             const std::string::const_iterator& last,
    193199             const std::string::const_iterator& last_trunc);
     
    197203    ///
    198204    /// Search in range [\a first, \a last) for expression
    199     /// /r(\w+):(\w+)/. If expression is found an
    200     /// anchor is created, displaying the expression, and first is
    201     /// pointing to character after expression.
     205    /// /r(\d+):(\d+)/. In addition character before and after
     206    /// expression cannot be alpha-numeric (beginning/end of string is
     207    /// allowed). If expression is found an anchor is created,
     208    /// displaying the expression, and iter is pointing to character
     209    /// after expression.
    202210    ///
    203211    /// The created anchor goes to trac-root/log/?rev=236&stop_rev=123
     
    205213    /// @return true if expression is found
    206214    ///
    207     bool log1(std::string::const_iterator& first,
     215    bool log1(const std::string::const_iterator& first,
     216              std::string::const_iterator& iter,
    208217              const std::string::const_iterator& last,
    209218              const std::string::const_iterator& last_trunc);
Note: See TracChangeset for help on using the changeset viewer.