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}}}
|
{{{!ENDIF}}}
|
||||||
{{{!ENDFOREACH}}}
|
{{{!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>
|
<br>
|
||||||
<h2>Test IF/FOREACH Expr</h2>
|
<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);
|
fprintf(stderr, "ERROR No closing \"]\"! %s\n", var);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (
|
} else if (
|
||||||
idx + 1 < var_size && var[idx] == '!' && var[idx + 1] == '=') {
|
idx + 2 < var_size && var[idx + 1] == '!' && var[idx + 2] == '=') {
|
||||||
|
++idx;
|
||||||
break;
|
break;
|
||||||
} else if (
|
} else if (
|
||||||
idx + 1 < var_size && var[idx] == '=' && var[idx + 1] == '=') {
|
idx + 2 < var_size && var[idx + 1] == '=' && var[idx + 2] == '=') {
|
||||||
|
++idx;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "ERROR Invalid expression after \"]\"! %s\n", var);
|
fprintf(stderr, "ERROR Invalid expression after \"]\"! %s\n", var);
|
||||||
|
|
Loading…
Reference in a new issue