velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbris...@apache.org
Subject svn commit: r1873088 - in /velocity/engine/trunk/velocity-engine-core/src: main/parser/ test/resources/gobbling/ test/resources/gobbling/compare/
Date Fri, 24 Jan 2020 07:45:07 GMT
Author: cbrisson
Date: Fri Jan 24 07:45:06 2020
New Revision: 1873088

URL: http://svn.apache.org/viewvc?rev=1873088&view=rev
Log:
[engine][VELOCITY-925] Fix BC whitespace gobbling for macro call without parentheses

Added:
    velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.BC
    velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.LINES
    velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.NONE
    velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.STRUCTURED
    velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/macro2.vtl
Modified:
    velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt

Modified: velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt?rev=1873088&r1=1873087&r2=1873088&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt Fri Jan 24 07:45:06
2020
@@ -1781,6 +1781,7 @@ boolean Directive(boolean afterNewline)
     ArrayList argtypes = new ArrayList(4);
     String blockPrefix = "";
     ASTBlock block = null, elseBlock = null;
+    boolean hasParentheses = false;
     boolean newlineAtStart = afterNewline;
 }
 {
@@ -1908,6 +1909,7 @@ boolean Directive(boolean afterNewline)
             <SINGLE_LINE_COMMENT_START> [<SINGLE_LINE_COMMENT>]
           )
         )* (<WHITESPACE> | <NEWLINE>)* <RPAREN>
+        { hasParentheses = true; }
       )
       |
       {
@@ -1918,10 +1920,10 @@ boolean Directive(boolean afterNewline)
     [
       // Conditions where whitespace and newline postfix is eaten by space gobbling at this
point:
       // - block directive
-      // - new line before directive
-      // - backward compatibility mode
+      // - new line before directive without backward compatibility mode
+      // - backward compatibility mode *with parentheses*
       // - #include() or #parse()
-      LOOKAHEAD(2, { directiveType != Directive.LINE || newlineAtStart || rsvc.getSpaceGobbling()
== SpaceGobbling.BC || d != null && (d instanceof Include || d instanceof Parse) })
+      LOOKAHEAD(2, { directiveType != Directive.LINE || newlineAtStart && rsvc.getSpaceGobbling()
!= SpaceGobbling.BC || rsvc.getSpaceGobbling() == SpaceGobbling.BC && hasParentheses
|| d != null && (d instanceof Include || d instanceof Parse) })
         ( [ ( t = <WHITESPACE> ) ] ( u = <NEWLINE> ) )
       {
           afterNewline = true;

Added: velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.BC
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.BC?rev=1873088&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.BC
(added)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.BC
Fri Jan 24 07:45:06 2020
@@ -0,0 +1,6 @@
+-----
+value
+-----
+
+-----
+value-----

Added: velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.LINES
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.LINES?rev=1873088&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.LINES
(added)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.LINES
Fri Jan 24 07:45:06 2020
@@ -0,0 +1,5 @@
+-----
+value-----
+
+-----
+value-----

Added: velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.NONE
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.NONE?rev=1873088&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.NONE
(added)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.NONE
Fri Jan 24 07:45:06 2020
@@ -0,0 +1,8 @@
+
+-----
+value
+-----
+
+-----
+value
+-----

Added: velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.STRUCTURED
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.STRUCTURED?rev=1873088&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.STRUCTURED
(added)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/compare/macro2.vtl.STRUCTURED
Fri Jan 24 07:45:06 2020
@@ -0,0 +1,5 @@
+-----
+value-----
+
+-----
+value-----

Added: velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/macro2.vtl
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/macro2.vtl?rev=1873088&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/macro2.vtl (added)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/gobbling/macro2.vtl Fri
Jan 24 07:45:06 2020
@@ -0,0 +1,8 @@
+#macro(test)value#end
+-----
+#test
+-----
+
+-----
+#test()
+-----



Mime
View raw message