Fix #251 (Config parser doesn't ignore comments), based on patch from Cygal
This was SVN commit r7109.
This commit is contained in:
parent
119eb08b47
commit
f4cdd7098c
@ -662,7 +662,6 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine)
|
||||
{
|
||||
// Store argument in CParserValue!
|
||||
CParserValue value;
|
||||
size_t i;
|
||||
|
||||
switch(CurNode->m_Type)
|
||||
{
|
||||
@ -710,22 +709,7 @@ bool CParserLine::ParseString(const CParser& Parser, const std::string &strLine)
|
||||
++Progress;
|
||||
break;
|
||||
case typeRest:
|
||||
// Extract the whole of the std::string
|
||||
|
||||
// Reset, probably is but still
|
||||
value.m_String = std::string();
|
||||
|
||||
for (i=Progress; i<Segments.size(); ++i)
|
||||
{
|
||||
value.m_String += Segments[i];
|
||||
|
||||
// If argument starts with => " <=, add one to the end of it too
|
||||
if (Segments[i][0] == '"')
|
||||
value.m_String += "\"";
|
||||
}
|
||||
|
||||
m_Arguments.push_back(value);
|
||||
|
||||
// This is a comment, don't store it.
|
||||
// Now BREAK EVERYTHING !
|
||||
// We're done, we found our match and let's get out
|
||||
LookNoFurther = true;
|
||||
|
@ -22,7 +22,7 @@
|
||||
class TestParser : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test1()
|
||||
void test_basic()
|
||||
{
|
||||
CParser Parser;
|
||||
Parser.InputTaskType("test", "_$ident_=_$value_");
|
||||
@ -39,7 +39,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void test2()
|
||||
void test_optional()
|
||||
{
|
||||
CParser Parser;
|
||||
Parser.InputTaskType("test", "_$value_[$value]_");
|
||||
@ -61,7 +61,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void test3()
|
||||
void test_multi_optional()
|
||||
{
|
||||
CParser Parser;
|
||||
Parser.InputTaskType("test", "_[$value]_[$value]_[$value]_");
|
||||
@ -90,7 +90,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void test4()
|
||||
void test_optional_repeat()
|
||||
{
|
||||
CParser Parser;
|
||||
Parser.InputTaskType("test", "<[_a_][_b_]_x_>");
|
||||
@ -109,4 +109,18 @@ public:
|
||||
TS_ASSERT(! Line.ParseString(Parser, "a a x"));
|
||||
TS_ASSERT(Line.ParseString(Parser, "a x a b x a x b x b x b x b x a x a x a b x a b x b x a x"));
|
||||
}
|
||||
|
||||
void test_rest()
|
||||
{
|
||||
CParser Parser;
|
||||
Parser.InputTaskType("assignment", "_$ident_=_$value[[;]$rest]");
|
||||
std::string str;
|
||||
|
||||
CParserLine Line;
|
||||
|
||||
TS_ASSERT(Line.ParseString(Parser, "12 = 34 ; comment"));
|
||||
TS_ASSERT_EQUALS((int)Line.GetArgCount(), 2);
|
||||
TS_ASSERT(Line.GetArgString(0, str) && str == "12");
|
||||
TS_ASSERT(Line.GetArgString(1, str) && str == "34");
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user