commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons-sandbox/util/src/java/org/apache/commons/util StringUtils.java
Date Sun, 13 Jan 2002 22:14:16 GMT
bayard      02/01/13 14:14:16

  Modified:    util/src/java/org/apache/commons/util StringUtils.java
  Log:
  Fixed errors in chop(String) when String is \r\n.
  Fixed errors in getChomp and in getPrechomp.
  
  Revision  Changes    Path
  1.23      +9 -9      jakarta-commons-sandbox/util/src/java/org/apache/commons/util/StringUtils.java
  
  Index: StringUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/util/src/java/org/apache/commons/util/StringUtils.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- StringUtils.java	29 Dec 2001 00:47:30 -0000	1.22
  +++ StringUtils.java	13 Jan 2002 22:14:15 -0000	1.23
  @@ -85,7 +85,7 @@
    * @author <a href="mailto:gcoladonato@yahoo.com">Greg Coladonato</a>
    * @author <a href="mailto:bayard@generationjava.com">Bayard</a>
    * @author <a href="mailto:ed@apache.org">Ed Korthof</a>
  - * @version $Id: StringUtils.java,v 1.22 2001/12/29 00:47:30 dlr Exp $
  + * @version $Id: StringUtils.java,v 1.23 2002/01/13 22:14:15 bayard Exp $
    */
   public class StringUtils
   {
  @@ -678,11 +678,11 @@
        */
       static public String getChomp(String str, String sep) {
           int idx = str.lastIndexOf(sep);
  -        if(idx == str.length()-1) {
  -            return "";
  +        if(idx == str.length()-sep.length()) {
  +            return sep;
           } else
           if(idx != -1) {
  -            return str.substring(idx+1);
  +            return str.substring(idx);
           } else {
               return "";
           }
  @@ -718,7 +718,7 @@
       static public String getPrechomp(String str, String sep) {
           int idx = str.indexOf(sep);
           if(idx != -1) {
  -            return str.substring(0,idx);
  +            return str.substring(0,idx+sep.length());
           } else {
               return "";
           }
  @@ -741,10 +741,10 @@
           }
           int lastIdx = str.length()-1;
           String ret = str.substring(0,lastIdx);
  -        String last = str.substring(lastIdx);
  -        if(last == "\n") {
  -            if(ret.substring(lastIdx-1) == "\r") {
  -                return ret.substring(lastIdx-1);
  +        char last = str.charAt(lastIdx);
  +        if(last == '\n') {
  +            if(ret.charAt(lastIdx-1) == '\r') {
  +                return ret.substring(0,lastIdx-1);
               }
           }
           return ret;
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message