Fix #1279 (Change error message: Invalid number of character ({). Can't process file.)
http://sourceforge.net/apps/trac/cppcheck/ticket/1279
This commit is contained in:
parent
4d7ac2f82e
commit
7817d5b142
|
@ -531,7 +531,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
{
|
||||
std::istringstream istr(code);
|
||||
TIMER_START();
|
||||
if (!_tokenizer.tokenize(istr, FileName))
|
||||
if (!_tokenizer.tokenize(istr, FileName, cfg))
|
||||
{
|
||||
// File had syntax errors, abort
|
||||
return;
|
||||
|
|
|
@ -805,8 +805,10 @@ void Tokenizer::simplifyTypedef()
|
|||
}
|
||||
}
|
||||
|
||||
bool Tokenizer::tokenize(std::istream &code, const char FileName[])
|
||||
bool Tokenizer::tokenize(std::istream &code, const char FileName[], const std::string configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
// The "_files" vector remembers what files have been tokenized..
|
||||
_files.push_back(FileLister::simplifyPath(FileName));
|
||||
|
||||
|
@ -5023,7 +5025,12 @@ void Tokenizer::syntaxError(const Token *tok, char c)
|
|||
|
||||
const ErrorLogger::ErrorMessage errmsg(locationList,
|
||||
"error",
|
||||
std::string("Invalid number of character (") + c + "). Can't process file.",
|
||||
std::string("Invalid number of character (") +
|
||||
c +
|
||||
") " +
|
||||
"when these macros are defined: '" +
|
||||
_configuration +
|
||||
"'.",
|
||||
"syntaxError");
|
||||
|
||||
if (_errorLogger)
|
||||
|
|
|
@ -64,9 +64,10 @@ public:
|
|||
* \endcode
|
||||
*
|
||||
* @param FileName The filename
|
||||
* @param configuration E.g. "A" for code where "#ifdef A" is true
|
||||
* @return false if Source code contains syntax errors
|
||||
*/
|
||||
bool tokenize(std::istream &code, const char FileName[]);
|
||||
bool tokenize(std::istream &code, const char FileName[], const std::string configuration = "");
|
||||
|
||||
/**
|
||||
* Create tokens from code.
|
||||
|
@ -397,6 +398,10 @@ private:
|
|||
std::vector<std::string> _files;
|
||||
const Settings * const _settings;
|
||||
ErrorLogger * const _errorLogger;
|
||||
|
||||
/** E.g. "A" for code where "#ifdef A" is true. This is used to
|
||||
print additional information in error situations. */
|
||||
std::string _configuration;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -585,7 +585,7 @@ private:
|
|||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(src);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid number of character ((). Can't process file.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid number of character (() when these macros are defined: ''.\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2500,7 +2500,7 @@ private:
|
|||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid number of character ({). Can't process file.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid number of character ({) when these macros are defined: ''.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2509,7 +2509,7 @@ private:
|
|||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid number of character ((). Can't process file.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid number of character (() when these macros are defined: ''.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2530,8 +2530,8 @@ private:
|
|||
"}\n";
|
||||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid number of character ((). Can't process file.\n", errout.str());
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp", "ABC"));
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid number of character (() when these macros are defined: 'ABC'.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2543,7 +2543,7 @@ private:
|
|||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid number of character ({). Can't process file.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid number of character ({) when these macros are defined: ''.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2555,7 +2555,7 @@ private:
|
|||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid number of character ([). Can't process file.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Invalid number of character ([) when these macros are defined: ''.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2569,7 +2569,7 @@ private:
|
|||
Tokenizer tokenizer(0, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(false, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid number of character ((). Can't process file.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid number of character (() when these macros are defined: ''.\n", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue