Bug + fix: white spaces in preprocessor macros

0 votes
asked Aug 2, 2019 in Bug by Henning (120 points)

Hi all,

given the following example:

!definelong ADD_ARRAY(name, type, length)
    +type name[length]
!enddefinelong

ADD_ARRAY(veryVeryLongName, int, 8)
ADD_ARRAY(shortName       , int, 8)

The preprocessor outputs:

+int veryVeryLongName[8]

+int shortName       [8]

which is not a correct array definition for shortName.

We were able to fix this with the following patch that trims white spaces from macro arguments:

-- a/src/net/sourceforge/plantuml/tim/Eater.java
+++ b/src/net/sourceforge/plantuml/tim/Eater.java
@@ -107,7 +107,7 @@ final protected String eatAndGetOptionalQuotedString() throws EaterException {
         }
         final StringBuilder value = new StringBuilder();
         addUpTo(',', ')', value);
-        return value.toString();
+        return value.toString().trim();
     }

     final public String eatAndGetNumber() throws EaterException {

I would kindly ask you to consider this patch for integration.

Best regards

Henning

1 Answer

0 votes
answered Aug 3, 2019 by plantuml (295,000 points)
Sure, you are right. Thanks for the patch.

This has been integrated in last beta http://beta.plantuml.net/plantuml.jar and will be released in next official release.
commented Aug 5, 2019 by Henning (120 points)
Thanks for taking care so quickly.

Henning
...