Browse Source

fix misleading message in <replace>.

PR: 14315


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273505 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
8d84ae5aef
1 changed files with 9 additions and 6 deletions
  1. +9
    -6
      src/main/org/apache/tools/ant/taskdefs/Replace.java

+ 9
- 6
src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -429,14 +429,14 @@ public class Replace extends MatchingTask {
// 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 @@ public class Replace extends MatchingTask {
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 @@ public class Replace extends MatchingTask {
/**
* 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 @@ public class Replace extends MatchingTask {
// search again
start = found + str1.length();
found = str.indexOf(str1, start);
++replaceCount;
if (countReplaces) {
++replaceCount;
}
}

// write the remaining characters


Loading…
Cancel
Save