From 4f096f6c073766c6cfe76f63cd175bea25b4b483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 25 Oct 2008 17:54:04 +0000 Subject: [PATCH] Usage of Global functions: Only checked if "--all" is given. Show progress. --- CommonCheck.cpp | 19 +++++++++++++++++++ main.cpp | 5 +++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CommonCheck.cpp b/CommonCheck.cpp index 030be496a..3abb9e2f7 100644 --- a/CommonCheck.cpp +++ b/CommonCheck.cpp @@ -222,9 +222,26 @@ void CheckGlobalFunctionUsage(const std::vector &filenames) // Iterator for UsedGlobalFunctions std::list::const_iterator usedfunc; + unsigned int i1 = 0; + unsigned int i2 = 1; + // Check that every function in GlobalFunctions are used for ( func = GlobalFunctions.begin(); func != GlobalFunctions.end(); func++ ) { + if ( GlobalFunctions.size() > 100 ) + { + ++i1; + if ( i1 > (i2 * GlobalFunctions.size()) / 100 ) + { + if ( (i2 % 10) == 0 ) + std::cout << i2 << "%"; + else + std::cout << "."; + std::cout.flush(); + ++i2; + } + } + const std::string &funcname = func->name(); if ( funcname == "main" || funcname == "WinMain" ) @@ -261,6 +278,8 @@ void CheckGlobalFunctionUsage(const std::vector &filenames) ReportErr( errmsg.str() ); } } + + std::cout << "\n"; } //--------------------------------------------------------------------------- diff --git a/main.cpp b/main.cpp index 0f269525a..1abd75f3d 100644 --- a/main.cpp +++ b/main.cpp @@ -222,10 +222,11 @@ int main(int argc, char* argv[]) std::cerr << errout.str(); } - if ( CheckCodingStyle && filenames.size() > 1 ) + // This generates false positives - especially for libraries + if ( ShowAll && CheckCodingStyle && filenames.size() > 1 ) { errout.str(""); - std::cout << "Checking usage of global functions..\n"; + std::cout << "Checking usage of global functions (this may take several minutes)..\n"; CheckGlobalFunctionUsage(filenames); if ( ! errout.str().empty() ) {