From 8b5aae9adb2196c9fb589fb347a29df619340664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 2 Apr 2010 07:32:03 +0200 Subject: [PATCH] astyle formatting --- lib/checkother.cpp | 52 ++++++++++++++++++++++---------------------- lib/checkother.h | 10 ++++----- lib/mathlib.cpp | 24 ++++++++++---------- lib/mathlib.h | 4 ++-- test/testmathlib.cpp | 20 ++++++++--------- test/testother.cpp | 12 +++++----- 6 files changed, 61 insertions(+), 61 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 75c6670df..f6d29275d 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2439,7 +2439,7 @@ void CheckOther::checkMathFunctions() { for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { - // case log(-2) + // case log(-2) if (Token::Match(tok, "log ( %num% )") && MathLib::isNegative(tok->tokAt(2)->str()) && MathLib::isInt(tok->tokAt(2)->str()) && @@ -2447,32 +2447,32 @@ void CheckOther::checkMathFunctions() { mathfunctionCallError(tok); } - // case log(-2.0) - else if (Token::Match(tok, "log ( %num% )") && - MathLib::isNegative(tok->tokAt(2)->str()) && - MathLib::isFloat(tok->tokAt(2)->str()) && - MathLib::toDoubleNumber(tok->tokAt(2)->str()) <= 0.) - { - mathfunctionCallError(tok); - } + // case log(-2.0) + else if (Token::Match(tok, "log ( %num% )") && + MathLib::isNegative(tok->tokAt(2)->str()) && + MathLib::isFloat(tok->tokAt(2)->str()) && + MathLib::toDoubleNumber(tok->tokAt(2)->str()) <= 0.) + { + mathfunctionCallError(tok); + } - // case log(0.0) - else if (Token::Match(tok, "log ( %num% )") && - !MathLib::isNegative(tok->tokAt(2)->str()) && - MathLib::isFloat(tok->tokAt(2)->str()) && - MathLib::toDoubleNumber(tok->tokAt(2)->str()) <= 0.) - { - mathfunctionCallError(tok); - } + // case log(0.0) + else if (Token::Match(tok, "log ( %num% )") && + !MathLib::isNegative(tok->tokAt(2)->str()) && + MathLib::isFloat(tok->tokAt(2)->str()) && + MathLib::toDoubleNumber(tok->tokAt(2)->str()) <= 0.) + { + mathfunctionCallError(tok); + } - // case log(0) - else if (Token::Match(tok, "log ( %num% )") && - !MathLib::isNegative(tok->tokAt(2)->str()) && - MathLib::isInt(tok->tokAt(2)->str()) && - MathLib::toLongNumber(tok->tokAt(2)->str()) <= 0) - { - mathfunctionCallError(tok); - } + // case log(0) + else if (Token::Match(tok, "log ( %num% )") && + !MathLib::isNegative(tok->tokAt(2)->str()) && + MathLib::isInt(tok->tokAt(2)->str()) && + MathLib::toLongNumber(tok->tokAt(2)->str()) <= 0) + { + mathfunctionCallError(tok); + } } } @@ -2622,7 +2622,7 @@ void CheckOther::zerodivError(const Token *tok) void CheckOther::mathfunctionCallError(const Token *tok) { - reportError(tok, Severity::error, "wrongmathcall","Passing value " + tok->tokAt(2)->str() + " to " + tok->str() + "() leads to undefined result"); + reportError(tok, Severity::error, "wrongmathcall", "Passing value " + tok->tokAt(2)->str() + " to " + tok->str() + "() leads to undefined result"); } void CheckOther::postIncrementError(const Token *tok, const std::string &var_name, const bool isIncrement) diff --git a/lib/checkother.h b/lib/checkother.h index 1f4f15aa1..2d5668918 100644 --- a/lib/checkother.h +++ b/lib/checkother.h @@ -82,7 +82,7 @@ public: checkOther.strPlusChar(); checkOther.invalidFunctionUsage(); checkOther.checkZeroDivision(); - checkOther.checkMathFunctions(); + checkOther.checkMathFunctions(); // New type of check: Check execution paths checkOther.executionPaths(); @@ -151,8 +151,8 @@ public: /** @brief %Check zero division*/ void checkZeroDivision(); - /** @brief %Check for parameters given to math function that do not make sense*/ - void checkMathFunctions(); + /** @brief %Check for parameters given to math function that do not make sense*/ + void checkMathFunctions(); /** @brief %Check for post increment/decrement in for loop*/ void postIncrement(); @@ -188,7 +188,7 @@ public: void uninitdataError(const Token *tok, const std::string &varname); void uninitvarError(const Token *tok, const std::string &varname); void zerodivError(const Token *tok); - void mathfunctionCallError(const Token *tok); + void mathfunctionCallError(const Token *tok); void postIncrementError(const Token *tok, const std::string &var_name, const bool isIncrement); void getErrorMessages() @@ -201,7 +201,7 @@ public: uninitdataError(0, "varname"); uninitvarError(0, "varname"); zerodivError(0); - mathfunctionCallError(0); + mathfunctionCallError(0); // style cstyleCastError(0); diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index 436d645bf..c1f002dcd 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -77,15 +77,15 @@ std::string MathLib::toString(T d) bool MathLib::isFloat(const std::string &s) { - // every number that contains a . is a float + // every number that contains a . is a float if (s.find("." , 0) != std::string::npos) - return true; - // scientific notation - else if (s.find("E-", 0) != std::string::npos - || s.find("e-", 0) != std::string::npos) - return true; - - return false; + return true; + // scientific notation + else if (s.find("E-", 0) != std::string::npos + || s.find("e-", 0) != std::string::npos) + return true; + + return false; } bool MathLib::isNegative(const std::string &s) @@ -94,11 +94,11 @@ bool MathLib::isNegative(const std::string &s) unsigned long n = 0; // eat up whitespace while (std::isspace(s[n])) ++n; - // every negative number has a negative sign + // every negative number has a negative sign if (s[n] == '-') - return true; - - return false; + return true; + + return false; } bool MathLib::isInt(const std::string & s) diff --git a/lib/mathlib.h b/lib/mathlib.h index aa779d955..6019f3e0f 100644 --- a/lib/mathlib.h +++ b/lib/mathlib.h @@ -37,8 +37,8 @@ public: static std::string toString(T d); static bool isInt(const std::string & str); - static bool isFloat(const std::string &str); - static bool isNegative(const std::string &str); + static bool isFloat(const std::string &str); + static bool isNegative(const std::string &str); static std::string add(const std::string & first, const std::string & second); static std::string subtract(const std::string & first, const std::string & second); diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index 36b2973e7..12a24c304 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -167,23 +167,23 @@ private: ASSERT_EQUALS(false, MathLib::isInt("+1.E-1")); } - void isnegative() - { - ASSERT_EQUALS(true, MathLib::isNegative("-1")); + void isnegative() + { + ASSERT_EQUALS(true, MathLib::isNegative("-1")); ASSERT_EQUALS(true, MathLib::isNegative("-1.")); ASSERT_EQUALS(true, MathLib::isNegative("-1.0")); ASSERT_EQUALS(true, MathLib::isNegative("-1.0E+2")); ASSERT_EQUALS(true, MathLib::isNegative("-1.0E-2")); - ASSERT_EQUALS(false, MathLib::isNegative("+1")); + ASSERT_EQUALS(false, MathLib::isNegative("+1")); ASSERT_EQUALS(false, MathLib::isNegative("+1.")); ASSERT_EQUALS(false, MathLib::isNegative("+1.0")); ASSERT_EQUALS(false, MathLib::isNegative("+1.0E+2")); - ASSERT_EQUALS(false, MathLib::isNegative("+1.0E-2")); - } + ASSERT_EQUALS(false, MathLib::isNegative("+1.0E-2")); + } - void isfloat() - { + void isfloat() + { ASSERT_EQUALS(false, MathLib::isFloat("0")); ASSERT_EQUALS(true , MathLib::isFloat("0.")); ASSERT_EQUALS(true , MathLib::isFloat("0.0")); @@ -194,7 +194,7 @@ private: ASSERT_EQUALS(true , MathLib::isFloat("+0.0E+1")); ASSERT_EQUALS(true , MathLib::isFloat("+0.0E-1")); ASSERT_EQUALS(true , MathLib::isFloat("-0.0E+1")); - ASSERT_EQUALS(true , MathLib::isFloat("-0.0E-1")); + ASSERT_EQUALS(true , MathLib::isFloat("-0.0E-1")); ASSERT_EQUALS(false , MathLib::isFloat("1")); ASSERT_EQUALS(false , MathLib::isFloat("-1")); @@ -214,7 +214,7 @@ private: ASSERT_EQUALS(true , MathLib::isFloat("1.0E+1")); ASSERT_EQUALS(true , MathLib::isFloat("1.0E-1")); ASSERT_EQUALS(true , MathLib::isFloat("-1.0E+1")); - } + } }; REGISTER_TEST(TestMathLib) diff --git a/test/testother.cpp b/test/testother.cpp index 9bae8a41e..8bb262268 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -90,7 +90,7 @@ private: TEST_CASE(passedByValue); - TEST_CASE(mathfunctionCall1); + TEST_CASE(mathfunctionCall1); } void check(const char code[]) @@ -112,7 +112,7 @@ private: checkOther.warningRedundantCode(); checkOther.checkZeroDivision(); checkOther.unreachableCode(); - checkOther.checkMathFunctions(); + checkOther.checkMathFunctions(); } @@ -2158,8 +2158,8 @@ private: ASSERT_EQUALS("[test.cpp:1]: (style) Function parameter 'v' is passed by value. It could be passed by reference instead.\n", errout.str()); } - void mathfunctionCall1() - { + void mathfunctionCall1() + { check("void foo()\n" "{\n" " std::cout << log(-2) << std::endl;\n" @@ -2176,7 +2176,7 @@ private: "{\n" " std::cout << log(-1.0) << std::endl;\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) Passing value -1.0 to log() leads to undefined result\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (error) Passing value -1.0 to log() leads to undefined result\n", errout.str()); check("void foo()\n" "{\n" @@ -2219,7 +2219,7 @@ private: " std::cout << log(1E-3) << std::endl;\n" "}"); TODO_ASSERT_EQUALS("", errout.str()); - } + } };