@@ -429,14 +429,14 @@ public class Replace extends MatchingTask {
// in order to compare with the file contents, replace them
// in order to compare with the file contents, replace them
// as needed
// as needed
String val = stringReplace(value.getText(), "\n",
String val = stringReplace(value.getText(), "\n",
StringUtils.LINE_SEP);
StringUtils.LINE_SEP, false );
String tok = stringReplace(token.getText(), "\n",
String tok = stringReplace(token.getText(), "\n",
StringUtils.LINE_SEP);
StringUtils.LINE_SEP, false );
// for each found token, replace with value
// for each found token, replace with value
log("Replacing in " + src.getPath() + ": " + token.getText()
log("Replacing in " + src.getPath() + ": " + token.getText()
+ " --> " + value.getText(), Project.MSG_VERBOSE);
+ " --> " + value.getText(), Project.MSG_VERBOSE);
newString = stringReplace(newString, tok, val);
newString = stringReplace(newString, tok, val, true );
}
}
if (replacefilters.size() > 0) {
if (replacefilters.size() > 0) {
@@ -507,7 +507,7 @@ public class Replace extends MatchingTask {
log("Replacing in " + filename + ": " + filter.getToken()
log("Replacing in " + filename + ": " + filter.getToken()
+ " --> " + filter.getReplaceValue(), Project.MSG_VERBOSE);
+ " --> " + filter.getReplaceValue(), Project.MSG_VERBOSE);
newString = stringReplace(newString, filter.getToken(),
newString = stringReplace(newString, filter.getToken(),
filter.getReplaceValue());
filter.getReplaceValue(), true );
}
}
return newString;
return newString;
@@ -627,7 +627,8 @@ public class Replace extends MatchingTask {
/**
/**
* Replace occurrences of str1 in string str with str2
* 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();
StringBuffer ret = new StringBuffer();
int start = 0;
int start = 0;
int found = str.indexOf(str1);
int found = str.indexOf(str1);
@@ -645,7 +646,9 @@ public class Replace extends MatchingTask {
// search again
// search again
start = found + str1.length();
start = found + str1.length();
found = str.indexOf(str1, start);
found = str.indexOf(str1, start);
++replaceCount;
if (countReplaces) {
++replaceCount;
}
}
}
// write the remaining characters
// write the remaining characters