fix eval bug
[org.ibex.xt-crawshaw.git] / src / java / org / ibex / xt / JSLeaf.java
index 63bffbd..048d475 100644 (file)
@@ -49,7 +49,7 @@ public class JSLeaf implements Tree.Leaf, Serializable {
         while ((exp = s.indexOf("${", pos)) >= 0) {
             ret.append(s.substring(pos, exp));
             pos = s.indexOf("}", exp);
-            Object app = exec("return (" + s.substring(exp + 2, pos) + ");");
+            Object app = exec("return (" + s.substring(exp + 2, pos) + ");\n");
             pos++;
 
             if (!(app == null || app instanceof String ||
@@ -73,9 +73,10 @@ public class JSLeaf implements Tree.Leaf, Serializable {
             pos = s.indexOf("}", exp);
             ret.append("return (");
             ret.append(s.substring(exp + 2, pos));
-            ret.append(");");
+            ret.append(");\n");
             pos++;
         }
+        if (pos < s.length()) ret.append(s.substring(pos));
 
         Reader r = new StringReader(ret.toString());
         try {