Remove './' from begin of paths when printing progress.

This commit is contained in:
Kimmo Varis 2010-07-19 15:05:44 +03:00
parent dc77bc69a0
commit 342632a618
2 changed files with 20 additions and 2 deletions

View File

@ -23,6 +23,7 @@
#include "filelister.h"
#include "check.h"
#include "path.h"
#include <algorithm>
#include <iostream>
@ -652,7 +653,13 @@ unsigned int CppCheck::check()
break;
if (_settings._errorsOnly == false)
_errorLogger.reportOut(std::string("Checking ") + fname + std::string("..."));
{
std::string fixedpath(fname);
fixedpath = Path::fromNativeSeparators(fixedpath);
fixedpath = Path::simplifyPath(fixedpath);
fixedpath = Path::toNativeSeparators(fixedpath);
_errorLogger.reportOut(std::string("Checking ") + fixedpath + std::string("..."));
}
try
{
@ -700,7 +707,13 @@ unsigned int CppCheck::check()
// If only errors are printed, print filename after the check
if (_settings._errorsOnly == false && it != configurations.begin())
_errorLogger.reportOut(std::string("Checking ") + fname + ": " + cfg + std::string("..."));
{
std::string fixedpath(fname);
fixedpath = Path::fromNativeSeparators(fixedpath);
fixedpath = Path::simplifyPath(fixedpath);
fixedpath = Path::toNativeSeparators(fixedpath);
_errorLogger.reportOut(std::string("Checking ") + fixedpath + ": " + cfg + std::string("..."));
}
std::string appendCode = _settings.append();
if ( !appendCode.empty() )

View File

@ -45,6 +45,11 @@ std::string Path::fromNativeSeparators(const std::string &path)
std::string Path::simplifyPath(const std::string &path)
{
std::string f(path);
// Remove './' from begin of the path
if (f.size() > 2 && f[0] == '.' && f[1] == '/')
f = f.erase(0, 2);
// replace "/ab/../" with "/"..
std::string::size_type pos = 0;
while ((pos = f.find("..", pos + 1)) != std::string::npos)