You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/01/29 13:14:24 UTC

cvs commit: xml-xalan/java/src/org/apache/xpath/functions FuncSubstring.java

sboag       01/01/29 04:14:23

  Modified:    java/src/org/apache/xpath/functions FuncSubstring.java
  Log:
  Fixed bug reported by "Jarno Elovirta" <ja...@codeonline.com>
  01/29/2001 02:36 AM about substring throwing an error if the start index
  is larger than the string:
  
  Error when attempting to evaluate
  
    <xsl:value-of select="substring($some-string,string-length($some-string) +
  $x)" />
  
  where $x >= 2, Xalan2-J (checked out on Mon Jan 29 09:29:43 GMT+02:00 2001)
  throws an error ($x = 2)
  
    XSLT Error (javax.xml.transform.TransformerException): String index out of
  range: -1
  
  Revision  Changes    Path
  1.5       +5 -0      xml-xalan/java/src/org/apache/xpath/functions/FuncSubstring.java
  
  Index: FuncSubstring.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncSubstring.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FuncSubstring.java	2000/12/16 20:01:54	1.4
  +++ FuncSubstring.java	2001/01/29 12:14:20	1.5
  @@ -119,10 +119,15 @@
           else if (end > lenOfS1)
             end = lenOfS1;
   
  +        if (startIndex > lenOfS1)
  +          startIndex = lenOfS1;
  +
           substr = s1.substring(startIndex, end);
         }
         else
         {
  +        if (startIndex > lenOfS1)
  +          startIndex = lenOfS1;
           substr = s1.substring(startIndex);
         }
       }