diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java index 6a647a453..6cc0bf542 100644 --- a/src/main/org/apache/tools/ant/Main.java +++ b/src/main/org/apache/tools/ant/Main.java @@ -264,8 +264,9 @@ public class Main { if (posEq > 0) { value = name.substring(posEq+1); name = name.substring(0, posEq); - } else if (i < args.length-1) + } else if (i < args.length-1) { value = args[++i]; + } definedProps.put(name, value); } else if (arg.equals("-logger")) { diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index d7a7575b4..0e8c561c8 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -366,7 +366,9 @@ public class Project { * @return the property value, or null for no match */ public String getProperty(String name) { - if (name == null) return null; + if (name == null) { + return null; + } String property = (String) properties.get(name); return property; } @@ -388,7 +390,9 @@ public class Project { * @return the property value, or null for no match */ public String getUserProperty(String name) { - if (name == null) return null; + if (name == null) { + return null; + } String property = (String) userProperties.get(name); return property; } @@ -516,10 +520,12 @@ public class Project { */ public void setBaseDir(File baseDir) throws BuildException { baseDir = fileUtils.normalize(baseDir.getAbsolutePath()); - if (!baseDir.exists()) + if (!baseDir.exists()) { throw new BuildException("Basedir " + baseDir.getAbsolutePath() + " does not exist"); - if (!baseDir.isDirectory()) + } + if (!baseDir.isDirectory()) { throw new BuildException("Basedir " + baseDir.getAbsolutePath() + " is not a directory"); + } this.baseDir = baseDir; setPropertyInternal( "basedir", this.baseDir.getPath()); String msg = "Project base dir set to: " + this.baseDir; @@ -635,8 +641,9 @@ public class Project { log(message, Project.MSG_ERR); throw new BuildException(message); } - if( !Task.class.isAssignableFrom(taskClass) ) + if( !Task.class.isAssignableFrom(taskClass) ) { TaskAdapter.checkTaskClass(taskClass, this); + } } /** @@ -815,8 +822,9 @@ public class Project { public Object createDataType(String typeName) throws BuildException { Class c = (Class) dataClassDefinitions.get(typeName); - if (c == null) + if (c == null) { return null; + } try { java.lang.reflect.Constructor ctor = null; diff --git a/src/main/org/apache/tools/ant/taskdefs/Delete.java b/src/main/org/apache/tools/ant/taskdefs/Delete.java index dd18ae2f9..25d21aba5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Delete.java +++ b/src/main/org/apache/tools/ant/taskdefs/Delete.java @@ -266,11 +266,12 @@ public class Delete extends MatchingTask { if (!file.delete()) { String message="Unable to delete file " + file.getAbsolutePath(); - if(failonerror) + if(failonerror) { throw new BuildException(message); - else + } else { log(message, quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); + } } } } else { @@ -337,7 +338,9 @@ public class Delete extends MatchingTask { protected void removeDir(File d) { String[] list = d.list(); - if (list == null) list = new String[0]; + if (list == null) { + list = new String[0]; + } for (int i = 0; i < list.length; i++) { String s = list[i]; File f = new File(d, s); @@ -347,22 +350,24 @@ public class Delete extends MatchingTask { log("Deleting " + f.getAbsolutePath(), verbosity); if (!f.delete()) { String message="Unable to delete file " + f.getAbsolutePath(); - if(failonerror) + if(failonerror) { throw new BuildException(message); - else + } else { log(message, quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); + } } } } log("Deleting directory " + d.getAbsolutePath(), verbosity); if (!d.delete()) { String message="Unable to delete directory " + dir.getAbsolutePath(); - if(failonerror) + if(failonerror) { throw new BuildException(message); - else + } else { log(message, quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); + } } } @@ -381,11 +386,12 @@ public class Delete extends MatchingTask { log("Deleting " + f.getAbsolutePath(), verbosity); if (!f.delete()) { String message="Unable to delete file " + f.getAbsolutePath(); - if(failonerror) + if(failonerror) { throw new BuildException(message); - else + } else { log(message, quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); + } } } } @@ -400,11 +406,12 @@ public class Delete extends MatchingTask { if (!dir.delete()) { String message="Unable to delete directory " + dir.getAbsolutePath(); - if(failonerror) + if(failonerror) { throw new BuildException(message); - else + } else { log(message, quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); + } } else { dirCount++; } diff --git a/src/main/org/apache/tools/ant/taskdefs/Ear.java b/src/main/org/apache/tools/ant/taskdefs/Ear.java index 3e385332d..8257585a8 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Ear.java +++ b/src/main/org/apache/tools/ant/taskdefs/Ear.java @@ -92,8 +92,9 @@ public class Ear extends Jar { */ public void setAppxml(File descr) { deploymentDescriptor = descr; - if (!deploymentDescriptor.exists()) + if (!deploymentDescriptor.exists()) { throw new BuildException("Deployment descriptor: " + deploymentDescriptor + " does not exist."); + } // Create a ZipFileSet for this file, and pass it up. ZipFileSet fs = new ZipFileSet(); diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java index cd0c01537..407f42091 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java @@ -259,7 +259,9 @@ public class ExecTask extends Task { */ protected Execute prepareExec() throws BuildException { // default directory to the project's base directory - if (dir == null) dir = project.getBaseDir(); + if (dir == null) { + dir = project.getBaseDir(); + } // show the command log(cmdl.toString(), Project.MSG_VERBOSE); @@ -360,7 +362,9 @@ public class ExecTask extends Task { * Create the Watchdog to kill a runaway process. */ protected ExecuteWatchdog createWatchdog() throws BuildException { - if (timeout == null) return null; + if (timeout == null) { + return null; + } return new ExecuteWatchdog(timeout.intValue()); } @@ -369,8 +373,12 @@ public class ExecTask extends Task { */ protected void logFlush() { try { - if (fos != null) fos.close(); - if (baos != null) baos.close(); + if (fos != null) { + fos.close(); + } + if (baos != null) { + baos.close(); + } } catch (IOException io) {} } diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index e283ac24b..a9b137061 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -172,7 +172,9 @@ public class Execute { * Find the list of environment variables for this process. */ public static synchronized Vector getProcEnvironment() { - if (procEnvironment != null) return procEnvironment; + if (procEnvironment != null) { + return procEnvironment; + } procEnvironment = new Vector(); try { @@ -326,7 +328,9 @@ public class Execute { * @return the environment used to create a subprocess */ public String[] getEnvironment() { - if (env == null || newEnvironment) return env; + if (env == null || newEnvironment) { + return env; + } return patchEnvironment(); } @@ -352,10 +356,11 @@ public class Execute { * @param wd the working directory of the process. */ public void setWorkingDirectory(File wd) { - if (wd == null || wd.getAbsolutePath().equals(antWorkingDirectory)) + if (wd == null || wd.getAbsolutePath().equals(antWorkingDirectory)) { workingDirectory = null; - else + } else { workingDirectory = wd; + } } /** @@ -408,16 +413,22 @@ public class Execute { // processDestroyer.add(process); - if (watchdog != null) watchdog.start(process); + if (watchdog != null) { + watchdog.start(process); + } waitFor(process); // remove the process to the list of those to destroy if the VM exits // processDestroyer.remove(process); - if (watchdog != null) watchdog.stop(); + if (watchdog != null) { + watchdog.stop(); + } streamHandler.stop(); - if (watchdog != null) watchdog.checkException(); + if (watchdog != null) { + watchdog.checkException(); + } return getExitValue(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java b/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java index d58dfb030..2fbfc310f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java +++ b/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java @@ -128,7 +128,9 @@ public class GenerateKey extends Task { public String encode( final String string ) { int end = string.indexOf(','); - if( -1 == end ) return string; + if( -1 == end ) { + return string; + } final StringBuffer sb = new StringBuffer(); diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 651938973..53738a423 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -751,10 +751,11 @@ public class Javadoc extends Task { toExecute.setExecutable( getJavadocExecutableName() ); // ------------------------------------------------ general javadoc arguments - if (classpath == null) + if (classpath == null) { classpath = Path.systemClasspath; - else + } else { classpath = classpath.concatSystemClasspath("ignore"); + } if (!javadoc1) { toExecute.createArgument().setValue("-classpath"); @@ -767,10 +768,12 @@ public class Javadoc extends Task { System.getProperty("path.separator") + classpath.toString()); } - if (version && doclet == null) + if (version && doclet == null) { toExecute.createArgument().setValue("-version"); - if (author && doclet == null) + } + if (author && doclet == null) { toExecute.createArgument().setValue("-author"); + } if (javadoc1 || doclet == null) { if (destDir == null) { @@ -1027,7 +1030,9 @@ public class Javadoc extends Task { Vector addedPackages = new Vector(); String[] list = sourcePath.list(); - if (list == null) list = new String[0]; + if (list == null) { + list = new String[0]; + } FileSet fs = new FileSet(); fs.setDefaultexcludes(useDefaultExcludes); @@ -1123,10 +1128,11 @@ public class Javadoc extends Task { queuedLine = line; } else { if (queuedLine != null) { - if (line.startsWith("Building ")) + if (line.startsWith("Building ")) { super.processLine(queuedLine, Project.MSG_VERBOSE); - else + } else { super.processLine(queuedLine, Project.MSG_INFO); + } queuedLine = null; } super.processLine(line, messageLevel); diff --git a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java index 40e398770..6456d690f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java +++ b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java @@ -125,10 +125,11 @@ public class JikesOutputParser implements ExecuteStreamHandler { * @param reader - Reader used to read jikes's output */ protected void parseOutput(BufferedReader reader) throws IOException { - if (emacsMode) + if (emacsMode) { parseEmacsOutput(reader); - else + } else { parseStandardOutput(reader); + } } private void parseStandardOutput(BufferedReader reader) throws IOException { @@ -145,21 +146,23 @@ public class JikesOutputParser implements ExecuteStreamHandler { while ((line = reader.readLine()) != null) { lower = line.toLowerCase(); - if (line.trim().equals("")) + if (line.trim().equals("")) { continue; - if (lower.indexOf("error") != -1) + } + if (lower.indexOf("error") != -1) { setError(true); - else if (lower.indexOf("warning") != -1) + } else if (lower.indexOf("warning") != -1) { setError(false); - else { + } else { // If we don't know the type of the line // and we are in emacs mode, it will be // an error, because in this mode, jikes won't // always print "error", but sometimes other // keywords like "Syntax". We should look for // all those keywords. - if (emacsMode) + if (emacsMode) { setError(true); + } } log(line); } @@ -172,8 +175,9 @@ public class JikesOutputParser implements ExecuteStreamHandler { private void setError(boolean err) { error = err; - if(error) + if(error) { errorFlag = true; + } } private void log(String line) { diff --git a/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java b/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java index da66050cc..736ac0ac0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java +++ b/src/main/org/apache/tools/ant/taskdefs/LogOutputStream.java @@ -100,8 +100,12 @@ public class LogOutputStream extends OutputStream { public void write(int cc) throws IOException { final byte c = (byte)cc; if ((c == '\n') || (c == '\r')) { - if (!skip) processBuffer(); - } else buffer.write(cc); + if (!skip) { + processBuffer(); + } + } else { + buffer.write(cc); + } skip = (c == '\r'); } @@ -137,7 +141,9 @@ public class LogOutputStream extends OutputStream { * Writes all remaining */ public void close() throws IOException { - if (buffer.size() > 0) processBuffer(); + if (buffer.size() > 0) { + processBuffer(); + } super.close(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Move.java b/src/main/org/apache/tools/ant/taskdefs/Move.java index aba7716cf..f7488ca6b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Move.java +++ b/src/main/org/apache/tools/ant/taskdefs/Move.java @@ -211,13 +211,17 @@ public class Move extends Copy { */ protected boolean okToDelete(File d) { String[] list = d.list(); - if (list == null) return false; // maybe io error? + if (list == null) { + return false; + } // maybe io error? for (int i = 0; i < list.length; i++) { String s = list[i]; File f = new File(d, s); if (f.isDirectory()) { - if (!okToDelete(f)) return false; + if (!okToDelete(f)) { + return false; + } } else { return false; // found a file } @@ -231,7 +235,9 @@ public class Move extends Copy { */ protected void deleteDir(File d) { String[] list = d.list(); - if (list == null) return; // on an io error list() can return null + if (list == null) { + return; + } // on an io error list() can return null for (int i = 0; i < list.length; i++) { String s = list[i]; diff --git a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java index a01fb8e64..daa64bd90 100644 --- a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java +++ b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java @@ -137,8 +137,9 @@ public class PathConvert extends Task { */ public Path createPath() { - if( isReference() ) + if( isReference() ) { throw noChildrenAllowed(); + } if( path == null ) { path = new Path(getProject()); @@ -190,8 +191,9 @@ public class PathConvert extends Task { * Adds a reference to a PATH or FILESET defined elsewhere. */ public void setRefid(Reference r) { - if( path != null ) + if( path != null ) { throw noChildrenAllowed(); + } refid = r; } @@ -271,7 +273,9 @@ public class PathConvert extends Task { elem = elem.replace( fromDirSep, toDirSep ); - if( i != 0 ) rslt.append( pathSep ); + if( i != 0 ) { + rslt.append( pathSep ); + } rslt.append( elem ); } @@ -323,16 +327,19 @@ public class PathConvert extends Task { */ private void validateSetup() throws BuildException { - if( path == null ) + if( path == null ) { throw new BuildException( "You must specify a path to convert" ); + } - if( property == null ) + if( property == null ) { throw new BuildException( "You must specify a property" ); + } // Must either have a target OS or both a dirSep and pathSep - if( targetOS == null && pathSep == null && dirSep == null ) + if( targetOS == null && pathSep == null && dirSep == null ) { throw new BuildException( "You must specify at least one of targetOS, dirSep, or pathSep" ); + } // Determine the separator strings. The dirsep and pathsep attributes // override the targetOS settings. diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java index c3ecb71c4..1e5238850 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Property.java +++ b/src/main/org/apache/tools/ant/taskdefs/Property.java @@ -197,11 +197,17 @@ public class Property extends Task { addProperty(name, value); } - if (file != null) loadFile(file); + if (file != null) { + loadFile(file); + } - if (resource != null) loadResource(resource); + if (resource != null) { + loadResource(resource); + } - if (env != null) loadEnvironment(env); + if (env != null) { + loadEnvironment(env); + } if ((name != null) && (ref != null)) { Object obj = ref.getReferencedObject(getProject()); @@ -266,7 +272,9 @@ public class Property extends Task { protected void loadEnvironment( String prefix ) { Properties props = new Properties(); - if (!prefix.endsWith(".")) prefix += "."; + if (!prefix.endsWith(".")) { + prefix += "."; + } log("Loading Environment " + prefix, Project.MSG_VERBOSE); Vector osEnv = Execute.getProcEnvironment(); for (Enumeration e = osEnv.elements(); e.hasMoreElements(); ) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Recorder.java b/src/main/org/apache/tools/ant/taskdefs/Recorder.java index 36cf4e721..146ffcd29 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Recorder.java +++ b/src/main/org/apache/tools/ant/taskdefs/Recorder.java @@ -157,8 +157,9 @@ public class Recorder extends Task { * The main execution. */ public void execute() throws BuildException { - if ( filename == null ) + if ( filename == null ) { throw new BuildException( "No filename specified" ); + } getProject().log( "setting a recorder for name " + filename, Project.MSG_DEBUG ); diff --git a/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java b/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java index b24e3b1db..10c77c3a3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java +++ b/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java @@ -121,8 +121,9 @@ public class RecorderEntry implements BuildLogger { * @param state true for on, false for off, null for no change. */ public void setRecordState( Boolean state ) { - if ( state != null ) + if ( state != null ) { record = state.booleanValue(); + } } public void buildStarted(BuildEvent event) { @@ -194,8 +195,9 @@ public class RecorderEntry implements BuildLogger { } public void setMessageOutputLevel(int level) { - if ( level >= Project.MSG_ERR && level <= Project.MSG_DEBUG ) + if ( level >= Project.MSG_ERR && level <= Project.MSG_DEBUG ) { loglevel = level; + } } public void setOutputPrintStream(PrintStream output) { diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java index 4037c5ad4..1505328f0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java @@ -122,8 +122,9 @@ public class Jikes extends DefaultCompilerAdapter { Commandline cmd = new Commandline(); cmd.setExecutable("jikes"); - if (deprecation == true) + if (deprecation == true) { cmd.createArgument().setValue("-deprecation"); + } if (destDir != null) { cmd.createArgument().setValue("-d"); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java b/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java index c8e85c10c..9d674a2c6 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ManifestFile.java @@ -53,8 +53,9 @@ public class ManifestFile extends Task { */ public void execute() throws BuildException { checkParameters(); - if (isUpdate(currentMethod)) + if (isUpdate(currentMethod)) { readFile(); + } executeOperation(); writeFile(); @@ -184,8 +185,9 @@ public class ManifestFile extends Task { c = fis.read(); if (c == -1){ stop =true; - } else + } else { buffer.append( (char) c); + } } fis.close(); StringTokenizer lineTokens = getLineTokens (buffer); @@ -312,8 +314,9 @@ public class ManifestFile extends Task { Entry ent = new Entry(); boolean result = false; int res = ent.compare (this,(Entry) obj ); - if (res==0) + if (res==0) { result =true; + } return result; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java index 94fb20588..2320d95f0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java @@ -197,7 +197,9 @@ public class NetRexxC extends MatchingTask { */ public void setCompile(boolean compile) { this.compile = compile; - if (!this.compile && !this.keep) this.keep = true; + if (!this.compile && !this.keep) { + this.keep = true; + } } /** diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java index da43b3ccb..88c4903c1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java @@ -420,7 +420,9 @@ public class PropertyFile extends Task GregorianCalendar value = new GregorianCalendar(); GregorianCalendar newValue = new GregorianCalendar(); - if (m_pattern == null) m_pattern = "yyyy/MM/dd HH:mm"; + if (m_pattern == null) { + m_pattern = "yyyy/MM/dd HH:mm"; + } DateFormat fmt = new SimpleDateFormat(m_pattern); // special case 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 140bce798..ca5d32b3d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java @@ -180,8 +180,9 @@ public class ReplaceRegExp extends Task public void setMatch(String match) { - if (regex != null) + if (regex != null) { throw new BuildException("Only one regular expression is allowed"); + } regex = new RegularExpression(); regex.setPattern(match); @@ -189,8 +190,9 @@ public class ReplaceRegExp extends Task public void setReplace(String replace) { - if (subs != null) + if (subs != null) { throw new BuildException("Only one substitution expression is allowed"); + } subs = new Substitution(); subs.setExpression(replace); @@ -204,8 +206,9 @@ public class ReplaceRegExp extends Task public void setByLine(String byline) { Boolean res = Boolean.valueOf(byline); - if (res == null) + if (res == null) { res = Boolean.FALSE; + } this.byline = res.booleanValue(); } @@ -216,8 +219,9 @@ public class ReplaceRegExp extends Task public RegularExpression createRegularExpression() { - if (regex != null) + if (regex != null) { throw new BuildException("Only one regular expression is allowed."); + } regex = new RegularExpression(); return regex; @@ -225,8 +229,9 @@ public class ReplaceRegExp extends Task public Substitution createSubstitution() { - if (subs != null) + if (subs != null) { throw new BuildException("Only one substitution expression is allowed"); + } subs = new Substitution(); return subs; @@ -287,8 +292,9 @@ public class ReplaceRegExp extends Task while ((line = lnr.readLine()) != null) { String res = doReplace(regex, subs, line, options); - if (! res.equals(line)) + if (! res.equals(line)) { changes = true; + } pw.println(res); } @@ -309,8 +315,9 @@ public class ReplaceRegExp extends Task String buf = new String(tmpBuf); String res = doReplace(regex, subs, buf, options); - if (! res.equals(buf)) + if (! res.equals(buf)) { changes = true; + } pw.println(res); pw.flush(); @@ -333,10 +340,14 @@ public class ReplaceRegExp extends Task } finally { - try { if (r != null) r.close(); } + try { if (r != null) { + r.close(); + } } catch (Exception e) { }; - try { if (w != null) r.close(); } + try { if (w != null) { + r.close(); + } } catch (Exception e) { }; } } @@ -344,28 +355,35 @@ public class ReplaceRegExp extends Task public void execute() throws BuildException { - if (regex == null) + if (regex == null) { throw new BuildException("No expression to match."); - if (subs == null) + } + if (subs == null) { throw new BuildException("Nothing to replace expression with."); + } - if (file != null && filesets.size() > 0) + if (file != null && filesets.size() > 0) { throw new BuildException("You cannot supply the 'file' attribute and filesets at the same time."); + } int options = 0; - if (flags.indexOf('g') != -1) + if (flags.indexOf('g') != -1) { options |= Regexp.REPLACE_ALL; + } - if (flags.indexOf('i') != -1) + if (flags.indexOf('i') != -1) { options |= Regexp.MATCH_CASE_INSENSITIVE; + } - if (flags.indexOf('m') != -1) + if (flags.indexOf('m') != -1) { options |= Regexp.MATCH_MULTILINE; + } - if (flags.indexOf('s') != -1) + if (flags.indexOf('s') != -1) { options |= Regexp.MATCH_SINGLELINE; + } if (file != null && file.exists()) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java index 5d4611592..6bec18e1f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/dotnet/CSharp.java @@ -537,9 +537,9 @@ public class CSharp * @return The ExtraOptions Parameter to CSC */ protected String getExtraOptionsParameter() { - if (_extraOptions!=null && _extraOptions.length()!=0) + if (_extraOptions!=null && _extraOptions.length()!=0) { return _extraOptions; - else { + } else { return null; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java index d6df5b96e..07f8b572c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java @@ -777,8 +777,9 @@ public class GenericDeploymentTool implements EJBDeploymentTool { Iterator i = checkEntries.keySet().iterator(); while (i.hasNext()) { String entryName = (String)i.next(); - if (entryName.endsWith(".class")) + if (entryName.endsWith(".class")) { newSet.add(entryName.substring(0, entryName.length() - ".class".length()).replace(File.separatorChar, '/')); + } } set.addAll(newSet); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java index 32b28c842..1cf7aad99 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java @@ -257,17 +257,20 @@ public class JDependTask extends Task { CommandlineJava commandline = new CommandlineJava(); - if("text".equals(format)) + if("text".equals(format)) { commandline.setClassname("jdepend.textui.JDepend"); - else - if("xml".equals(format)) + } else + if("xml".equals(format)) { commandline.setClassname("jdepend.xmlui.JDepend"); + } - if(_jvm!=null) + if(_jvm!=null) { commandline.setVm(_jvm); + } - if (getSourcespath() == null) + if (getSourcespath() == null) { throw new BuildException("Missing Sourcepath required argument"); + } // execute the test and get the return code int exitValue = JDependTask.ERRORS; @@ -289,11 +292,12 @@ public class JDependTask extends Task { boolean errorOccurred = exitValue == JDependTask.ERRORS; if (errorOccurred) { - if (getHaltonerror()) + if (getHaltonerror()) { throw new BuildException("JDepend failed", location); - else + } else { log("JDepend FAILED", Project.MSG_ERR); + } } } @@ -310,10 +314,11 @@ public class JDependTask extends Task { public int executeInVM(CommandlineJava commandline) throws BuildException { jdepend.textui.JDepend jdepend; - if("xml".equals(format)) + if("xml".equals(format)) { jdepend = new jdepend.xmlui.JDepend(); - else + } else { jdepend = new jdepend.textui.JDepend(); + } if (getOutputFile() != null) { FileWriter fw; @@ -386,8 +391,9 @@ public class JDependTask extends Task { File f = new File(sourcesPath.nextToken()); // not necessary as JDepend would fail, but why loose some time? - if (! f.exists() || !f.isDirectory()) + if (! f.exists() || !f.isDirectory()) { throw new BuildException("\""+ f.getPath() + "\" does not represent a valid directory. JDepend would fail."); + } commandline.createArgument().setValue(f.getPath()); } @@ -398,8 +404,9 @@ public class JDependTask extends Task { execute.setAntRun(project); } - if (getOutputFile() != null) + if (getOutputFile() != null) { log("Output to be stored in " + getOutputFile().getPath()); + } log("Executing: "+commandline.toString(), Project.MSG_VERBOSE); try { return execute.execute(); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java index a2b229839..43ab9fe5c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java @@ -248,15 +248,17 @@ public class JspC extends MatchingTask /* ------------------------------------------------------------ */ /** Set the classpath to be used for this compilation */ public void setClasspath(Path cp) { - if (classpath == null) + if (classpath == null) { classpath = cp; - else + } else { classpath.append(cp); + } } /** Maybe creates a nested classpath element. */ public Path createClasspath() { - if (classpath == null) + if (classpath == null) { classpath = new Path(project); + } return classpath.createPath(); } /** Adds a reference to a CLASSPATH defined elsewhere */ @@ -294,9 +296,9 @@ public class JspC extends MatchingTask // calculate where the files will end up: File dest = null; - if (packageName == null) + if (packageName == null) { dest = destDir; - else { + } else { String path = destDir.getPath() + File.separatorChar + packageName.replace('.', File.separatorChar); dest = new File(path); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java index e951b58c7..93a40a366 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java @@ -79,12 +79,14 @@ public class JasperC extends DefaultCompilerAdapter // Create an instance of the compiler, redirecting output to // the project log Java java = (Java)(getJspc().getProject()).createTask("java"); - if (getJspc().getClasspath() != null) + if (getJspc().getClasspath() != null) { java.setClasspath(getJspc().getClasspath()); + } java.setClassname("org.apache.jasper.JspC"); String args[] = cmd.getArguments(); - for (int i =0; i < args.length; i++) + for (int i =0; i < args.length; i++) { java.createArg().setValue(args[i]); + } java.setFailonerror(true); java.execute(); return true; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index dc404d659..a33252812 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -518,7 +518,9 @@ public class JUnitTask extends Task { } catch (IOException e) { throw new BuildException("Process fork failed.", e, location); } finally { - if (! propsFile.delete()) throw new BuildException("Could not delete temporary properties file."); + if (! propsFile.delete()) { + throw new BuildException("Could not delete temporary properties file."); + } } return retVal; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java index c46d32f79..993aa1374 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java @@ -321,14 +321,16 @@ public class MimeMail extends Task { String addrUserName, String addrList ) throws MessagingException, BuildException { - if ((null == addrList) || (addrList.trim().length() <= 0)) + if ((null == addrList) || (addrList.trim().length() <= 0)) { return; + } try { InternetAddress[] addrArray = InternetAddress.parse(addrList); - if ((null == addrArray) || (0 == addrArray.length)) + if ((null == addrArray) || (0 == addrArray.length)) { throw new BuildException("Empty " + addrUserName + " recipients list was specified"); + } msg.setRecipients(recipType, addrArray); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java index ae65a7654..f8cf60773 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Add.java @@ -87,14 +87,16 @@ public class P4Add extends P4Base { private int m_cmdLength = 450; public void setCommandlength(int len) throws BuildException { - if(len <= 0) + if(len <= 0) { throw new BuildException("P4Add: Commandlength should be a positive number"); + } this.m_cmdLength = len; } public void setChangelist(int changelist) throws BuildException { - if(changelist <= 0) + if(changelist <= 0) { throw new BuildException("P4Add: Changelist# should be a positive number"); + } this.m_changelist = changelist; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java index 53263ea56..b94018ff4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java @@ -116,9 +116,15 @@ public abstract class P4Base extends org.apache.tools.ant.Task { //Get default P4 settings from environment - Mark would have done something cool with //introspection here.....:-) String tmpprop; - if((tmpprop = project.getProperty("p4.port")) != null) setPort(tmpprop); - if((tmpprop = project.getProperty("p4.client")) != null) setClient(tmpprop); - if((tmpprop = project.getProperty("p4.user")) != null) setUser(tmpprop); + if((tmpprop = project.getProperty("p4.port")) != null) { + setPort(tmpprop); + } + if((tmpprop = project.getProperty("p4.client")) != null) { + setClient(tmpprop); + } + if((tmpprop = project.getProperty("p4.user")) != null) { + setUser(tmpprop); + } } protected void execP4Command(String command) throws BuildException { @@ -157,7 +163,9 @@ public abstract class P4Base extends org.apache.tools.ant.Task { log("Execing "+cmdl, Project.MSG_VERBOSE); - if(handler == null ) handler = new SimpleP4OutputHandler(this); + if(handler == null ) { + handler = new SimpleP4OutputHandler(this); + } Execute exe = new Execute(handler, null); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java index 83691bb8c..07a18a526 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java @@ -79,7 +79,9 @@ public class P4Change extends P4Base { public void execute() throws BuildException { - if(emptyChangeList == null) emptyChangeList = getEmptyChangeList(); + if(emptyChangeList == null) { + emptyChangeList = getEmptyChangeList(); + } final Project myProj = project; P4Handler handler = new P4HandlerAdapter() { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java index 7c432f8ed..b3e4147ec 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java @@ -76,8 +76,12 @@ public class P4Delete extends P4Base { } public void execute() throws BuildException { - if(change != null ) P4CmdOpts = "-c "+change; - if(P4View == null) throw new BuildException("No view specified to delete"); + if(change != null ) { + P4CmdOpts = "-c "+change; + } + if(P4View == null) { + throw new BuildException("No view specified to delete"); + } execP4Command("-s delete "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this)); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java index 151c81200..e80dbfc79 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java @@ -78,8 +78,12 @@ import org.apache.tools.ant.BuildException; } public void execute() throws BuildException { - if(change != null ) P4CmdOpts = "-c "+change; - if(P4View == null) throw new BuildException("No view specified to edit"); + if(change != null ) { + P4CmdOpts = "-c "+change; + } + if(P4View == null) { + throw new BuildException("No view specified to edit"); + } execP4Command("-s edit "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this)); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java index 1a9eb2592..b6aeacc10 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java @@ -69,14 +69,19 @@ public class P4Reopen extends P4Base { private String toChange = ""; public void setToChange(String toChange) throws BuildException { - if(toChange == null && !toChange.equals("")) + if(toChange == null && !toChange.equals("")) { throw new BuildException("P4Reopen: tochange cannot be null or empty"); + } this.toChange = toChange; } public void execute() throws BuildException { - if(P4View == null) if(P4View == null) throw new BuildException("No view specified to reopen"); + if(P4View == null) { + if(P4View == null) { + throw new BuildException("No view specified to reopen"); + } + } execP4Command("-s reopen -c "+toChange+" "+P4View, new SimpleP4OutputHandler(this)); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java index 8d0b95402..49141cb29 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java @@ -70,8 +70,9 @@ public class P4Revert extends P4Base { private boolean onlyUnchanged = false; public void setChange(String revertChange) throws BuildException { - if(revertChange == null && !revertChange.equals("")) + if(revertChange == null && !revertChange.equals("")) { throw new BuildException("P4Revert: change cannot be null or empty"); + } this.revertChange = revertChange; @@ -91,9 +92,13 @@ public class P4Revert extends P4Base { * The whole process also accepts a p4 filespec */ String p4cmd = "-s revert"; - if(onlyUnchanged) p4cmd+=" -a"; + if(onlyUnchanged) { + p4cmd+=" -a"; + } - if (revertChange != null) p4cmd += " -c "+revertChange; + if (revertChange != null) { + p4cmd += " -c "+revertChange; + } execP4Command(p4cmd+" "+P4View, new SimpleP4OutputHandler(this)); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java index 810e3dd81..78ddf89e4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java @@ -84,8 +84,9 @@ public class P4Sync extends P4Base { private String syncCmd = ""; public void setLabel(String label) throws BuildException { - if(label == null && !label.equals("")) + if(label == null && !label.equals("")) { throw new BuildException("P4Sync: Labels cannot be Null or Empty"); + } this.label = label; @@ -93,8 +94,9 @@ public class P4Sync extends P4Base { public void setForce(String force) throws BuildException { - if(force == null && !label.equals("")) + if(force == null && !label.equals("")) { throw new BuildException("P4Sync: If you want to force, set force to non-null string!"); + } P4CmdOpts = "-f"; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java index cce46015b..3bace3089 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java @@ -143,11 +143,13 @@ public class Pvcs extends org.apache.tools.ant.Task { private String getExecutable(String exe) { StringBuffer correctedExe = new StringBuffer(); - if(getPvcsbin()!=null) - if(pvcsbin.endsWith(File.separator)) + if(getPvcsbin()!=null) { + if(pvcsbin.endsWith(File.separator)) { correctedExe.append(pvcsbin); - else + } else { correctedExe.append(pvcsbin).append(File.separator); + } + } return correctedExe.append(exe).toString(); } @@ -158,8 +160,9 @@ public class Pvcs extends org.apache.tools.ant.Task { Project aProj = getProject(); int result = 0; - if(repository == null || repository.trim().equals("")) + if(repository == null || repository.trim().equals("")) { throw new BuildException("Required argument repository not specified"); + } // Check workspace exists // Launch PCLI listversionedfiles -z -aw @@ -171,22 +174,26 @@ public class Pvcs extends org.apache.tools.ant.Task { commandLine.createArgument().setValue("lvf"); commandLine.createArgument().setValue("-z"); commandLine.createArgument().setValue("-aw"); - if(getWorkspace()!=null) + if(getWorkspace()!=null) { commandLine.createArgument().setValue("-sp"+getWorkspace()); + } commandLine.createArgument().setValue("-pr"+getRepository()); // default pvcs project is "/" - if(getPvcsproject() == null && getPvcsprojects().isEmpty()) + if(getPvcsproject() == null && getPvcsprojects().isEmpty()) { pvcsProject = "/"; + } - if(getPvcsproject()!=null) + if(getPvcsproject()!=null) { commandLine.createArgument().setValue(getPvcsproject()); + } if(!getPvcsprojects().isEmpty()) { Enumeration e = getPvcsprojects().elements(); while (e.hasMoreElements()) { String projectName = ((PvcsProject)e.nextElement()).getName(); - if (projectName == null || (projectName.trim()).equals("")) + if (projectName == null || (projectName.trim()).equals("")) { throw new BuildException("name is a required attribute of pvcsproject"); + } commandLine.createArgument().setValue(projectName); } } @@ -204,8 +211,9 @@ public class Pvcs extends org.apache.tools.ant.Task { throw new BuildException(msg, location); } - if(!tmp.exists()) + if(!tmp.exists()) { throw new BuildException("Communication between ant and pvcs failed. No output generated from executing PVCS commandline interface \"pcli\" and \"get\""); + } // Create folders in workspace log("Creating folders", Project.MSG_INFO); @@ -218,16 +226,18 @@ public class Pvcs extends org.apache.tools.ant.Task { commandLine.clearArgs(); commandLine.setExecutable(getExecutable(GET_EXE)); - if(getForce()!=null && getForce().equals("yes")) + if(getForce()!=null && getForce().equals("yes")) { commandLine.createArgument().setValue("-Y"); - else + } else { commandLine.createArgument().setValue("-N"); + } - if(getPromotiongroup()!=null) + if(getPromotiongroup()!=null) { commandLine.createArgument().setValue("-G"+getPromotiongroup()); - else { - if(getLabel()!=null) + } else { + if(getLabel()!=null) { commandLine.createArgument().setValue("-r"+getLabel()); + } } if (updateOnly) { @@ -419,10 +429,11 @@ public class Pvcs extends org.apache.tools.ant.Task { * @param repo String (yes/no) */ public void setForce(String f) { - if(f!=null && f.equalsIgnoreCase("yes")) + if(f!=null && f.equalsIgnoreCase("yes")) { force="yes"; - else + } else { force = "no"; + } } /** diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java index 7cb5fe74d..fe998ed1e 100644 --- a/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -94,7 +94,9 @@ public class CommandlineJava implements Cloneable { public String[] getVariables() throws BuildException { String props[] = super.getVariables(); - if (props == null) return null; + if (props == null) { + return null; + } for (int i = 0; i < props.length; i++) { props[i] = "-D" + props[i]; @@ -121,8 +123,9 @@ public class CommandlineJava implements Cloneable { } public void restoreSystem() throws BuildException { - if (sys == null) + if (sys == null) { throw new BuildException("Unbalanced nesting of SysProperties"); + } try { System.setProperties(sys); diff --git a/src/main/org/apache/tools/ant/types/FileSet.java b/src/main/org/apache/tools/ant/types/FileSet.java index dc44d820b..6d0e68c2f 100644 --- a/src/main/org/apache/tools/ant/types/FileSet.java +++ b/src/main/org/apache/tools/ant/types/FileSet.java @@ -300,7 +300,9 @@ public class FileSet extends DataType implements Cloneable { ds.setIncludes(defaultPatterns.getIncludePatterns(p)); ds.setExcludes(defaultPatterns.getExcludePatterns(p)); - if (useDefaultExcludes) ds.addDefaultExcludes(); + if (useDefaultExcludes) { + ds.addDefaultExcludes(); + } ds.setCaseSensitive(isCaseSensitive); } diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java index 79e10a56a..2f1cda03a 100644 --- a/src/main/org/apache/tools/ant/types/Path.java +++ b/src/main/org/apache/tools/ant/types/Path.java @@ -215,7 +215,9 @@ public class Path extends DataType implements Cloneable { * Append the contents of the other Path instance to this. */ public void append(Path other) { - if (other == null) return; + if (other == null) { + return; + } String[] l = other.list(); for (int i=0; i>> 31); @@ -274,8 +277,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { private void complete() { storedCombinedCRC = bsGetInt32(); - if (storedCombinedCRC != computedCombinedCRC) + if (storedCombinedCRC != computedCombinedCRC) { crcError(); + } bsFinishedWithStream(); streamEnd = true; @@ -357,23 +361,29 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { int pp, i, j, vec; pp = 0; - for(i = minLen; i <= maxLen; i++) - for(j = 0; j < alphaSize; j++) + for(i = minLen; i <= maxLen; i++) { + for(j = 0; j < alphaSize; j++) { if (length[j] == i) { perm[pp] = j; pp++; - }; + } + } + }; - for(i = 0; i < MAX_CODE_LEN; i++) + for(i = 0; i < MAX_CODE_LEN; i++) { base[i] = 0; - for(i = 0; i < alphaSize; i++) + } + for(i = 0; i < alphaSize; i++) { base[length[i]+1]++; + } - for(i = 1; i < MAX_CODE_LEN; i++) + for(i = 1; i < MAX_CODE_LEN; i++) { base[i] += base[i-1]; + } - for (i = 0; i < MAX_CODE_LEN; i++) + for (i = 0; i < MAX_CODE_LEN; i++) { limit[i] = 0; + } vec = 0; for (i = minLen; i <= maxLen; i++) { @@ -381,8 +391,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { limit[i] = vec-1; vec <<= 1; } - for (i = minLen + 1; i <= maxLen; i++) + for (i = minLen + 1; i <= maxLen; i++) { base[i] = ((limit[i-1] + 1) << 1) - base[i]; + } } private void recvDecodingTables() { @@ -392,20 +403,27 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { boolean inUse16[] = new boolean[16]; /* Receive the mapping table */ - for (i = 0; i < 16; i++) - if (bsR(1) == 1) + for (i = 0; i < 16; i++) { + if (bsR(1) == 1) { inUse16[i] = true; - else + } else { inUse16[i] = false; + } + } - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { inUse[i] = false; + } - for (i = 0; i < 16; i++) - if (inUse16[i]) - for (j = 0; j < 16; j++) - if (bsR(1) == 1) + for (i = 0; i < 16; i++) { + if (inUse16[i]) { + for (j = 0; j < 16; j++) { + if (bsR(1) == 1) { inUse[i * 16 + j] = true; + } + } + } + } makeMaps(); alphaSize = nInUse+2; @@ -415,8 +433,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { nSelectors = bsR(15); for (i = 0; i < nSelectors; i++) { j = 0; - while (bsR(1) == 1) + while (bsR(1) == 1) { j++; + } selectorMtf[i] = (char)j; } @@ -424,8 +443,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { { char pos[] = new char[N_GROUPS]; char tmp, v; - for (v = 0; v < nGroups; v++) + for (v = 0; v < nGroups; v++) { pos[v] = v; + } for (i = 0; i < nSelectors; i++) { v = selectorMtf[i]; @@ -444,10 +464,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { int curr = bsR ( 5 ); for (i = 0; i < alphaSize; i++) { while (bsR(1) == 1) { - if (bsR(1) == 0) + if (bsR(1) == 0) { curr++; - else + } else { curr--; + } } len[t][i] = (char)curr; } @@ -458,10 +479,12 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { minLen = 32; maxLen = 0; for (i = 0; i < alphaSize; i++) { - if (len[t][i] > maxLen) + if (len[t][i] > maxLen) { maxLen = len[t][i]; - if (len[t][i] < minLen) + } + if (len[t][i] < minLen) { minLen = len[t][i]; + } } hbCreateDecodeTables(limit[t], base[t], perm[t], len[t], minLen, maxLen, alphaSize); @@ -488,11 +511,13 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { in a separate pass, and so saves a block's worth of cache misses. */ - for (i = 0; i <= 255; i++) + for (i = 0; i <= 255; i++) { unzftab[i] = 0; + } - for (i = 0; i <= 255; i++) + for (i = 0; i <= 255; i++) { yy[i] = (char) i; + } last = -1; @@ -536,18 +561,20 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { while(true) { - if (nextSym == EOB) + if (nextSym == EOB) { break; + } if (nextSym == RUNA || nextSym == RUNB) { char ch; int s = -1; int N = 1; do { - if (nextSym == RUNA) + if (nextSym == RUNA) { s = s + (0+1) * N; - else if (nextSym == RUNB) + } else if (nextSym == RUNB) { s = s + (1+1) * N; + } N = N * 2; { int zt, zn, zvec, zj; @@ -598,14 +625,16 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { s--; }; - if (last >= limitLast) + if (last >= limitLast) { blockOverrun(); + } continue; } else { char tmp; last++; - if (last >= limitLast) + if (last >= limitLast) { blockOverrun(); + } tmp = yy[nextSym-1]; unzftab[seqToUnseq[tmp]]++; @@ -625,8 +654,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { yy[j-2] = yy[j-3]; yy[j-3] = yy[j-4]; } - for (; j > 0; j--) + for (; j > 0; j--) { yy[j] = yy[j-1]; + } yy[0] = tmp; { @@ -673,10 +703,12 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { char ch; cftab[0] = 0; - for (i = 1; i <= 256; i++) + for (i = 1; i <= 256; i++) { cftab[i] = unzftab[i-1]; - for (i = 1; i <= 256; i++) + } + for (i = 1; i <= 256; i++) { cftab[i] += cftab[i-1]; + } for (i = 0; i <= last; i++) { ch = (char)ll8[i]; @@ -708,8 +740,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { if (rNToGo == 0) { rNToGo = rNums[rTPos]; rTPos++; - if(rTPos == 512) + if(rTPos == 512) { rTPos = 0; + } } rNToGo--; ch2 ^= (int)((rNToGo == 1) ? 1 : 0); @@ -755,8 +788,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { if (rNToGo == 0) { rNToGo = rNums[rTPos]; rTPos++; - if(rTPos == 512) + if(rTPos == 512) { rTPos = 0; + } } rNToGo--; z ^= ((rNToGo == 1) ? 1 : 0); @@ -824,8 +858,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { blockSize100k = newSize100k; - if(newSize100k == 0) + if(newSize100k == 0) { return; + } int n = baseBlockSize * newSize100k; ll8 = new char[n]; diff --git a/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java b/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java index 9d9769248..2d510ae4d 100644 --- a/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java +++ b/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java @@ -678,10 +678,11 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { fave[t] = 0; } - for (t = 0; t < nGroups; t++) + for (t = 0; t < nGroups; t++) { for (v = 0; v < alphaSize; v++) { rfreq[t][v] = 0; } + } nSelectors = 0; totc = 0; @@ -771,8 +772,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { fave = null; cost = null; - if (!(nGroups < 8)) + if (!(nGroups < 8)) { panic(); + } if (!(nSelectors < 32768 && nSelectors <= (2 + (900000 / G_SIZE)))) { panic(); } @@ -1192,8 +1194,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { simpleSort ( 0, last, 0 ); } else { numQSorted = 0; - for (i = 0; i <= 255; i++) + for (i = 0; i <= 255; i++) { bigDone[i] = false; + } for (i = 0; i <= 65536; i++) { ftab[i] = 0;