[Orxonox-commit 5618] r10278 - code/trunk/src/libraries/core

landauf at orxonox.net landauf at orxonox.net
Wed Feb 18 21:56:39 CET 2015


Author: landauf
Date: 2015-02-18 21:56:38 +0100 (Wed, 18 Feb 2015)
New Revision: 10278

Modified:
   code/trunk/src/libraries/core/Loader.cc
Log:
fixed issue with inline-lua-code. only add an extra space if there's actually a line-break at the beginning of the text-content. otherwise code like this: mesh="ast<?lua print(1) ?>.mesh" becomes mesh="ast1 .mesh" instead of mesh="ast1.mesh"

Modified: code/trunk/src/libraries/core/Loader.cc
===================================================================
--- code/trunk/src/libraries/core/Loader.cc	2015-02-18 20:32:48 UTC (rev 10277)
+++ code/trunk/src/libraries/core/Loader.cc	2015-02-18 20:56:38 UTC (rev 10278)
@@ -469,7 +469,10 @@
                     }
                     //A newline directly after square brackets is ignored. To make sure that the string is printed
                     //exactly as it is, including newlines at the beginning, insert a space after the brackets.
-                    output << "print([" + equalSigns + "[ " + temp + ']' + equalSigns +"])";
+                    bool needsExtraSpace = false;
+                    if (temp.size() > 0 && (temp[0] == '\n' || temp[0] == '\r')) // begins with \n or \r (a line break)
+                        needsExtraSpace = true;
+                    output << "print([" + equalSigns + (needsExtraSpace ? "[ " : "[") + temp + ']' + equalSigns +"])";
                     start = end + 5;
                 }
                 else




More information about the Orxonox-commit mailing list