Fix indexing in IF
Expressions like `{{{!IF SomeVar[2]==true}}}` should work properly now.
This commit is contained in:
parent
7735cb2e71
commit
b5b12171e1
2 changed files with 27 additions and 2 deletions
|
@ -36,6 +36,29 @@ HTML='''
|
|||
{{{!ENDIF}}}
|
||||
{{{!ENDFOREACH}}}
|
||||
|
||||
Again with IFs:<br>
|
||||
|
||||
{{{!IF EachIfTest_Array[0]==true}}}
|
||||
EachIfTest_Array entry is <b>true</b>. <br>
|
||||
{{{!ELSE}}}
|
||||
EachIfTest_Array entry is <b>false</b>. <br>
|
||||
{{{!ENDIF}}}
|
||||
{{{!IF EachIfTest_Array[1]==true}}}
|
||||
EachIfTest_Array entry is <b>true</b>. <br>
|
||||
{{{!ELSE}}}
|
||||
EachIfTest_Array entry is <b>false</b>. <br>
|
||||
{{{!ENDIF}}}
|
||||
{{{!IF EachIfTest_Array[2]==true}}}
|
||||
EachIfTest_Array entry is <b>true</b>. <br>
|
||||
{{{!ELSE}}}
|
||||
EachIfTest_Array entry is <b>false</b>. <br>
|
||||
{{{!ENDIF}}}
|
||||
{{{!IF EachIfTest_Array[3]==true}}}
|
||||
EachIfTest_Array entry is <b>true</b>. <br>
|
||||
{{{!ELSE}}}
|
||||
EachIfTest_Array entry is <b>false</b>. <br>
|
||||
{{{!ENDIF}}}
|
||||
|
||||
<br>
|
||||
<h2>Test IF/FOREACH Expr</h2>
|
||||
|
||||
|
|
|
@ -229,10 +229,12 @@ int c_simple_http_internal_parse_if_expression(
|
|||
fprintf(stderr, "ERROR No closing \"]\"! %s\n", var);
|
||||
return 1;
|
||||
} else if (
|
||||
idx + 1 < var_size && var[idx] == '!' && var[idx + 1] == '=') {
|
||||
idx + 2 < var_size && var[idx + 1] == '!' && var[idx + 2] == '=') {
|
||||
++idx;
|
||||
break;
|
||||
} else if (
|
||||
idx + 1 < var_size && var[idx] == '=' && var[idx + 1] == '=') {
|
||||
idx + 2 < var_size && var[idx + 1] == '=' && var[idx + 2] == '=') {
|
||||
++idx;
|
||||
break;
|
||||
} else {
|
||||
fprintf(stderr, "ERROR Invalid expression after \"]\"! %s\n", var);
|
||||
|
|
Loading…
Reference in a new issue