Stefan Schuermans commited on 2014-05-04 09:35:59
Showing 5 changed files, with 15 additions and 8 deletions.
... | ... |
@@ -15,8 +15,9 @@ namespace Blinker { |
15 | 15 |
*/ |
16 | 16 |
bool SyncRecv::checkName(const std::string &playlist, const std::string &sync) |
17 | 17 |
{ |
18 |
- std::string::size_type pos; |
|
18 |
+ std::string::size_type pos, noprefix; |
|
19 | 19 |
std::string noext; |
20 |
+ unsigned int underscore; |
|
20 | 21 |
|
21 | 22 |
// full match |
22 | 23 |
if (playlist == sync) |
... | ... |
@@ -28,13 +29,19 @@ bool SyncRecv::checkName(const std::string &playlist, const std::string &sync) |
28 | 29 |
if (noext == sync) |
29 | 30 |
return true; |
30 | 31 |
|
31 |
- // match without number prefix "[0-9]*[._-]?" |
|
32 |
- for (pos = 0; pos < noext.length() && std::isdigit(noext.at(pos)); ++pos); |
|
33 |
- if (pos < noext.length() && |
|
34 |
- (noext.at(pos) == '.' || noext.at(pos) == '_' || noext.at(pos) == '-')) |
|
35 |
- ++pos; |
|
36 |
- noext = noext.substr(pos); |
|
37 |
- if (noext == sync) |
|
32 |
+ // match without ignore prefix ".*__" |
|
33 |
+ noprefix = 0; |
|
34 |
+ underscore = 0; |
|
35 |
+ for (pos = 0; pos < noext.length(); ++pos) { |
|
36 |
+ if (noext.at(pos) == '_') { |
|
37 |
+ underscore++; |
|
38 |
+ if (underscore >= 2) |
|
39 |
+ noprefix = pos + 1; |
|
40 |
+ } else { |
|
41 |
+ underscore = 0; |
|
42 |
+ } |
|
43 |
+ } |
|
44 |
+ if (noext.substr(noprefix) == sync) |
|
38 | 45 |
return true; |
39 | 46 |
|
40 | 47 |
// no match |
41 | 48 |