Repository: ant
Updated Branches:
  refs/heads/master 110081eef -> 061d29b6f


Inline/whitespace/format

Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/96ed9bdf
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/96ed9bdf
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/96ed9bdf

Branch: refs/heads/master
Commit: 96ed9bdfd06c41860ccee7e860f865b44b8afc13
Parents: 110081e
Author: Gintas Grigelionis <gin...@apache.org>
Authored: Thu Apr 12 08:33:31 2018 +0200
Committer: Gintas Grigelionis <gin...@apache.org>
Committed: Thu Apr 12 09:19:49 2018 +0200

----------------------------------------------------------------------
 src/main/org/apache/tools/ant/taskdefs/Checksum.java          | 6 +-----
 src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java | 3 +--
 src/main/org/apache/tools/ant/taskdefs/SQLExec.java           | 3 ++-
 src/main/org/apache/tools/ant/taskdefs/optional/Javah.java    | 6 ++----
 .../org/apache/tools/ant/taskdefs/optional/net/RExecTask.java | 4 ++--
 .../ant/types/selectors/modifiedselector/DigestAlgorithm.java | 6 +-----
 src/main/org/apache/tools/ant/util/FileUtils.java             | 5 ++---
 src/main/org/apache/tools/ant/util/Native2AsciiUtils.java     | 7 +------
 src/main/org/apache/tools/tar/TarUtils.java                   | 3 +--
 9 files changed, 13 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/96ed9bdf/src/main/org/apache/tools/ant/taskdefs/Checksum.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Checksum.java 
b/src/main/org/apache/tools/ant/taskdefs/Checksum.java
index e753d94..9632723 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Checksum.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Checksum.java
@@ -578,11 +578,7 @@ public class Checksum extends MatchingTask implements 
Condition {
     private String createDigestString(byte[] fileDigest) {
         StringBuilder checksumSb = new StringBuilder();
         for (byte digestByte : fileDigest) {
-            String hexStr = Integer.toHexString(BYTE_MASK & digestByte);
-            if (hexStr.length() < 2) {
-                checksumSb.append('0');
-            }
-            checksumSb.append(hexStr);
+            checksumSb.append(String.format("%02x", BYTE_MASK & digestByte));
         }
         return checksumSb.toString();
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/96ed9bdf/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java 
b/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java
index 2872c7f..17aa051 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ManifestClassPath.java
@@ -76,9 +76,8 @@ public class ManifestClassPath extends Task {
         final FileUtils fileUtils = FileUtils.getFileUtils();
         dir = fileUtils.normalize(dir.getAbsolutePath());
 
-        String[] elements = path.list();
         StringBuilder buffer = new StringBuilder();
-        for (String element : elements) {
+        for (String element : path.list()) {
             // Normalize the current file
             File pathEntry = new File(element);
             String fullPath = pathEntry.getAbsolutePath();

http://git-wip-us.apache.org/repos/asf/ant/blob/96ed9bdf/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java 
b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
index 9d4b5d6..55f80c6 100644
--- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
+++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
@@ -906,7 +906,8 @@ public class SQLExec extends JDBCTask {
     }
 
     private String maybeQuote(String s) {
-        if (csvQuoteChar == null || s == null || (!forceCsvQuoteChar && 
!s.contains(csvColumnSep) && !s.contains(csvQuoteChar))) {
+        if (csvQuoteChar == null || s == null
+                || (!forceCsvQuoteChar && !s.contains(csvColumnSep) && 
!s.contains(csvQuoteChar))) {
             return s;
         }
         StringBuilder sb = new StringBuilder(csvQuoteChar);

http://git-wip-us.apache.org/repos/asf/ant/blob/96ed9bdf/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java 
b/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
index b5dfddc..17dd9d7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
@@ -34,7 +34,6 @@ import org.apache.tools.ant.types.Commandline;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.Reference;
-import org.apache.tools.ant.util.StringUtils;
 import org.apache.tools.ant.util.facade.FacadeTaskHelper;
 import org.apache.tools.ant.util.facade.ImplementationSpecificArgument;
 
@@ -484,11 +483,10 @@ public class Javah extends Task {
         if (c.length > 1) {
             message.append("es");
         }
-        message.append(" to be compiled:");
-        message.append(StringUtils.LINE_SEP);
+        message.append(String.format(" to be compiled:%n"));
         for (String element : c) {
             cmd.createArgument().setValue(element);
-            message.append("    
").append(element).append(StringUtils.LINE_SEP);
+            message.append(String.format("    %s%n", element));
         }
         log(message.toString(), Project.MSG_VERBOSE);
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/96ed9bdf/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java 
b/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
index 8017123..d416060 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
@@ -278,7 +278,7 @@ public class RExecTask extends Task {
                 } else {
                     Calendar endTime = Calendar.getInstance();
                     endTime.add(Calendar.SECOND, timeout);
-                int read = 0;
+                    int read = 0;
                     while (read != -1) {
                         while (Calendar.getInstance().before(endTime) && 
is.available() == 0) {
                             Thread.sleep(PAUSE_TIME);
@@ -289,7 +289,7 @@ public class RExecTask extends Task {
                                                          "Response timed-out 
waiting for EOF",
                                                          getLocation());
                         }
-                        read =  is.read();
+                        read = is.read();
                         if (read != -1) {
                             char c = (char) read;
                             sb.append(c);

http://git-wip-us.apache.org/repos/asf/ant/blob/96ed9bdf/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
----------------------------------------------------------------------
diff --git 
a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
 
b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
index 67a3a39..6b321ea 100644
--- 
a/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
+++ 
b/src/main/org/apache/tools/ant/types/selectors/modifiedselector/DigestAlgorithm.java
@@ -166,11 +166,7 @@ public class DigestAlgorithm implements Algorithm {
             }
             StringBuilder checksumSb = new StringBuilder();
             for (byte digestByte : messageDigest.digest()) {
-                String hexStr = Integer.toHexString(BYTE_MASK & digestByte);
-                if (hexStr.length() < 2) {
-                    checksumSb.append('0');
-                }
-                checksumSb.append(hexStr);
+                checksumSb.append(String.format("%02x", BYTE_MASK & 
digestByte));
             }
             return checksumSb.toString();
         } catch (IOException ignored) {

http://git-wip-us.apache.org/repos/asf/ant/blob/96ed9bdf/src/main/org/apache/tools/ant/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java 
b/src/main/org/apache/tools/ant/util/FileUtils.java
index 541353c..cc2242c 100644
--- a/src/main/org/apache/tools/ant/util/FileUtils.java
+++ b/src/main/org/apache/tools/ant/util/FileUtils.java
@@ -1073,15 +1073,14 @@ public class FileUtils {
         }
         final char[] buffer = new char[bufferSize];
         int bufferLength = 0;
-        StringBuilder textBuffer = null;
+        StringBuilder textBuffer = new StringBuilder();
         while (bufferLength != -1) {
             bufferLength = rdr.read(buffer);
             if (bufferLength > 0) {
-                textBuffer = (textBuffer == null) ? new StringBuilder() : 
textBuffer;
                 textBuffer.append(buffer, 0, bufferLength);
             }
         }
-        return (textBuffer == null) ? null : textBuffer.toString();
+        return (textBuffer.length() == 0) ? null : textBuffer.toString();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ant/blob/96ed9bdf/src/main/org/apache/tools/ant/util/Native2AsciiUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/util/Native2AsciiUtils.java 
b/src/main/org/apache/tools/ant/util/Native2AsciiUtils.java
index a69d031..7a00439 100644
--- a/src/main/org/apache/tools/ant/util/Native2AsciiUtils.java
+++ b/src/main/org/apache/tools/ant/util/Native2AsciiUtils.java
@@ -38,12 +38,7 @@ public class Native2AsciiUtils {
             if (c <= MAX_ASCII) {
                 sb.append(c);
             } else {
-                sb.append("\\u");
-                String encoded = Integer.toHexString(c);
-                for (int i = encoded.length(); i < 4; i++) {
-                    sb.append("0");
-                }
-                sb.append(encoded);
+                sb.append(String.format("\\u%04x", (int) c));
             }
         }
         return sb.toString();

http://git-wip-us.apache.org/repos/asf/ant/blob/96ed9bdf/src/main/org/apache/tools/tar/TarUtils.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/tar/TarUtils.java 
b/src/main/org/apache/tools/tar/TarUtils.java
index fcd0c4e..fcb1127 100644
--- a/src/main/org/apache/tools/tar/TarUtils.java
+++ b/src/main/org/apache/tools/tar/TarUtils.java
@@ -62,8 +62,7 @@ public class TarUtils {
             }
 
             public String decode(final byte[] buffer) {
-                final int length = buffer.length;
-                final StringBuilder result = new StringBuilder(length);
+                final StringBuilder result = new StringBuilder(buffer.length);
 
                 for (final byte b : buffer) {
                     if (b == 0) { // Trailing null

Reply via email to