Skip to content

Commit 577db64

Browse files
committed
Fix parsing of INLINE with double escaped characters.
Add corresponding regression test. Fixes #37.
1 parent 02bf53e commit 577db64

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
>one:():two:():three<

regtests/tests/0139_inline/test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from test_support import *
2+
3+
run('testme', ["testinline.tmplt"])
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
@@INLINE(>)(:\(\):)(<)@@
3+
@@TABLE@@
4+
@_VAR3_@
5+
@@END_TABLE@@
6+
@@END_INLINE@@

src/templates_parser.adb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,8 +2831,6 @@ package body Templates_Parser is
28312831
Look_For_Char : while K < I_Last loop
28322832
if Buffer (K) = '\' and then Escape = 0 then
28332833
Escape := 2;
2834-
elsif Escape /= 0 then
2835-
Escape := Escape - 1;
28362834
end if;
28372835

28382836
if Escape = 0 then
@@ -2842,6 +2840,9 @@ package body Templates_Parser is
28422840
Level := Level - 1;
28432841
end if;
28442842
exit Look_For_Char when Buffer (K) = Char and then Level = 0;
2843+
2844+
else
2845+
Escape := Escape - 1;
28452846
end if;
28462847

28472848
K := K + 1;
@@ -2899,8 +2900,6 @@ package body Templates_Parser is
28992900
for K in First .. I_Last loop
29002901
if Buffer (K) = '\' and then Escape = 0 then
29012902
Escape := 2;
2902-
elsif Escape /= 0 then
2903-
Escape := Escape - 1;
29042903
end if;
29052904

29062905
if Escape = 0 then
@@ -2912,6 +2911,9 @@ package body Templates_Parser is
29122911
elsif Buffer (K) = ')' then
29132912
Level := Level - 1;
29142913
end if;
2914+
2915+
else
2916+
Escape := Escape - 1;
29152917
end if;
29162918
end loop;
29172919

0 commit comments

Comments
 (0)