Changeset 294
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Trac.cc
r293 r294 96 96 return false; 97 97 const std::string::const_iterator first_orig(first); 98 if (match(first, last, "changeset:").empty()){98 if (match(first, last, Str("changeset:")).empty()){ 99 99 first = first_orig; 100 100 return false; … … 123 123 if (changeset(first, str.end())) 124 124 continue; 125 if (diff(first, str.end())) 126 continue; 125 127 hs_ << *first; 126 128 ++first; … … 136 138 137 139 const std::string::const_iterator first_orig(first); 138 if (match(first, last, "comment:ticket:").empty()){140 if (match(first, last, Str("comment:ticket:")).empty()){ 139 141 first = first_orig; 140 142 return false; … … 208 210 const std::string::const_iterator first_orig(first); 209 211 210 if (match(first, last, "ticket:").empty()){212 if (match(first, last, Str("ticket:")).empty()){ 211 213 first = first_orig; 212 214 return false; … … 217 219 const Configuration& conf = Configuration::instance(); 218 220 hs_.stream() << anchor(conf.trac_root()+"ticket/"+ticket,"#"+ticket); 221 return true; 222 } 223 224 225 bool Trac::diff(std::string::const_iterator& first, 226 const std::string::const_iterator& last) 227 { 228 if (diff1(first, last)) 229 return true; 230 if (diff3(first, last)) 231 return true; 232 if (diff2(first, last)) 233 return true; 234 return false; 235 } 236 237 238 bool Trac::diff1(std::string::const_iterator& first, 239 const std::string::const_iterator& last) 240 { 241 if (first==last) 242 return false; 243 244 const std::string::const_iterator first_orig(first); 245 if (match(first, last, Str("diff:")).empty()){ 246 first = first_orig; 247 return false; 248 } 249 std::string node = match(first, last, notChar('@')); 250 if (first==last){ 251 first = first_orig; 252 return false; 253 } 254 ++first; 255 std::string old_rev = match(first, last, Digit()); 256 if (old_rev.empty() || first == last || *first != ':') { 257 first = first_orig; 258 return false; 259 } 260 ++first; 261 std::string new_rev = match(first, last, Digit()); 262 if (new_rev.empty() ) { 263 first = first_orig; 264 return false; 265 } 266 std::string href; 267 if (node.empty()) 268 href = std::string(Configuration::instance().trac_root()+ 269 "changeset?new="+new_rev+"&old="+old_rev); 270 else 271 href = std::string(Configuration::instance().trac_root()+ 272 "changeset?new="+new_rev+"&new_path="+node+"&old="+ 273 old_rev+"&oldpath="+node); 274 hs_.stream() << anchor(href, std::string(first_orig, first)); 275 return true; 276 } 277 278 279 bool Trac::diff2(std::string::const_iterator& first, 280 const std::string::const_iterator& last) 281 { 282 if (first==last) 283 return false; 284 285 const std::string::const_iterator first_orig(first); 286 if (match(first, last, Str("diff:")).empty()){ 287 first = first_orig; 288 return false; 289 } 290 std::string old_path(match(first, last, not2Str("//", " "))); 291 std::string new_path; 292 if (first==last || *first==' ') 293 new_path = old_path; 294 else { 295 first += 2; 296 new_path = match(first, last, notChar(' ')); 297 } 298 if (new_path.empty() || old_path.empty()){ 299 first = first_orig; 300 return false; 301 } 302 std::string href(Configuration::instance().trac_root()+ 303 "changeset?new_path="+new_path+"&old_path="+old_path); 304 hs_.stream() << anchor(href, std::string(first_orig, first)); 305 return true; 306 } 307 308 309 bool Trac::diff3(std::string::const_iterator& first, 310 const std::string::const_iterator& last) 311 { 312 if (first==last) 313 return false; 314 315 const std::string::const_iterator first_orig(first); 316 if (match(first, last, Str("diff:")).empty()){ 317 first = first_orig; 318 return false; 319 } 320 std::string old_path(match(first, last, not2Char('@', ' '))); 321 if (*first!='@'){ 322 first = first_orig; 323 return false; 324 } 325 ++first; 326 std::string old_rev(match(first, last, Digit())); 327 if (!match_begin(first, first+1, std::string("//"))) { 328 first = first_orig; 329 return false; 330 } 331 first+2; 332 std::string new_path = match(first, last, not2Char('@', ' ')); 333 if (*first!='@'){ 334 first = first_orig; 335 return false; 336 } 337 ++first; 338 std::string new_rev(match(first, last, Digit())); 339 if (new_rev.empty()){ 340 first = first_orig; 341 return false; 342 } 343 344 std::string href(Configuration::instance().trac_root()+ 345 "changeset?new="+new_rev+"&new_path="+new_path+ 346 "&old="+old_rev+"&old_path="+old_path); 347 hs_.stream() << anchor(href, std::string(first_orig, first)); 219 348 return true; 220 349 } -
trunk/lib/Trac.h
r293 r294 62 62 const std::string::const_iterator& last); 63 63 64 bool diff(std::string::const_iterator& first, 65 const std::string::const_iterator& last); 66 67 bool diff1(std::string::const_iterator& first, 68 const std::string::const_iterator& last); 69 70 bool diff2(std::string::const_iterator& first, 71 const std::string::const_iterator& last); 72 73 bool diff3(std::string::const_iterator& first, 74 const std::string::const_iterator& last); 75 64 76 bool comment(std::string::const_iterator& first, 65 77 const std::string::const_iterator& last); -
trunk/lib/utility.cc
r290 r294 111 111 112 112 113 std::string match(std::string::const_iterator& first,114 const std::string::const_iterator& last,115 const char* c)116 {117 std::string str(c);118 if (match_begin(first, last, str)) {119 first += str.size();120 return str;121 }122 return std::string();123 }124 125 126 113 bool node_exist(const std::string& path) 127 114 { … … 188 175 189 176 177 Str::Str(std::string s) 178 : str_(s) 179 {} 180 181 182 not2Str::not2Str(std::string s1, std::string s2) 183 : str1_(s1), str2_(s2) 184 {} 185 186 190 187 }} // end of namespace svndigest and namespace theplu -
trunk/lib/utility.h
r290 r294 134 134 135 135 136 std::string match(std::string::const_iterator& first,137 const std::string::const_iterator& last,138 const char*);139 140 136 template <class T> 141 137 std::string match(std::string::const_iterator& first, … … 144 140 { 145 141 std::string res; 146 for (;first!=last && func( *first); ++first)142 for (;first!=last && func(first); ++first) 147 143 res.append(1,*first); 148 144 return res; … … 151 147 struct Digit 152 148 { 153 inline bool operator()(char c) const { return isdigit(c); } 149 inline bool operator()(std::string::const_iterator i) const 150 { return isdigit(*i); } 154 151 }; 155 152 … … 158 155 public: 159 156 notChar(char); 160 inline bool operator()(char c) const { return c!=char_; } 157 inline bool operator()(std::string::const_iterator i) const 158 { return *i!=char_; } 161 159 private: 162 160 char char_; … … 167 165 public: 168 166 not2Char(char, char); 169 inline bool operator()( char c) const170 { return c!=char1_ && c!=char2_; }167 inline bool operator()(std::string::const_iterator i) const 168 { return *i!=char1_ && *i!=char2_; } 171 169 private: 172 170 const char char1_; 173 171 const char char2_; 172 }; 173 174 class Str 175 { 176 public: 177 Str(std::string); 178 inline bool operator()(std::string::const_iterator i) const 179 { return (std::equal(str_.begin(), str_.end(), i)); } 180 181 private: 182 const std::string str_; 183 }; 184 185 class not2Str 186 { 187 public: 188 not2Str(std::string, std::string); 189 inline bool operator()(std::string::const_iterator i) const 190 { 191 return !(std::equal(str1_.begin(), str1_.end(), i) || 192 std::equal(str2_.begin(), str2_.end(), i)); 193 } 194 195 private: 196 const std::string str1_; 197 const std::string str2_; 174 198 }; 175 199
Note: See TracChangeset
for help on using the changeset viewer.