Fix bug in C# detection code. The test had a bug also, so it was not detected by the test.

This commit is contained in:
Reijo Tomperi 2011-12-27 22:50:56 +02:00
parent 8cb53107dd
commit 1afd923d34
2 changed files with 7 additions and 5 deletions

View File

@ -1982,9 +1982,7 @@ bool Tokenizer::tokenize(std::istream &code,
}
// Convert C# code
// FIXME: This should be if(isCSharp()), but that makes the lines 5931 and
// 5932 of test/testtokenize.cpp fail.
if (_files[0].find(".cs")) {
if (isCSharp()) {
for (Token *tok = _tokens; tok; tok = tok->next()) {
if (Token::Match(tok, "%type% [ ] %var% [=;]") &&
(!tok->previous() || Token::Match(tok->previous(), "[;{}]"))) {

View File

@ -5928,8 +5928,12 @@ private:
}
void cs() {
ASSERT_EQUALS("int * i ;", tokenizeAndStringify("int [] i;"));
ASSERT_EQUALS("; int * i ;", tokenizeAndStringify("; int [] i;"));
bool simplify = false;
bool expand = true;
Settings::PlatformType platform = Settings::Unspecified;
const std::string filename="test.cs";
ASSERT_EQUALS("int * i ;", tokenizeAndStringify("int [] i;", simplify, expand, platform, filename));
ASSERT_EQUALS("; int * i ;", tokenizeAndStringify("; int [] i;", simplify, expand, platform, filename));
}
std::string javatest(const char javacode[]) {