ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Replace.java
Date Thu, 07 Nov 2002 15:15:01 GMT
bodewig     2002/11/07 07:15:01

  Modified:    src/main/org/apache/tools/ant/taskdefs Replace.java
  Log:
  fix misleading message in <replace>.
  
  PR: 14315
  
  Revision  Changes    Path
  1.36      +9 -6      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Replace.java
  
  Index: Replace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Replace.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- Replace.java	25 Jul 2002 15:21:05 -0000	1.35
  +++ Replace.java	7 Nov 2002 15:15:01 -0000	1.36
  @@ -429,14 +429,14 @@
                   // in order to compare with the file contents, replace them
                   // as needed
                   String val = stringReplace(value.getText(), "\n",
  -                                           StringUtils.LINE_SEP);
  +                                           StringUtils.LINE_SEP, false);
                   String tok = stringReplace(token.getText(), "\n",
  -                                           StringUtils.LINE_SEP);
  +                                           StringUtils.LINE_SEP, false);
                   
                   // for each found token, replace with value
                   log("Replacing in " + src.getPath() + ": " + token.getText() 
                       + " --> " + value.getText(), Project.MSG_VERBOSE);
  -                newString = stringReplace(newString, tok, val);
  +                newString = stringReplace(newString, tok, val, true);
               }
   
               if (replacefilters.size() > 0) {
  @@ -507,7 +507,7 @@
               log("Replacing in " + filename + ": " + filter.getToken() 
                   + " --> " + filter.getReplaceValue(), Project.MSG_VERBOSE);
               newString = stringReplace(newString, filter.getToken(), 
  -                                      filter.getReplaceValue());
  +                                      filter.getReplaceValue(), true);
           }
   
           return newString;
  @@ -627,7 +627,8 @@
       /**
        * Replace occurrences of str1 in string str with str2
        */    
  -    private String stringReplace(String str, String str1, String str2) {
  +    private String stringReplace(String str, String str1, String str2,
  +                                 boolean countReplaces) {
           StringBuffer ret = new StringBuffer();
           int start = 0;
           int found = str.indexOf(str1);
  @@ -645,7 +646,9 @@
               // search again
               start = found + str1.length();
               found = str.indexOf(str1, start);
  -            ++replaceCount;
  +            if (countReplaces) {
  +                ++replaceCount;
  +            }
           }
   
           // write the remaining characters
  
  
  

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


Mime
View raw message