Fixed: ElseIf/Else sections were executed although the corresponding If evaluated to true
This commit is contained in:
1 parent
7aafcacfad
commit
3d234120f6
3 files changed
+43
-11
No files matched your search
@@ -126,7 +126,7 @@ Copy: <Target channel>=<Source channel>+...
|
||||
Copy: <Target channel>=<Constant value>+...
|
||||
|
||||
**Description:**
|
||||
Replaces the audio on the target channel by the sum of the given source channels with optional factors. To add instead of replace the audio on the target channel, the target channel itself can also be a source channel. The factor can also be specified in dB by appending dB. Multiple channel assignments can be specified on a single line by separating them with spaces, therefore a single assignment must not contain spaces. Instead of channel and factor, a constant value can be specified. To avoid ambiguity with numerical channel indices, the constant value must contain a decimal point.
|
||||
Replaces the audio on the target channel by the sum of the given source channels with optional factors. To add instead of replace the audio on the target channel, the target channel itself can also be a source channel. The factor can also be specified in dB by appending dB. Multiple channel assignments can be specified on a single line by separating them with spaces, therefore a single assignment must not contain spaces. Instead of channel and factor, a constant value can be specified. To avoid ambiguity with numerical channel indices, the constant value must contain a decimal point. For more information about channel identifiers, see the [Channel](#channel-since-version-08) command.
|
||||
|
||||
**Example:**
|
||||
|
||||
@@ -142,6 +142,10 @@ Replaces the audio on the target channel by the sum of the given source channels
|
||||
# Attention: Sets the audio on channel L to the audio on the second channel
|
||||
# (not to constant value 2, because no decimal point is present)
|
||||
Copy: L=2
|
||||
# Real world example: Replaces the audio on the subwoofer channel with
|
||||
# the audio on the left channel while muting all other channels of a 5.1 speaker system
|
||||
# (useful for measuring the subwoofer response in REW)
|
||||
Copy: SUB=L L=0.0 R=0.0 C=0.0 RL=0.0 RR=0.0
|
||||
|
||||
<br>
|
||||
# Control commands
|
||||
|
||||
+37
-10
@@ -46,6 +46,7 @@ std::vector<IFilter*> IfFilterFactory::startOfFile(const std::wstring& configPat
|
||||
{
|
||||
trueCountStack.push(trueCount);
|
||||
trueCount = 0;
|
||||
executeElse = false;
|
||||
if(falseCount != 0)
|
||||
{
|
||||
LogF(L"File was included inside If that evaluated to false!");
|
||||
@@ -74,9 +75,14 @@ vector<IFilter*> IfFilterFactory::createFilter(const wstring& configPath, wstrin
|
||||
TraceF(L"If(%s) evaluated to %s (%s)", expression.c_str(), result.ToString().c_str(), isTrue ? L"true" : L"false");
|
||||
|
||||
if(isTrue)
|
||||
{
|
||||
trueCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
falseCount++;
|
||||
executeElse = true;
|
||||
}
|
||||
}
|
||||
catch(ParserError e)
|
||||
{
|
||||
@@ -91,7 +97,19 @@ vector<IFilter*> IfFilterFactory::createFilter(const wstring& configPath, wstrin
|
||||
}
|
||||
else if(command == L"ElseIf")
|
||||
{
|
||||
if(falseCount == 1)
|
||||
if(falseCount == 0)
|
||||
{
|
||||
if(trueCount == 0)
|
||||
{
|
||||
LogF(L"ElseIf without If!");
|
||||
}
|
||||
else
|
||||
{
|
||||
falseCount++;
|
||||
trueCount--;
|
||||
}
|
||||
}
|
||||
else if(falseCount == 1 && executeElse)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -107,6 +125,7 @@ vector<IFilter*> IfFilterFactory::createFilter(const wstring& configPath, wstrin
|
||||
{
|
||||
falseCount--;
|
||||
trueCount++;
|
||||
executeElse = false;
|
||||
}
|
||||
}
|
||||
catch(ParserError e)
|
||||
@@ -114,21 +133,26 @@ vector<IFilter*> IfFilterFactory::createFilter(const wstring& configPath, wstrin
|
||||
LogF(L"Error while evaluating ElseIf(%s): %s", expression.c_str(), e.GetMsg().c_str());
|
||||
}
|
||||
}
|
||||
else if(falseCount == 0 && trueCount == 0)
|
||||
{
|
||||
LogF(L"ElseIf without If!");
|
||||
}
|
||||
}
|
||||
else if(command == L"Else")
|
||||
{
|
||||
if(falseCount == 1)
|
||||
if(falseCount == 0)
|
||||
{
|
||||
if(trueCount == 0)
|
||||
{
|
||||
LogF(L"Else without If!");
|
||||
}
|
||||
else
|
||||
{
|
||||
falseCount++;
|
||||
trueCount--;
|
||||
}
|
||||
}
|
||||
else if(falseCount == 1 && executeElse)
|
||||
{
|
||||
falseCount--;
|
||||
trueCount++;
|
||||
}
|
||||
else if(falseCount == 0 && trueCount == 0)
|
||||
{
|
||||
LogF(L"Else without If!");
|
||||
executeElse = false;
|
||||
}
|
||||
}
|
||||
else if(command == L"EndIf")
|
||||
@@ -144,6 +168,9 @@ vector<IFilter*> IfFilterFactory::createFilter(const wstring& configPath, wstrin
|
||||
{
|
||||
falseCount--;
|
||||
}
|
||||
|
||||
if(falseCount == 0)
|
||||
executeElse = false;
|
||||
}
|
||||
|
||||
if(falseCount > 0)
|
||||
|
||||
@@ -39,6 +39,7 @@ private:
|
||||
|
||||
unsigned trueCount;
|
||||
unsigned falseCount;
|
||||
bool executeElse;
|
||||
std::stack<unsigned> trueCountStack;
|
||||
|
||||
bool toBoolean(const mup::Value& value);
|
||||
|
||||
Reference in new issue
Block a user