From 065256f579a3681862b7dc61cce5a6fb45a0244e Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 14 Mar 2014 18:57:51 +0000 Subject: [PATCH] whitespace only git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1577660 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/taskdefs/optional/ReplaceRegExp.java | 160 +++++++++--------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java index 0751ec541..c03f1c309 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java @@ -364,96 +364,96 @@ public class ReplaceRegExp extends Task { BufferedReader br = new BufferedReader(r); BufferedWriter bw = new BufferedWriter(w); - log("Replacing pattern '" + regex.getPattern(getProject()) - + "' with '" + subs.getExpression(getProject()) - + "' in '" + f.getPath() + "'" + (byline ? " by line" : "") - + (flags.length() > 0 ? " with flags: '" + flags + "'" : "") - + ".", Project.MSG_VERBOSE); - - if (byline) { - StringBuffer linebuf = new StringBuffer(); - String line = null; - String res = null; - int c; - boolean hasCR = false; - - do { - c = br.read(); - - if (c == '\r') { - if (hasCR) { - // second CR -> EOL + possibly empty line - line = linebuf.toString(); - res = doReplace(regex, subs, line, options); - - if (!res.equals(line)) { - changes = true; + log("Replacing pattern '" + regex.getPattern(getProject()) + + "' with '" + subs.getExpression(getProject()) + + "' in '" + f.getPath() + "'" + (byline ? " by line" : "") + + (flags.length() > 0 ? " with flags: '" + flags + "'" : "") + + ".", Project.MSG_VERBOSE); + + if (byline) { + StringBuffer linebuf = new StringBuffer(); + String line = null; + String res = null; + int c; + boolean hasCR = false; + + do { + c = br.read(); + + if (c == '\r') { + if (hasCR) { + // second CR -> EOL + possibly empty line + line = linebuf.toString(); + res = doReplace(regex, subs, line, options); + + if (!res.equals(line)) { + changes = true; + } + + bw.write(res); + bw.write('\r'); + + linebuf = new StringBuffer(); + // hasCR is still true (for the second one) + } else { + // first CR in this line + hasCR = true; + } + } else if (c == '\n') { + // LF -> EOL + line = linebuf.toString(); + res = doReplace(regex, subs, line, options); + + if (!res.equals(line)) { + changes = true; + } + + bw.write(res); + if (hasCR) { + bw.write('\r'); + hasCR = false; + } + bw.write('\n'); + + linebuf = new StringBuffer(); + } else { // any other char + if ((hasCR) || (c < 0)) { + // Mac-style linebreak or EOF (or both) + line = linebuf.toString(); + res = doReplace(regex, subs, line, options); + + if (!res.equals(line)) { + changes = true; + } + + bw.write(res); + if (hasCR) { + bw.write('\r'); + hasCR = false; + } + + linebuf = new StringBuffer(); + } + + if (c >= 0) { + linebuf.append((char) c); + } } + } while (c >= 0); - bw.write(res); - bw.write('\r'); + } else { + String buf = FileUtils.safeReadFully(br); - linebuf = new StringBuffer(); - // hasCR is still true (for the second one) - } else { - // first CR in this line - hasCR = true; - } - } else if (c == '\n') { - // LF -> EOL - line = linebuf.toString(); - res = doReplace(regex, subs, line, options); + String res = doReplace(regex, subs, buf, options); - if (!res.equals(line)) { + if (!res.equals(buf)) { changes = true; } bw.write(res); - if (hasCR) { - bw.write('\r'); - hasCR = false; - } - bw.write('\n'); - - linebuf = new StringBuffer(); - } else { // any other char - if ((hasCR) || (c < 0)) { - // Mac-style linebreak or EOF (or both) - line = linebuf.toString(); - res = doReplace(regex, subs, line, options); - - if (!res.equals(line)) { - changes = true; - } - - bw.write(res); - if (hasCR) { - bw.write('\r'); - hasCR = false; - } - - linebuf = new StringBuffer(); - } - - if (c >= 0) { - linebuf.append((char) c); - } } - } while (c >= 0); - - } else { - String buf = FileUtils.safeReadFully(br); - - String res = doReplace(regex, subs, buf, options); - - if (!res.equals(buf)) { - changes = true; - } - - bw.write(res); - } - bw.flush(); + bw.flush(); } finally { os.close();