Compare commits

...

2 commits
1.6 ... main

Author SHA1 Message Date
fca624550f Version 1.7
All checks were successful
Build for Releases / ensure-release-exists (push) Successful in 1s
Build for Releases / push-build-x86_64 (push) Successful in 5s
Run Unit Tests / build-and-run-unit-tests (push) Successful in 2m10s
Build for Releases / push-build-aarch64 (push) Successful in 1m16s
Build for Releases / push-build-x86_64_debian (push) Successful in 35s
Build for Releases / push-build-aarch64_debian (push) Successful in 5m30s
2024-11-29 12:11:29 +09:00
b5b12171e1 Fix indexing in IF
Expressions like `{{{!IF SomeVar[2]==true}}}` should work properly now.
2024-11-29 12:10:17 +09:00
3 changed files with 32 additions and 2 deletions

View file

@ -2,6 +2,11 @@
## Upcoming Changes
## Version 1.7
Fix usage of indexing in `IF`.
Note this is used like `{{{!IF SomeVar[2]==true}}}`.
## Version 1.6
Fix usage of `IF` with a `FOREACH` variable when the `IF` is nested in the

View file

@ -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>

View file

@ -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);