Skip to content

Commit 084fcc9

Browse files
committed
Rephrased syntaxError message for empty configurations to improve readability:
Old: Invalid number of character 'c' when these macros are defined: ''. New: Invalid number of character 'c' when no macros are defined.
1 parent ad96f7b commit 084fcc9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lib/tokenize.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7570,10 +7570,14 @@ void Tokenizer::syntaxError(const Token *tok) const
75707570
void Tokenizer::syntaxError(const Token *tok, char c) const
75717571
{
75727572
printDebugOutput(0);
7573-
throw InternalError(tok,
7574-
std::string("Invalid number of character '") + c + "' " +
7575-
"when these macros are defined: '" + _configuration + "'.",
7576-
InternalError::SYNTAX);
7573+
if (_configuration.empty())
7574+
throw InternalError(tok,
7575+
std::string("Invalid number of character '") + c + "' when no macros are defined.",
7576+
InternalError::SYNTAX);
7577+
else
7578+
throw InternalError(tok,
7579+
std::string("Invalid number of character '") + c + "' when these macros are defined: '" + _configuration + "'.",
7580+
InternalError::SYNTAX);
75777581
}
75787582

75797583
void Tokenizer::unhandled_macro_class_x_y(const Token *tok) const

samples/syntaxError/out.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[samples\syntaxError\bad.c:2]: (error) Invalid number of character '{' when these macros are defined: ''.
1+
[samples\syntaxError\bad.c:2]: (error) Invalid number of character '{' when no macros are defined.

test/testgarbage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ class TestGarbage : public TestFixture {
10731073
tokenizer.tokenize(istr, "test.cpp");
10741074
assertThrowFail(__FILE__, __LINE__);
10751075
} catch (InternalError& e) {
1076-
ASSERT_EQUALS("Invalid number of character '(' when these macros are defined: ''.", e.errorMessage);
1076+
ASSERT_EQUALS("Invalid number of character '(' when no macros are defined.", e.errorMessage);
10771077
ASSERT_EQUALS("syntaxError", e.id);
10781078
ASSERT_EQUALS(2, e.token->linenr());
10791079
}

0 commit comments

Comments
 (0)