chore(util/lean_path): workaround 'spurious' warning produced by g++ in release mode
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
50b0c17092
commit
5611c6a0a0
1 changed files with 15 additions and 10 deletions
|
@ -295,20 +295,25 @@ std::string dirname(char const * fname) {
|
|||
if (fname == nullptr)
|
||||
return ".";
|
||||
unsigned i = 0;
|
||||
optional<unsigned> last_sep;
|
||||
unsigned last_sep = 0;
|
||||
bool found_sep = false;
|
||||
char const * it = fname;
|
||||
while (*it) {
|
||||
if (*it == g_sep)
|
||||
if (*it == g_sep) {
|
||||
found_sep = true;
|
||||
last_sep = i;
|
||||
}
|
||||
++i;
|
||||
++it;
|
||||
}
|
||||
if (!last_sep)
|
||||
if (!found_sep) {
|
||||
return ".";
|
||||
} else {
|
||||
std::string r;
|
||||
for (unsigned i = 0; i < *last_sep; i++)
|
||||
for (unsigned i = 0; i < last_sep; i++)
|
||||
r.push_back(fname[i]);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
std::string path_append(char const * p1, char const * p2) {
|
||||
|
|
Loading…
Reference in a new issue