changeset 690:036b399b9dfa

8062923: XSL: Run-time internal error in 'substring()' 8062924: XSL: wrong answer from substring() function Reviewed-by: joehw
author aefimov
date Mon, 26 Jan 2015 12:17:59 +0300
parents 833051855168
children b13f7d2000cf
files src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java	Fri Jan 23 18:50:46 2015 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java	Mon Jan 26 12:17:59 2015 +0300
@@ -270,8 +270,8 @@
         if (Double.isNaN(start))
             return(EMPTYSTRING);
 
-            final int strlen = value.length();
-            int istart = (int)Math.round(start) - 1;
+        final int strlen = value.length();
+        int istart = (int)Math.round(start) - 1;
 
         if (istart > strlen)
             return(EMPTYSTRING);
@@ -292,10 +292,11 @@
     public static String substringF(String value, double start, double length) {
         if (Double.isInfinite(start) ||
             Double.isNaN(start) ||
-            Double.isNaN(length))
+            Double.isNaN(length) ||
+            length < 0)
             return(EMPTYSTRING);
 
-            int istart = (int)Math.round(start) - 1;
+        int istart = (int)Math.round(start) - 1;
         final int isum;
         if (Double.isInfinite(length))
             isum = Integer.MAX_VALUE;