|
|
@@ -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 |
|
|
|