diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-10-27 15:57:48 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-10-27 15:57:48 +0200 |
commit | 2db621da6660d56f3ff1954adf4ed8ce71834bf6 (patch) | |
tree | 821e378aa65e5dd99718247f7b908bdc053a2020 /compilerplugins/clang/plugin.cxx | |
parent | aace85877c85935bbe92ecdfc1c27271b89628e5 (diff) |
Adapt loplugin:includeform to Windows \ path separator
This can also call loplugin::isSamePathname with two paths that both contain
backslashes, so finally make it (and hasPathnamePrefix) symmetric in which
arguments my contain backslashes.
Change-Id: I0465988d9d41e21c5660cbdbd1558543860ae1ad
Diffstat (limited to 'compilerplugins/clang/plugin.cxx')
-rw-r--r-- | compilerplugins/clang/plugin.cxx | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 077b24370f71..7d53e71dfd61 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -442,15 +442,28 @@ template<typename Fn> bool checkPathname( for (std::size_t n = 0;;) { std::size_t n1 = pathname.find('\\', n); - if (n1 >= against.size()) { - return check(pathname.substr(n), against.substr(n)); - } - if (against[n1] != '/' - || pathname.substr(n, n1 - n) != against.substr(n, n1 - n)) - { - break; + std::size_t n2 = against.find('\\', n); + if (n1 <= n2) { + if (n1 >= against.size()) { + return check(pathname.substr(n), against.substr(n)); + } + if ((against[n1] != '/' && against[n1] != '\\') + || pathname.substr(n, n1 - n) != against.substr(n, n1 - n)) + { + break; + } + n = n1 + 1; + } else { + if (n2 >= pathname.size()) { + return check(pathname.substr(n), against.substr(n)); + } + if (pathname[n2] != '/' + || pathname.substr(n, n2 - n) != against.substr(n, n2 - n)) + { + break; + } + n = n2 + 1; } - n = n1 + 1; } #endif return false; |