then/else parts of if statement and loop body must always been enclosed in a block statement. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270637 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -264,8 +264,9 @@ public class Main { | |||||
| if (posEq > 0) { | if (posEq > 0) { | ||||
| value = name.substring(posEq+1); | value = name.substring(posEq+1); | ||||
| name = name.substring(0, posEq); | name = name.substring(0, posEq); | ||||
| } else if (i < args.length-1) | |||||
| } else if (i < args.length-1) { | |||||
| value = args[++i]; | value = args[++i]; | ||||
| } | |||||
| definedProps.put(name, value); | definedProps.put(name, value); | ||||
| } else if (arg.equals("-logger")) { | } else if (arg.equals("-logger")) { | ||||
| @@ -366,7 +366,9 @@ public class Project { | |||||
| * @return the property value, or null for no match | * @return the property value, or null for no match | ||||
| */ | */ | ||||
| public String getProperty(String name) { | public String getProperty(String name) { | ||||
| if (name == null) return null; | |||||
| if (name == null) { | |||||
| return null; | |||||
| } | |||||
| String property = (String) properties.get(name); | String property = (String) properties.get(name); | ||||
| return property; | return property; | ||||
| } | } | ||||
| @@ -388,7 +390,9 @@ public class Project { | |||||
| * @return the property value, or null for no match | * @return the property value, or null for no match | ||||
| */ | */ | ||||
| public String getUserProperty(String name) { | public String getUserProperty(String name) { | ||||
| if (name == null) return null; | |||||
| if (name == null) { | |||||
| return null; | |||||
| } | |||||
| String property = (String) userProperties.get(name); | String property = (String) userProperties.get(name); | ||||
| return property; | return property; | ||||
| } | } | ||||
| @@ -516,10 +520,12 @@ public class Project { | |||||
| */ | */ | ||||
| public void setBaseDir(File baseDir) throws BuildException { | public void setBaseDir(File baseDir) throws BuildException { | ||||
| baseDir = fileUtils.normalize(baseDir.getAbsolutePath()); | baseDir = fileUtils.normalize(baseDir.getAbsolutePath()); | ||||
| if (!baseDir.exists()) | |||||
| if (!baseDir.exists()) { | |||||
| throw new BuildException("Basedir " + baseDir.getAbsolutePath() + " does not exist"); | 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"); | throw new BuildException("Basedir " + baseDir.getAbsolutePath() + " is not a directory"); | ||||
| } | |||||
| this.baseDir = baseDir; | this.baseDir = baseDir; | ||||
| setPropertyInternal( "basedir", this.baseDir.getPath()); | setPropertyInternal( "basedir", this.baseDir.getPath()); | ||||
| String msg = "Project base dir set to: " + this.baseDir; | String msg = "Project base dir set to: " + this.baseDir; | ||||
| @@ -635,8 +641,9 @@ public class Project { | |||||
| log(message, Project.MSG_ERR); | log(message, Project.MSG_ERR); | ||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| } | } | ||||
| if( !Task.class.isAssignableFrom(taskClass) ) | |||||
| if( !Task.class.isAssignableFrom(taskClass) ) { | |||||
| TaskAdapter.checkTaskClass(taskClass, this); | TaskAdapter.checkTaskClass(taskClass, this); | ||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -815,8 +822,9 @@ public class Project { | |||||
| public Object createDataType(String typeName) throws BuildException { | public Object createDataType(String typeName) throws BuildException { | ||||
| Class c = (Class) dataClassDefinitions.get(typeName); | Class c = (Class) dataClassDefinitions.get(typeName); | ||||
| if (c == null) | |||||
| if (c == null) { | |||||
| return null; | return null; | ||||
| } | |||||
| try { | try { | ||||
| java.lang.reflect.Constructor ctor = null; | java.lang.reflect.Constructor ctor = null; | ||||
| @@ -266,11 +266,12 @@ public class Delete extends MatchingTask { | |||||
| if (!file.delete()) { | if (!file.delete()) { | ||||
| String message="Unable to delete file " + file.getAbsolutePath(); | String message="Unable to delete file " + file.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else { | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -337,7 +338,9 @@ public class Delete extends MatchingTask { | |||||
| protected void removeDir(File d) { | protected void removeDir(File d) { | ||||
| String[] list = d.list(); | 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++) { | for (int i = 0; i < list.length; i++) { | ||||
| String s = list[i]; | String s = list[i]; | ||||
| File f = new File(d, s); | File f = new File(d, s); | ||||
| @@ -347,22 +350,24 @@ public class Delete extends MatchingTask { | |||||
| log("Deleting " + f.getAbsolutePath(), verbosity); | log("Deleting " + f.getAbsolutePath(), verbosity); | ||||
| if (!f.delete()) { | if (!f.delete()) { | ||||
| String message="Unable to delete file " + f.getAbsolutePath(); | String message="Unable to delete file " + f.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else { | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| log("Deleting directory " + d.getAbsolutePath(), verbosity); | log("Deleting directory " + d.getAbsolutePath(), verbosity); | ||||
| if (!d.delete()) { | if (!d.delete()) { | ||||
| String message="Unable to delete directory " + dir.getAbsolutePath(); | String message="Unable to delete directory " + dir.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else { | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -381,11 +386,12 @@ public class Delete extends MatchingTask { | |||||
| log("Deleting " + f.getAbsolutePath(), verbosity); | log("Deleting " + f.getAbsolutePath(), verbosity); | ||||
| if (!f.delete()) { | if (!f.delete()) { | ||||
| String message="Unable to delete file " + f.getAbsolutePath(); | String message="Unable to delete file " + f.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else { | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -400,11 +406,12 @@ public class Delete extends MatchingTask { | |||||
| if (!dir.delete()) { | if (!dir.delete()) { | ||||
| String message="Unable to delete directory " | String message="Unable to delete directory " | ||||
| + dir.getAbsolutePath(); | + dir.getAbsolutePath(); | ||||
| if(failonerror) | |||||
| if(failonerror) { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| else | |||||
| } else { | |||||
| log(message, | log(message, | ||||
| quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | quiet ? Project.MSG_VERBOSE : Project.MSG_WARN); | ||||
| } | |||||
| } else { | } else { | ||||
| dirCount++; | dirCount++; | ||||
| } | } | ||||
| @@ -92,8 +92,9 @@ public class Ear extends Jar { | |||||
| */ | */ | ||||
| public void setAppxml(File descr) { | public void setAppxml(File descr) { | ||||
| deploymentDescriptor = descr; | deploymentDescriptor = descr; | ||||
| if (!deploymentDescriptor.exists()) | |||||
| if (!deploymentDescriptor.exists()) { | |||||
| throw new BuildException("Deployment descriptor: " + deploymentDescriptor + " does not exist."); | throw new BuildException("Deployment descriptor: " + deploymentDescriptor + " does not exist."); | ||||
| } | |||||
| // Create a ZipFileSet for this file, and pass it up. | // Create a ZipFileSet for this file, and pass it up. | ||||
| ZipFileSet fs = new ZipFileSet(); | ZipFileSet fs = new ZipFileSet(); | ||||
| @@ -259,7 +259,9 @@ public class ExecTask extends Task { | |||||
| */ | */ | ||||
| protected Execute prepareExec() throws BuildException { | protected Execute prepareExec() throws BuildException { | ||||
| // default directory to the project's base directory | // default directory to the project's base directory | ||||
| if (dir == null) dir = project.getBaseDir(); | |||||
| if (dir == null) { | |||||
| dir = project.getBaseDir(); | |||||
| } | |||||
| // show the command | // show the command | ||||
| log(cmdl.toString(), Project.MSG_VERBOSE); | log(cmdl.toString(), Project.MSG_VERBOSE); | ||||
| @@ -360,7 +362,9 @@ public class ExecTask extends Task { | |||||
| * Create the Watchdog to kill a runaway process. | * Create the Watchdog to kill a runaway process. | ||||
| */ | */ | ||||
| protected ExecuteWatchdog createWatchdog() throws BuildException { | protected ExecuteWatchdog createWatchdog() throws BuildException { | ||||
| if (timeout == null) return null; | |||||
| if (timeout == null) { | |||||
| return null; | |||||
| } | |||||
| return new ExecuteWatchdog(timeout.intValue()); | return new ExecuteWatchdog(timeout.intValue()); | ||||
| } | } | ||||
| @@ -369,8 +373,12 @@ public class ExecTask extends Task { | |||||
| */ | */ | ||||
| protected void logFlush() { | protected void logFlush() { | ||||
| try { | try { | ||||
| if (fos != null) fos.close(); | |||||
| if (baos != null) baos.close(); | |||||
| if (fos != null) { | |||||
| fos.close(); | |||||
| } | |||||
| if (baos != null) { | |||||
| baos.close(); | |||||
| } | |||||
| } catch (IOException io) {} | } catch (IOException io) {} | ||||
| } | } | ||||
| @@ -172,7 +172,9 @@ public class Execute { | |||||
| * Find the list of environment variables for this process. | * Find the list of environment variables for this process. | ||||
| */ | */ | ||||
| public static synchronized Vector getProcEnvironment() { | public static synchronized Vector getProcEnvironment() { | ||||
| if (procEnvironment != null) return procEnvironment; | |||||
| if (procEnvironment != null) { | |||||
| return procEnvironment; | |||||
| } | |||||
| procEnvironment = new Vector(); | procEnvironment = new Vector(); | ||||
| try { | try { | ||||
| @@ -326,7 +328,9 @@ public class Execute { | |||||
| * @return the environment used to create a subprocess | * @return the environment used to create a subprocess | ||||
| */ | */ | ||||
| public String[] getEnvironment() { | public String[] getEnvironment() { | ||||
| if (env == null || newEnvironment) return env; | |||||
| if (env == null || newEnvironment) { | |||||
| return env; | |||||
| } | |||||
| return patchEnvironment(); | return patchEnvironment(); | ||||
| } | } | ||||
| @@ -352,10 +356,11 @@ public class Execute { | |||||
| * @param wd the working directory of the process. | * @param wd the working directory of the process. | ||||
| */ | */ | ||||
| public void setWorkingDirectory(File wd) { | public void setWorkingDirectory(File wd) { | ||||
| if (wd == null || wd.getAbsolutePath().equals(antWorkingDirectory)) | |||||
| if (wd == null || wd.getAbsolutePath().equals(antWorkingDirectory)) { | |||||
| workingDirectory = null; | workingDirectory = null; | ||||
| else | |||||
| } else { | |||||
| workingDirectory = wd; | workingDirectory = wd; | ||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -408,16 +413,22 @@ public class Execute { | |||||
| // | // | ||||
| processDestroyer.add(process); | processDestroyer.add(process); | ||||
| if (watchdog != null) watchdog.start(process); | |||||
| if (watchdog != null) { | |||||
| watchdog.start(process); | |||||
| } | |||||
| waitFor(process); | waitFor(process); | ||||
| // remove the process to the list of those to destroy if the VM exits | // remove the process to the list of those to destroy if the VM exits | ||||
| // | // | ||||
| processDestroyer.remove(process); | processDestroyer.remove(process); | ||||
| if (watchdog != null) watchdog.stop(); | |||||
| if (watchdog != null) { | |||||
| watchdog.stop(); | |||||
| } | |||||
| streamHandler.stop(); | streamHandler.stop(); | ||||
| if (watchdog != null) watchdog.checkException(); | |||||
| if (watchdog != null) { | |||||
| watchdog.checkException(); | |||||
| } | |||||
| return getExitValue(); | return getExitValue(); | ||||
| } | } | ||||
| @@ -128,7 +128,9 @@ public class GenerateKey extends Task { | |||||
| public String encode( final String string ) { | public String encode( final String string ) { | ||||
| int end = string.indexOf(','); | int end = string.indexOf(','); | ||||
| if( -1 == end ) return string; | |||||
| if( -1 == end ) { | |||||
| return string; | |||||
| } | |||||
| final StringBuffer sb = new StringBuffer(); | final StringBuffer sb = new StringBuffer(); | ||||
| @@ -751,10 +751,11 @@ public class Javadoc extends Task { | |||||
| toExecute.setExecutable( getJavadocExecutableName() ); | toExecute.setExecutable( getJavadocExecutableName() ); | ||||
| // ------------------------------------------------ general javadoc arguments | // ------------------------------------------------ general javadoc arguments | ||||
| if (classpath == null) | |||||
| if (classpath == null) { | |||||
| classpath = Path.systemClasspath; | classpath = Path.systemClasspath; | ||||
| else | |||||
| } else { | |||||
| classpath = classpath.concatSystemClasspath("ignore"); | classpath = classpath.concatSystemClasspath("ignore"); | ||||
| } | |||||
| if (!javadoc1) { | if (!javadoc1) { | ||||
| toExecute.createArgument().setValue("-classpath"); | toExecute.createArgument().setValue("-classpath"); | ||||
| @@ -767,10 +768,12 @@ public class Javadoc extends Task { | |||||
| System.getProperty("path.separator") + classpath.toString()); | System.getProperty("path.separator") + classpath.toString()); | ||||
| } | } | ||||
| if (version && doclet == null) | |||||
| if (version && doclet == null) { | |||||
| toExecute.createArgument().setValue("-version"); | toExecute.createArgument().setValue("-version"); | ||||
| if (author && doclet == null) | |||||
| } | |||||
| if (author && doclet == null) { | |||||
| toExecute.createArgument().setValue("-author"); | toExecute.createArgument().setValue("-author"); | ||||
| } | |||||
| if (javadoc1 || doclet == null) { | if (javadoc1 || doclet == null) { | ||||
| if (destDir == null) { | if (destDir == null) { | ||||
| @@ -1027,7 +1030,9 @@ public class Javadoc extends Task { | |||||
| Vector addedPackages = new Vector(); | Vector addedPackages = new Vector(); | ||||
| String[] list = sourcePath.list(); | String[] list = sourcePath.list(); | ||||
| if (list == null) list = new String[0]; | |||||
| if (list == null) { | |||||
| list = new String[0]; | |||||
| } | |||||
| FileSet fs = new FileSet(); | FileSet fs = new FileSet(); | ||||
| fs.setDefaultexcludes(useDefaultExcludes); | fs.setDefaultexcludes(useDefaultExcludes); | ||||
| @@ -1123,10 +1128,11 @@ public class Javadoc extends Task { | |||||
| queuedLine = line; | queuedLine = line; | ||||
| } else { | } else { | ||||
| if (queuedLine != null) { | if (queuedLine != null) { | ||||
| if (line.startsWith("Building ")) | |||||
| if (line.startsWith("Building ")) { | |||||
| super.processLine(queuedLine, Project.MSG_VERBOSE); | super.processLine(queuedLine, Project.MSG_VERBOSE); | ||||
| else | |||||
| } else { | |||||
| super.processLine(queuedLine, Project.MSG_INFO); | super.processLine(queuedLine, Project.MSG_INFO); | ||||
| } | |||||
| queuedLine = null; | queuedLine = null; | ||||
| } | } | ||||
| super.processLine(line, messageLevel); | super.processLine(line, messageLevel); | ||||
| @@ -125,10 +125,11 @@ public class JikesOutputParser implements ExecuteStreamHandler { | |||||
| * @param reader - Reader used to read jikes's output | * @param reader - Reader used to read jikes's output | ||||
| */ | */ | ||||
| protected void parseOutput(BufferedReader reader) throws IOException { | protected void parseOutput(BufferedReader reader) throws IOException { | ||||
| if (emacsMode) | |||||
| if (emacsMode) { | |||||
| parseEmacsOutput(reader); | parseEmacsOutput(reader); | ||||
| else | |||||
| } else { | |||||
| parseStandardOutput(reader); | parseStandardOutput(reader); | ||||
| } | |||||
| } | } | ||||
| private void parseStandardOutput(BufferedReader reader) throws IOException { | private void parseStandardOutput(BufferedReader reader) throws IOException { | ||||
| @@ -145,21 +146,23 @@ public class JikesOutputParser implements ExecuteStreamHandler { | |||||
| while ((line = reader.readLine()) != null) { | while ((line = reader.readLine()) != null) { | ||||
| lower = line.toLowerCase(); | lower = line.toLowerCase(); | ||||
| if (line.trim().equals("")) | |||||
| if (line.trim().equals("")) { | |||||
| continue; | continue; | ||||
| if (lower.indexOf("error") != -1) | |||||
| } | |||||
| if (lower.indexOf("error") != -1) { | |||||
| setError(true); | setError(true); | ||||
| else if (lower.indexOf("warning") != -1) | |||||
| } else if (lower.indexOf("warning") != -1) { | |||||
| setError(false); | setError(false); | ||||
| else { | |||||
| } else { | |||||
| // If we don't know the type of the line | // If we don't know the type of the line | ||||
| // and we are in emacs mode, it will be | // and we are in emacs mode, it will be | ||||
| // an error, because in this mode, jikes won't | // an error, because in this mode, jikes won't | ||||
| // always print "error", but sometimes other | // always print "error", but sometimes other | ||||
| // keywords like "Syntax". We should look for | // keywords like "Syntax". We should look for | ||||
| // all those keywords. | // all those keywords. | ||||
| if (emacsMode) | |||||
| if (emacsMode) { | |||||
| setError(true); | setError(true); | ||||
| } | |||||
| } | } | ||||
| log(line); | log(line); | ||||
| } | } | ||||
| @@ -172,8 +175,9 @@ public class JikesOutputParser implements ExecuteStreamHandler { | |||||
| private void setError(boolean err) { | private void setError(boolean err) { | ||||
| error = err; | error = err; | ||||
| if(error) | |||||
| if(error) { | |||||
| errorFlag = true; | errorFlag = true; | ||||
| } | |||||
| } | } | ||||
| private void log(String line) { | private void log(String line) { | ||||
| @@ -100,8 +100,12 @@ public class LogOutputStream extends OutputStream { | |||||
| public void write(int cc) throws IOException { | public void write(int cc) throws IOException { | ||||
| final byte c = (byte)cc; | final byte c = (byte)cc; | ||||
| if ((c == '\n') || (c == '\r')) { | if ((c == '\n') || (c == '\r')) { | ||||
| if (!skip) processBuffer(); | |||||
| } else buffer.write(cc); | |||||
| if (!skip) { | |||||
| processBuffer(); | |||||
| } | |||||
| } else { | |||||
| buffer.write(cc); | |||||
| } | |||||
| skip = (c == '\r'); | skip = (c == '\r'); | ||||
| } | } | ||||
| @@ -137,7 +141,9 @@ public class LogOutputStream extends OutputStream { | |||||
| * Writes all remaining | * Writes all remaining | ||||
| */ | */ | ||||
| public void close() throws IOException { | public void close() throws IOException { | ||||
| if (buffer.size() > 0) processBuffer(); | |||||
| if (buffer.size() > 0) { | |||||
| processBuffer(); | |||||
| } | |||||
| super.close(); | super.close(); | ||||
| } | } | ||||
| @@ -211,13 +211,17 @@ public class Move extends Copy { | |||||
| */ | */ | ||||
| protected boolean okToDelete(File d) { | protected boolean okToDelete(File d) { | ||||
| String[] list = d.list(); | 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++) { | for (int i = 0; i < list.length; i++) { | ||||
| String s = list[i]; | String s = list[i]; | ||||
| File f = new File(d, s); | File f = new File(d, s); | ||||
| if (f.isDirectory()) { | if (f.isDirectory()) { | ||||
| if (!okToDelete(f)) return false; | |||||
| if (!okToDelete(f)) { | |||||
| return false; | |||||
| } | |||||
| } else { | } else { | ||||
| return false; // found a file | return false; // found a file | ||||
| } | } | ||||
| @@ -231,7 +235,9 @@ public class Move extends Copy { | |||||
| */ | */ | ||||
| protected void deleteDir(File d) { | protected void deleteDir(File d) { | ||||
| String[] list = d.list(); | 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++) { | for (int i = 0; i < list.length; i++) { | ||||
| String s = list[i]; | String s = list[i]; | ||||
| @@ -137,8 +137,9 @@ public class PathConvert extends Task { | |||||
| */ | */ | ||||
| public Path createPath() { | public Path createPath() { | ||||
| if( isReference() ) | |||||
| if( isReference() ) { | |||||
| throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
| } | |||||
| if( path == null ) { | if( path == null ) { | ||||
| path = new Path(getProject()); | path = new Path(getProject()); | ||||
| @@ -190,8 +191,9 @@ public class PathConvert extends Task { | |||||
| * Adds a reference to a PATH or FILESET defined elsewhere. | * Adds a reference to a PATH or FILESET defined elsewhere. | ||||
| */ | */ | ||||
| public void setRefid(Reference r) { | public void setRefid(Reference r) { | ||||
| if( path != null ) | |||||
| if( path != null ) { | |||||
| throw noChildrenAllowed(); | throw noChildrenAllowed(); | ||||
| } | |||||
| refid = r; | refid = r; | ||||
| } | } | ||||
| @@ -271,7 +273,9 @@ public class PathConvert extends Task { | |||||
| elem = elem.replace( fromDirSep, toDirSep ); | elem = elem.replace( fromDirSep, toDirSep ); | ||||
| if( i != 0 ) rslt.append( pathSep ); | |||||
| if( i != 0 ) { | |||||
| rslt.append( pathSep ); | |||||
| } | |||||
| rslt.append( elem ); | rslt.append( elem ); | ||||
| } | } | ||||
| @@ -323,16 +327,19 @@ public class PathConvert extends Task { | |||||
| */ | */ | ||||
| private void validateSetup() throws BuildException { | private void validateSetup() throws BuildException { | ||||
| if( path == null ) | |||||
| if( path == null ) { | |||||
| throw new BuildException( "You must specify a path to convert" ); | throw new BuildException( "You must specify a path to convert" ); | ||||
| } | |||||
| if( property == null ) | |||||
| if( property == null ) { | |||||
| throw new BuildException( "You must specify a property" ); | throw new BuildException( "You must specify a property" ); | ||||
| } | |||||
| // Must either have a target OS or both a dirSep and pathSep | // 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" ); | throw new BuildException( "You must specify at least one of targetOS, dirSep, or pathSep" ); | ||||
| } | |||||
| // Determine the separator strings. The dirsep and pathsep attributes | // Determine the separator strings. The dirsep and pathsep attributes | ||||
| // override the targetOS settings. | // override the targetOS settings. | ||||
| @@ -197,11 +197,17 @@ public class Property extends Task { | |||||
| addProperty(name, value); | 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)) { | if ((name != null) && (ref != null)) { | ||||
| Object obj = ref.getReferencedObject(getProject()); | Object obj = ref.getReferencedObject(getProject()); | ||||
| @@ -266,7 +272,9 @@ public class Property extends Task { | |||||
| protected void loadEnvironment( String prefix ) { | protected void loadEnvironment( String prefix ) { | ||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| if (!prefix.endsWith(".")) prefix += "."; | |||||
| if (!prefix.endsWith(".")) { | |||||
| prefix += "."; | |||||
| } | |||||
| log("Loading Environment " + prefix, Project.MSG_VERBOSE); | log("Loading Environment " + prefix, Project.MSG_VERBOSE); | ||||
| Vector osEnv = Execute.getProcEnvironment(); | Vector osEnv = Execute.getProcEnvironment(); | ||||
| for (Enumeration e = osEnv.elements(); e.hasMoreElements(); ) { | for (Enumeration e = osEnv.elements(); e.hasMoreElements(); ) { | ||||
| @@ -157,8 +157,9 @@ public class Recorder extends Task { | |||||
| * The main execution. | * The main execution. | ||||
| */ | */ | ||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| if ( filename == null ) | |||||
| if ( filename == null ) { | |||||
| throw new BuildException( "No filename specified" ); | throw new BuildException( "No filename specified" ); | ||||
| } | |||||
| getProject().log( "setting a recorder for name " + filename, | getProject().log( "setting a recorder for name " + filename, | ||||
| Project.MSG_DEBUG ); | Project.MSG_DEBUG ); | ||||
| @@ -121,8 +121,9 @@ public class RecorderEntry implements BuildLogger { | |||||
| * @param state true for on, false for off, null for no change. | * @param state true for on, false for off, null for no change. | ||||
| */ | */ | ||||
| public void setRecordState( Boolean state ) { | public void setRecordState( Boolean state ) { | ||||
| if ( state != null ) | |||||
| if ( state != null ) { | |||||
| record = state.booleanValue(); | record = state.booleanValue(); | ||||
| } | |||||
| } | } | ||||
| public void buildStarted(BuildEvent event) { | public void buildStarted(BuildEvent event) { | ||||
| @@ -194,8 +195,9 @@ public class RecorderEntry implements BuildLogger { | |||||
| } | } | ||||
| public void setMessageOutputLevel(int level) { | 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; | loglevel = level; | ||||
| } | |||||
| } | } | ||||
| public void setOutputPrintStream(PrintStream output) { | public void setOutputPrintStream(PrintStream output) { | ||||
| @@ -122,8 +122,9 @@ public class Jikes extends DefaultCompilerAdapter { | |||||
| Commandline cmd = new Commandline(); | Commandline cmd = new Commandline(); | ||||
| cmd.setExecutable("jikes"); | cmd.setExecutable("jikes"); | ||||
| if (deprecation == true) | |||||
| if (deprecation == true) { | |||||
| cmd.createArgument().setValue("-deprecation"); | cmd.createArgument().setValue("-deprecation"); | ||||
| } | |||||
| if (destDir != null) { | if (destDir != null) { | ||||
| cmd.createArgument().setValue("-d"); | cmd.createArgument().setValue("-d"); | ||||
| @@ -53,8 +53,9 @@ public class ManifestFile extends Task { | |||||
| */ | */ | ||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| checkParameters(); | checkParameters(); | ||||
| if (isUpdate(currentMethod)) | |||||
| if (isUpdate(currentMethod)) { | |||||
| readFile(); | readFile(); | ||||
| } | |||||
| executeOperation(); | executeOperation(); | ||||
| writeFile(); | writeFile(); | ||||
| @@ -184,8 +185,9 @@ public class ManifestFile extends Task { | |||||
| c = fis.read(); | c = fis.read(); | ||||
| if (c == -1){ | if (c == -1){ | ||||
| stop =true; | stop =true; | ||||
| } else | |||||
| } else { | |||||
| buffer.append( (char) c); | buffer.append( (char) c); | ||||
| } | |||||
| } | } | ||||
| fis.close(); | fis.close(); | ||||
| StringTokenizer lineTokens = getLineTokens (buffer); | StringTokenizer lineTokens = getLineTokens (buffer); | ||||
| @@ -312,8 +314,9 @@ public class ManifestFile extends Task { | |||||
| Entry ent = new Entry(); | Entry ent = new Entry(); | ||||
| boolean result = false; | boolean result = false; | ||||
| int res = ent.compare (this,(Entry) obj ); | int res = ent.compare (this,(Entry) obj ); | ||||
| if (res==0) | |||||
| if (res==0) { | |||||
| result =true; | result =true; | ||||
| } | |||||
| return result; | return result; | ||||
| } | } | ||||
| @@ -197,7 +197,9 @@ public class NetRexxC extends MatchingTask { | |||||
| */ | */ | ||||
| public void setCompile(boolean compile) { | public void setCompile(boolean compile) { | ||||
| this.compile = compile; | this.compile = compile; | ||||
| if (!this.compile && !this.keep) this.keep = true; | |||||
| if (!this.compile && !this.keep) { | |||||
| this.keep = true; | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -420,7 +420,9 @@ public class PropertyFile extends Task | |||||
| GregorianCalendar value = new GregorianCalendar(); | GregorianCalendar value = new GregorianCalendar(); | ||||
| GregorianCalendar newValue = 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); | DateFormat fmt = new SimpleDateFormat(m_pattern); | ||||
| // special case | // special case | ||||
| @@ -180,8 +180,9 @@ public class ReplaceRegExp extends Task | |||||
| public void setMatch(String match) | public void setMatch(String match) | ||||
| { | { | ||||
| if (regex != null) | |||||
| if (regex != null) { | |||||
| throw new BuildException("Only one regular expression is allowed"); | throw new BuildException("Only one regular expression is allowed"); | ||||
| } | |||||
| regex = new RegularExpression(); | regex = new RegularExpression(); | ||||
| regex.setPattern(match); | regex.setPattern(match); | ||||
| @@ -189,8 +190,9 @@ public class ReplaceRegExp extends Task | |||||
| public void setReplace(String replace) | public void setReplace(String replace) | ||||
| { | { | ||||
| if (subs != null) | |||||
| if (subs != null) { | |||||
| throw new BuildException("Only one substitution expression is allowed"); | throw new BuildException("Only one substitution expression is allowed"); | ||||
| } | |||||
| subs = new Substitution(); | subs = new Substitution(); | ||||
| subs.setExpression(replace); | subs.setExpression(replace); | ||||
| @@ -204,8 +206,9 @@ public class ReplaceRegExp extends Task | |||||
| public void setByLine(String byline) | public void setByLine(String byline) | ||||
| { | { | ||||
| Boolean res = Boolean.valueOf(byline); | Boolean res = Boolean.valueOf(byline); | ||||
| if (res == null) | |||||
| if (res == null) { | |||||
| res = Boolean.FALSE; | res = Boolean.FALSE; | ||||
| } | |||||
| this.byline = res.booleanValue(); | this.byline = res.booleanValue(); | ||||
| } | } | ||||
| @@ -216,8 +219,9 @@ public class ReplaceRegExp extends Task | |||||
| public RegularExpression createRegularExpression() | public RegularExpression createRegularExpression() | ||||
| { | { | ||||
| if (regex != null) | |||||
| if (regex != null) { | |||||
| throw new BuildException("Only one regular expression is allowed."); | throw new BuildException("Only one regular expression is allowed."); | ||||
| } | |||||
| regex = new RegularExpression(); | regex = new RegularExpression(); | ||||
| return regex; | return regex; | ||||
| @@ -225,8 +229,9 @@ public class ReplaceRegExp extends Task | |||||
| public Substitution createSubstitution() | public Substitution createSubstitution() | ||||
| { | { | ||||
| if (subs != null) | |||||
| if (subs != null) { | |||||
| throw new BuildException("Only one substitution expression is allowed"); | throw new BuildException("Only one substitution expression is allowed"); | ||||
| } | |||||
| subs = new Substitution(); | subs = new Substitution(); | ||||
| return subs; | return subs; | ||||
| @@ -287,8 +292,9 @@ public class ReplaceRegExp extends Task | |||||
| while ((line = lnr.readLine()) != null) | while ((line = lnr.readLine()) != null) | ||||
| { | { | ||||
| String res = doReplace(regex, subs, line, options); | String res = doReplace(regex, subs, line, options); | ||||
| if (! res.equals(line)) | |||||
| if (! res.equals(line)) { | |||||
| changes = true; | changes = true; | ||||
| } | |||||
| pw.println(res); | pw.println(res); | ||||
| } | } | ||||
| @@ -309,8 +315,9 @@ public class ReplaceRegExp extends Task | |||||
| String buf = new String(tmpBuf); | String buf = new String(tmpBuf); | ||||
| String res = doReplace(regex, subs, buf, options); | String res = doReplace(regex, subs, buf, options); | ||||
| if (! res.equals(buf)) | |||||
| if (! res.equals(buf)) { | |||||
| changes = true; | changes = true; | ||||
| } | |||||
| pw.println(res); | pw.println(res); | ||||
| pw.flush(); | pw.flush(); | ||||
| @@ -333,10 +340,14 @@ public class ReplaceRegExp extends Task | |||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| try { if (r != null) r.close(); } | |||||
| try { if (r != null) { | |||||
| r.close(); | |||||
| } } | |||||
| catch (Exception e) { }; | catch (Exception e) { }; | ||||
| try { if (w != null) r.close(); } | |||||
| try { if (w != null) { | |||||
| r.close(); | |||||
| } } | |||||
| catch (Exception e) { }; | catch (Exception e) { }; | ||||
| } | } | ||||
| } | } | ||||
| @@ -344,28 +355,35 @@ public class ReplaceRegExp extends Task | |||||
| public void execute() | public void execute() | ||||
| throws BuildException | throws BuildException | ||||
| { | { | ||||
| if (regex == null) | |||||
| if (regex == null) { | |||||
| throw new BuildException("No expression to match."); | throw new BuildException("No expression to match."); | ||||
| if (subs == null) | |||||
| } | |||||
| if (subs == null) { | |||||
| throw new BuildException("Nothing to replace expression with."); | 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."); | throw new BuildException("You cannot supply the 'file' attribute and filesets at the same time."); | ||||
| } | |||||
| int options = 0; | int options = 0; | ||||
| if (flags.indexOf('g') != -1) | |||||
| if (flags.indexOf('g') != -1) { | |||||
| options |= Regexp.REPLACE_ALL; | options |= Regexp.REPLACE_ALL; | ||||
| } | |||||
| if (flags.indexOf('i') != -1) | |||||
| if (flags.indexOf('i') != -1) { | |||||
| options |= Regexp.MATCH_CASE_INSENSITIVE; | options |= Regexp.MATCH_CASE_INSENSITIVE; | ||||
| } | |||||
| if (flags.indexOf('m') != -1) | |||||
| if (flags.indexOf('m') != -1) { | |||||
| options |= Regexp.MATCH_MULTILINE; | options |= Regexp.MATCH_MULTILINE; | ||||
| } | |||||
| if (flags.indexOf('s') != -1) | |||||
| if (flags.indexOf('s') != -1) { | |||||
| options |= Regexp.MATCH_SINGLELINE; | options |= Regexp.MATCH_SINGLELINE; | ||||
| } | |||||
| if (file != null && file.exists()) | if (file != null && file.exists()) | ||||
| { | { | ||||
| @@ -537,9 +537,9 @@ public class CSharp | |||||
| * @return The ExtraOptions Parameter to CSC | * @return The ExtraOptions Parameter to CSC | ||||
| */ | */ | ||||
| protected String getExtraOptionsParameter() { | protected String getExtraOptionsParameter() { | ||||
| if (_extraOptions!=null && _extraOptions.length()!=0) | |||||
| if (_extraOptions!=null && _extraOptions.length()!=0) { | |||||
| return _extraOptions; | return _extraOptions; | ||||
| else { | |||||
| } else { | |||||
| return null; | return null; | ||||
| } | } | ||||
| } | } | ||||
| @@ -777,8 +777,9 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
| Iterator i = checkEntries.keySet().iterator(); | Iterator i = checkEntries.keySet().iterator(); | ||||
| while (i.hasNext()) { | while (i.hasNext()) { | ||||
| String entryName = (String)i.next(); | 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, '/')); | newSet.add(entryName.substring(0, entryName.length() - ".class".length()).replace(File.separatorChar, '/')); | ||||
| } | |||||
| } | } | ||||
| set.addAll(newSet); | set.addAll(newSet); | ||||
| @@ -257,17 +257,20 @@ public class JDependTask extends Task { | |||||
| CommandlineJava commandline = new CommandlineJava(); | CommandlineJava commandline = new CommandlineJava(); | ||||
| if("text".equals(format)) | |||||
| if("text".equals(format)) { | |||||
| commandline.setClassname("jdepend.textui.JDepend"); | commandline.setClassname("jdepend.textui.JDepend"); | ||||
| else | |||||
| if("xml".equals(format)) | |||||
| } else | |||||
| if("xml".equals(format)) { | |||||
| commandline.setClassname("jdepend.xmlui.JDepend"); | commandline.setClassname("jdepend.xmlui.JDepend"); | ||||
| } | |||||
| if(_jvm!=null) | |||||
| if(_jvm!=null) { | |||||
| commandline.setVm(_jvm); | commandline.setVm(_jvm); | ||||
| } | |||||
| if (getSourcespath() == null) | |||||
| if (getSourcespath() == null) { | |||||
| throw new BuildException("Missing Sourcepath required argument"); | throw new BuildException("Missing Sourcepath required argument"); | ||||
| } | |||||
| // execute the test and get the return code | // execute the test and get the return code | ||||
| int exitValue = JDependTask.ERRORS; | int exitValue = JDependTask.ERRORS; | ||||
| @@ -289,11 +292,12 @@ public class JDependTask extends Task { | |||||
| boolean errorOccurred = exitValue == JDependTask.ERRORS; | boolean errorOccurred = exitValue == JDependTask.ERRORS; | ||||
| if (errorOccurred) { | if (errorOccurred) { | ||||
| if (getHaltonerror()) | |||||
| if (getHaltonerror()) { | |||||
| throw new BuildException("JDepend failed", | throw new BuildException("JDepend failed", | ||||
| location); | location); | ||||
| else | |||||
| } else { | |||||
| log("JDepend FAILED", Project.MSG_ERR); | log("JDepend FAILED", Project.MSG_ERR); | ||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -310,10 +314,11 @@ public class JDependTask extends Task { | |||||
| public int executeInVM(CommandlineJava commandline) throws BuildException { | public int executeInVM(CommandlineJava commandline) throws BuildException { | ||||
| jdepend.textui.JDepend jdepend; | jdepend.textui.JDepend jdepend; | ||||
| if("xml".equals(format)) | |||||
| if("xml".equals(format)) { | |||||
| jdepend = new jdepend.xmlui.JDepend(); | jdepend = new jdepend.xmlui.JDepend(); | ||||
| else | |||||
| } else { | |||||
| jdepend = new jdepend.textui.JDepend(); | jdepend = new jdepend.textui.JDepend(); | ||||
| } | |||||
| if (getOutputFile() != null) { | if (getOutputFile() != null) { | ||||
| FileWriter fw; | FileWriter fw; | ||||
| @@ -386,8 +391,9 @@ public class JDependTask extends Task { | |||||
| File f = new File(sourcesPath.nextToken()); | File f = new File(sourcesPath.nextToken()); | ||||
| // not necessary as JDepend would fail, but why loose some time? | // 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."); | throw new BuildException("\""+ f.getPath() + "\" does not represent a valid directory. JDepend would fail."); | ||||
| } | |||||
| commandline.createArgument().setValue(f.getPath()); | commandline.createArgument().setValue(f.getPath()); | ||||
| } | } | ||||
| @@ -398,8 +404,9 @@ public class JDependTask extends Task { | |||||
| execute.setAntRun(project); | execute.setAntRun(project); | ||||
| } | } | ||||
| if (getOutputFile() != null) | |||||
| if (getOutputFile() != null) { | |||||
| log("Output to be stored in " + getOutputFile().getPath()); | log("Output to be stored in " + getOutputFile().getPath()); | ||||
| } | |||||
| log("Executing: "+commandline.toString(), Project.MSG_VERBOSE); | log("Executing: "+commandline.toString(), Project.MSG_VERBOSE); | ||||
| try { | try { | ||||
| return execute.execute(); | return execute.execute(); | ||||
| @@ -248,15 +248,17 @@ public class JspC extends MatchingTask | |||||
| /* ------------------------------------------------------------ */ | /* ------------------------------------------------------------ */ | ||||
| /** Set the classpath to be used for this compilation */ | /** Set the classpath to be used for this compilation */ | ||||
| public void setClasspath(Path cp) { | public void setClasspath(Path cp) { | ||||
| if (classpath == null) | |||||
| if (classpath == null) { | |||||
| classpath = cp; | classpath = cp; | ||||
| else | |||||
| } else { | |||||
| classpath.append(cp); | classpath.append(cp); | ||||
| } | |||||
| } | } | ||||
| /** Maybe creates a nested classpath element. */ | /** Maybe creates a nested classpath element. */ | ||||
| public Path createClasspath() { | public Path createClasspath() { | ||||
| if (classpath == null) | |||||
| if (classpath == null) { | |||||
| classpath = new Path(project); | classpath = new Path(project); | ||||
| } | |||||
| return classpath.createPath(); | return classpath.createPath(); | ||||
| } | } | ||||
| /** Adds a reference to a CLASSPATH defined elsewhere */ | /** Adds a reference to a CLASSPATH defined elsewhere */ | ||||
| @@ -294,9 +296,9 @@ public class JspC extends MatchingTask | |||||
| // calculate where the files will end up: | // calculate where the files will end up: | ||||
| File dest = null; | File dest = null; | ||||
| if (packageName == null) | |||||
| if (packageName == null) { | |||||
| dest = destDir; | dest = destDir; | ||||
| else { | |||||
| } else { | |||||
| String path = destDir.getPath() + File.separatorChar + | String path = destDir.getPath() + File.separatorChar + | ||||
| packageName.replace('.', File.separatorChar); | packageName.replace('.', File.separatorChar); | ||||
| dest = new File(path); | dest = new File(path); | ||||
| @@ -79,12 +79,14 @@ public class JasperC extends DefaultCompilerAdapter | |||||
| // Create an instance of the compiler, redirecting output to | // Create an instance of the compiler, redirecting output to | ||||
| // the project log | // the project log | ||||
| Java java = (Java)(getJspc().getProject()).createTask("java"); | Java java = (Java)(getJspc().getProject()).createTask("java"); | ||||
| if (getJspc().getClasspath() != null) | |||||
| if (getJspc().getClasspath() != null) { | |||||
| java.setClasspath(getJspc().getClasspath()); | java.setClasspath(getJspc().getClasspath()); | ||||
| } | |||||
| java.setClassname("org.apache.jasper.JspC"); | java.setClassname("org.apache.jasper.JspC"); | ||||
| String args[] = cmd.getArguments(); | 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.createArg().setValue(args[i]); | ||||
| } | |||||
| java.setFailonerror(true); | java.setFailonerror(true); | ||||
| java.execute(); | java.execute(); | ||||
| return true; | return true; | ||||
| @@ -518,7 +518,9 @@ public class JUnitTask extends Task { | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new BuildException("Process fork failed.", e, location); | throw new BuildException("Process fork failed.", e, location); | ||||
| } finally { | } 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; | return retVal; | ||||
| @@ -321,14 +321,16 @@ public class MimeMail extends Task { | |||||
| String addrUserName, | String addrUserName, | ||||
| String addrList | String addrList | ||||
| ) throws MessagingException, BuildException { | ) throws MessagingException, BuildException { | ||||
| if ((null == addrList) || (addrList.trim().length() <= 0)) | |||||
| if ((null == addrList) || (addrList.trim().length() <= 0)) { | |||||
| return; | return; | ||||
| } | |||||
| try { | try { | ||||
| InternetAddress[] addrArray = InternetAddress.parse(addrList); | 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"); | throw new BuildException("Empty " + addrUserName + " recipients list was specified"); | ||||
| } | |||||
| msg.setRecipients(recipType, addrArray); | msg.setRecipients(recipType, addrArray); | ||||
| } | } | ||||
| @@ -87,14 +87,16 @@ public class P4Add extends P4Base { | |||||
| private int m_cmdLength = 450; | private int m_cmdLength = 450; | ||||
| public void setCommandlength(int len) throws BuildException { | public void setCommandlength(int len) throws BuildException { | ||||
| if(len <= 0) | |||||
| if(len <= 0) { | |||||
| throw new BuildException("P4Add: Commandlength should be a positive number"); | throw new BuildException("P4Add: Commandlength should be a positive number"); | ||||
| } | |||||
| this.m_cmdLength = len; | this.m_cmdLength = len; | ||||
| } | } | ||||
| public void setChangelist(int changelist) throws BuildException { | public void setChangelist(int changelist) throws BuildException { | ||||
| if(changelist <= 0) | |||||
| if(changelist <= 0) { | |||||
| throw new BuildException("P4Add: Changelist# should be a positive number"); | throw new BuildException("P4Add: Changelist# should be a positive number"); | ||||
| } | |||||
| this.m_changelist = changelist; | this.m_changelist = changelist; | ||||
| } | } | ||||
| @@ -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 | //Get default P4 settings from environment - Mark would have done something cool with | ||||
| //introspection here.....:-) | //introspection here.....:-) | ||||
| String tmpprop; | 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 { | 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); | 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); | Execute exe = new Execute(handler, null); | ||||
| @@ -79,7 +79,9 @@ public class P4Change extends P4Base { | |||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| if(emptyChangeList == null) emptyChangeList = getEmptyChangeList(); | |||||
| if(emptyChangeList == null) { | |||||
| emptyChangeList = getEmptyChangeList(); | |||||
| } | |||||
| final Project myProj = project; | final Project myProj = project; | ||||
| P4Handler handler = new P4HandlerAdapter() { | P4Handler handler = new P4HandlerAdapter() { | ||||
| @@ -76,8 +76,12 @@ public class P4Delete extends P4Base { | |||||
| } | } | ||||
| public void execute() throws BuildException { | 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)); | execP4Command("-s delete "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -78,8 +78,12 @@ import org.apache.tools.ant.BuildException; | |||||
| } | } | ||||
| public void execute() throws 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)); | execP4Command("-s edit "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -69,14 +69,19 @@ public class P4Reopen extends P4Base { | |||||
| private String toChange = ""; | private String toChange = ""; | ||||
| public void setToChange(String toChange) throws BuildException { | 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"); | throw new BuildException("P4Reopen: tochange cannot be null or empty"); | ||||
| } | |||||
| this.toChange = toChange; | this.toChange = toChange; | ||||
| } | } | ||||
| public void execute() throws BuildException { | 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)); | execP4Command("-s reopen -c "+toChange+" "+P4View, new SimpleP4OutputHandler(this)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -70,8 +70,9 @@ public class P4Revert extends P4Base { | |||||
| private boolean onlyUnchanged = false; | private boolean onlyUnchanged = false; | ||||
| public void setChange(String revertChange) throws BuildException { | 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"); | throw new BuildException("P4Revert: change cannot be null or empty"); | ||||
| } | |||||
| this.revertChange = revertChange; | this.revertChange = revertChange; | ||||
| @@ -91,9 +92,13 @@ public class P4Revert extends P4Base { | |||||
| * The whole process also accepts a p4 filespec | * The whole process also accepts a p4 filespec | ||||
| */ | */ | ||||
| String p4cmd = "-s revert"; | 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)); | execP4Command(p4cmd+" "+P4View, new SimpleP4OutputHandler(this)); | ||||
| } | } | ||||
| @@ -84,8 +84,9 @@ public class P4Sync extends P4Base { | |||||
| private String syncCmd = ""; | private String syncCmd = ""; | ||||
| public void setLabel(String label) throws BuildException { | 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"); | throw new BuildException("P4Sync: Labels cannot be Null or Empty"); | ||||
| } | |||||
| this.label = label; | this.label = label; | ||||
| @@ -93,8 +94,9 @@ public class P4Sync extends P4Base { | |||||
| public void setForce(String force) throws BuildException { | 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!"); | throw new BuildException("P4Sync: If you want to force, set force to non-null string!"); | ||||
| } | |||||
| P4CmdOpts = "-f"; | P4CmdOpts = "-f"; | ||||
| } | } | ||||
| @@ -143,11 +143,13 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||||
| private String getExecutable(String exe) { | private String getExecutable(String exe) { | ||||
| StringBuffer correctedExe = new StringBuffer(); | StringBuffer correctedExe = new StringBuffer(); | ||||
| if(getPvcsbin()!=null) | |||||
| if(pvcsbin.endsWith(File.separator)) | |||||
| if(getPvcsbin()!=null) { | |||||
| if(pvcsbin.endsWith(File.separator)) { | |||||
| correctedExe.append(pvcsbin); | correctedExe.append(pvcsbin); | ||||
| else | |||||
| } else { | |||||
| correctedExe.append(pvcsbin).append(File.separator); | correctedExe.append(pvcsbin).append(File.separator); | ||||
| } | |||||
| } | |||||
| return correctedExe.append(exe).toString(); | return correctedExe.append(exe).toString(); | ||||
| } | } | ||||
| @@ -158,8 +160,9 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||||
| Project aProj = getProject(); | Project aProj = getProject(); | ||||
| int result = 0; | int result = 0; | ||||
| if(repository == null || repository.trim().equals("")) | |||||
| if(repository == null || repository.trim().equals("")) { | |||||
| throw new BuildException("Required argument repository not specified"); | throw new BuildException("Required argument repository not specified"); | ||||
| } | |||||
| // Check workspace exists | // Check workspace exists | ||||
| // Launch PCLI listversionedfiles -z -aw | // 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("lvf"); | ||||
| commandLine.createArgument().setValue("-z"); | commandLine.createArgument().setValue("-z"); | ||||
| commandLine.createArgument().setValue("-aw"); | commandLine.createArgument().setValue("-aw"); | ||||
| if(getWorkspace()!=null) | |||||
| if(getWorkspace()!=null) { | |||||
| commandLine.createArgument().setValue("-sp"+getWorkspace()); | commandLine.createArgument().setValue("-sp"+getWorkspace()); | ||||
| } | |||||
| commandLine.createArgument().setValue("-pr"+getRepository()); | commandLine.createArgument().setValue("-pr"+getRepository()); | ||||
| // default pvcs project is "/" | // default pvcs project is "/" | ||||
| if(getPvcsproject() == null && getPvcsprojects().isEmpty()) | |||||
| if(getPvcsproject() == null && getPvcsprojects().isEmpty()) { | |||||
| pvcsProject = "/"; | pvcsProject = "/"; | ||||
| } | |||||
| if(getPvcsproject()!=null) | |||||
| if(getPvcsproject()!=null) { | |||||
| commandLine.createArgument().setValue(getPvcsproject()); | commandLine.createArgument().setValue(getPvcsproject()); | ||||
| } | |||||
| if(!getPvcsprojects().isEmpty()) { | if(!getPvcsprojects().isEmpty()) { | ||||
| Enumeration e = getPvcsprojects().elements(); | Enumeration e = getPvcsprojects().elements(); | ||||
| while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
| String projectName = ((PvcsProject)e.nextElement()).getName(); | 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"); | throw new BuildException("name is a required attribute of pvcsproject"); | ||||
| } | |||||
| commandLine.createArgument().setValue(projectName); | commandLine.createArgument().setValue(projectName); | ||||
| } | } | ||||
| } | } | ||||
| @@ -204,8 +211,9 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||||
| throw new BuildException(msg, location); | 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\""); | throw new BuildException("Communication between ant and pvcs failed. No output generated from executing PVCS commandline interface \"pcli\" and \"get\""); | ||||
| } | |||||
| // Create folders in workspace | // Create folders in workspace | ||||
| log("Creating folders", Project.MSG_INFO); | log("Creating folders", Project.MSG_INFO); | ||||
| @@ -218,16 +226,18 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||||
| commandLine.clearArgs(); | commandLine.clearArgs(); | ||||
| commandLine.setExecutable(getExecutable(GET_EXE)); | commandLine.setExecutable(getExecutable(GET_EXE)); | ||||
| if(getForce()!=null && getForce().equals("yes")) | |||||
| if(getForce()!=null && getForce().equals("yes")) { | |||||
| commandLine.createArgument().setValue("-Y"); | commandLine.createArgument().setValue("-Y"); | ||||
| else | |||||
| } else { | |||||
| commandLine.createArgument().setValue("-N"); | commandLine.createArgument().setValue("-N"); | ||||
| } | |||||
| if(getPromotiongroup()!=null) | |||||
| if(getPromotiongroup()!=null) { | |||||
| commandLine.createArgument().setValue("-G"+getPromotiongroup()); | commandLine.createArgument().setValue("-G"+getPromotiongroup()); | ||||
| else { | |||||
| if(getLabel()!=null) | |||||
| } else { | |||||
| if(getLabel()!=null) { | |||||
| commandLine.createArgument().setValue("-r"+getLabel()); | commandLine.createArgument().setValue("-r"+getLabel()); | ||||
| } | |||||
| } | } | ||||
| if (updateOnly) { | if (updateOnly) { | ||||
| @@ -419,10 +429,11 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||||
| * @param repo String (yes/no) | * @param repo String (yes/no) | ||||
| */ | */ | ||||
| public void setForce(String f) { | public void setForce(String f) { | ||||
| if(f!=null && f.equalsIgnoreCase("yes")) | |||||
| if(f!=null && f.equalsIgnoreCase("yes")) { | |||||
| force="yes"; | force="yes"; | ||||
| else | |||||
| } else { | |||||
| force = "no"; | force = "no"; | ||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -94,7 +94,9 @@ public class CommandlineJava implements Cloneable { | |||||
| public String[] getVariables() throws BuildException { | public String[] getVariables() throws BuildException { | ||||
| String props[] = super.getVariables(); | String props[] = super.getVariables(); | ||||
| if (props == null) return null; | |||||
| if (props == null) { | |||||
| return null; | |||||
| } | |||||
| for (int i = 0; i < props.length; i++) { | for (int i = 0; i < props.length; i++) { | ||||
| props[i] = "-D" + props[i]; | props[i] = "-D" + props[i]; | ||||
| @@ -121,8 +123,9 @@ public class CommandlineJava implements Cloneable { | |||||
| } | } | ||||
| public void restoreSystem() throws BuildException { | public void restoreSystem() throws BuildException { | ||||
| if (sys == null) | |||||
| if (sys == null) { | |||||
| throw new BuildException("Unbalanced nesting of SysProperties"); | throw new BuildException("Unbalanced nesting of SysProperties"); | ||||
| } | |||||
| try { | try { | ||||
| System.setProperties(sys); | System.setProperties(sys); | ||||
| @@ -300,7 +300,9 @@ public class FileSet extends DataType implements Cloneable { | |||||
| ds.setIncludes(defaultPatterns.getIncludePatterns(p)); | ds.setIncludes(defaultPatterns.getIncludePatterns(p)); | ||||
| ds.setExcludes(defaultPatterns.getExcludePatterns(p)); | ds.setExcludes(defaultPatterns.getExcludePatterns(p)); | ||||
| if (useDefaultExcludes) ds.addDefaultExcludes(); | |||||
| if (useDefaultExcludes) { | |||||
| ds.addDefaultExcludes(); | |||||
| } | |||||
| ds.setCaseSensitive(isCaseSensitive); | ds.setCaseSensitive(isCaseSensitive); | ||||
| } | } | ||||
| @@ -215,7 +215,9 @@ public class Path extends DataType implements Cloneable { | |||||
| * Append the contents of the other Path instance to this. | * Append the contents of the other Path instance to this. | ||||
| */ | */ | ||||
| public void append(Path other) { | public void append(Path other) { | ||||
| if (other == null) return; | |||||
| if (other == null) { | |||||
| return; | |||||
| } | |||||
| String[] l = other.list(); | String[] l = other.list(); | ||||
| for (int i=0; i<l.length; i++) { | for (int i=0; i<l.length; i++) { | ||||
| if (elements.indexOf(l[i]) == -1) { | if (elements.indexOf(l[i]) == -1) { | ||||
| @@ -319,7 +321,9 @@ public class Path extends DataType implements Cloneable { | |||||
| final String[] list = list(); | final String[] list = list(); | ||||
| // empty path return empty string | // empty path return empty string | ||||
| if (list.length == 0) return ""; | |||||
| if (list.length == 0) { | |||||
| return ""; | |||||
| } | |||||
| // path containing one or more elements | // path containing one or more elements | ||||
| final StringBuffer result = new StringBuffer(list[0].toString()); | final StringBuffer result = new StringBuffer(list[0].toString()); | ||||
| @@ -336,7 +340,9 @@ public class Path extends DataType implements Cloneable { | |||||
| */ | */ | ||||
| public static String[] translatePath(Project project, String source) { | public static String[] translatePath(Project project, String source) { | ||||
| final Vector result = new Vector(); | final Vector result = new Vector(); | ||||
| if (source == null) return new String[0]; | |||||
| if (source == null) { | |||||
| return new String[0]; | |||||
| } | |||||
| PathTokenizer tok = new PathTokenizer(source); | PathTokenizer tok = new PathTokenizer(source); | ||||
| StringBuffer element = new StringBuffer(); | StringBuffer element = new StringBuffer(); | ||||
| @@ -365,7 +371,9 @@ public class Path extends DataType implements Cloneable { | |||||
| * replaced so that they match the local OS conventions. | * replaced so that they match the local OS conventions. | ||||
| */ | */ | ||||
| public static String translateFile(String source) { | public static String translateFile(String source) { | ||||
| if (source == null) return ""; | |||||
| if (source == null) { | |||||
| return ""; | |||||
| } | |||||
| final StringBuffer result = new StringBuffer(source); | final StringBuffer result = new StringBuffer(source); | ||||
| for (int i=0; i < result.length(); i++) { | for (int i=0; i < result.length(); i++) { | ||||
| @@ -390,7 +390,9 @@ public class PatternSet extends DataType { | |||||
| * Convert a vector of NameEntry elements into an array of Strings. | * Convert a vector of NameEntry elements into an array of Strings. | ||||
| */ | */ | ||||
| private String[] makeArray(Vector list, Project p) { | private String[] makeArray(Vector list, Project p) { | ||||
| if (list.size() == 0) return null; | |||||
| if (list.size() == 0) { | |||||
| return null; | |||||
| } | |||||
| Vector tmpNames = new Vector(); | Vector tmpNames = new Vector(); | ||||
| for (Enumeration e = list.elements() ; e.hasMoreElements() ;) { | for (Enumeration e = list.elements() ; e.hasMoreElements() ;) { | ||||
| @@ -417,10 +419,11 @@ public class PatternSet extends DataType { | |||||
| String fileName = ne.evalName(p); | String fileName = ne.evalName(p); | ||||
| if (fileName != null) { | if (fileName != null) { | ||||
| File inclFile = p.resolveFile(fileName); | File inclFile = p.resolveFile(fileName); | ||||
| if (!inclFile.exists()) | |||||
| if (!inclFile.exists()) { | |||||
| throw new BuildException("Includesfile " | throw new BuildException("Includesfile " | ||||
| + inclFile.getAbsolutePath() | + inclFile.getAbsolutePath() | ||||
| + " not found."); | + " not found."); | ||||
| } | |||||
| readPatterns(inclFile, includeList, p); | readPatterns(inclFile, includeList, p); | ||||
| } | } | ||||
| } | } | ||||
| @@ -434,10 +437,11 @@ public class PatternSet extends DataType { | |||||
| String fileName = ne.evalName(p); | String fileName = ne.evalName(p); | ||||
| if (fileName != null) { | if (fileName != null) { | ||||
| File exclFile = p.resolveFile(fileName); | File exclFile = p.resolveFile(fileName); | ||||
| if (!exclFile.exists()) | |||||
| if (!exclFile.exists()) { | |||||
| throw new BuildException("Excludesfile " | throw new BuildException("Excludesfile " | ||||
| + exclFile.getAbsolutePath() | + exclFile.getAbsolutePath() | ||||
| + " not found."); | + " not found."); | ||||
| } | |||||
| readPatterns(exclFile, excludeList, p); | readPatterns(exclFile, excludeList, p); | ||||
| } | } | ||||
| } | } | ||||
| @@ -119,16 +119,18 @@ public class RegularExpression extends DataType | |||||
| */ | */ | ||||
| public String getPattern(Project p) | public String getPattern(Project p) | ||||
| { | { | ||||
| if (isReference()) | |||||
| if (isReference()) { | |||||
| return getRef(p).getPattern(p); | return getRef(p).getPattern(p); | ||||
| } | |||||
| return regexp.getPattern(); | return regexp.getPattern(); | ||||
| } | } | ||||
| public Regexp getRegexp(Project p) | public Regexp getRegexp(Project p) | ||||
| { | { | ||||
| if (isReference()) | |||||
| if (isReference()) { | |||||
| return getRef(p).getRegexp(p); | return getRef(p).getRegexp(p); | ||||
| } | |||||
| return this.regexp; | return this.regexp; | ||||
| } | } | ||||
| @@ -95,8 +95,9 @@ public class Dependencies implements Visitor { | |||||
| public void visitConstantNameAndType(ConstantNameAndType obj) {} | public void visitConstantNameAndType(ConstantNameAndType obj) {} | ||||
| public void visitConstantPool(ConstantPool obj) { | public void visitConstantPool(ConstantPool obj) { | ||||
| if (verbose) | |||||
| if (verbose) { | |||||
| System.out.println("visit ConstantPool"); | System.out.println("visit ConstantPool"); | ||||
| } | |||||
| this.constantPool = obj; | this.constantPool = obj; | ||||
| // visit constants | // visit constants | ||||
| @@ -203,8 +204,9 @@ public class Dependencies implements Visitor { | |||||
| for (int i=o; i < args.length; i++) { | for (int i=o; i < args.length; i++) { | ||||
| String fileName = args[i].substring(0, args[i].length() - ".class".length()); | String fileName = args[i].substring(0, args[i].length() - ".class".length()); | ||||
| if (base != null && fileName.startsWith(base)) | |||||
| if (base != null && fileName.startsWith(base)) { | |||||
| fileName = fileName.substring(base.length()); | fileName = fileName.substring(base.length()); | ||||
| } | |||||
| newSet.add(fileName); | newSet.add(fileName); | ||||
| } | } | ||||
| set.addAll(newSet); | set.addAll(newSet); | ||||
| @@ -228,8 +230,9 @@ public class Dependencies implements Visitor { | |||||
| applyFilter(newSet, new Filter() { | applyFilter(newSet, new Filter() { | ||||
| public boolean accept(Object object) { | public boolean accept(Object object) { | ||||
| String fileName = object + ".class"; | String fileName = object + ".class"; | ||||
| if (base != null) | |||||
| if (base != null) { | |||||
| fileName = base + fileName; | fileName = base + fileName; | ||||
| } | |||||
| return new File(fileName).exists(); | return new File(fileName).exists(); | ||||
| } | } | ||||
| }); | }); | ||||
| @@ -149,12 +149,15 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||||
| { | { | ||||
| int cOptions = RE.MATCH_NORMAL; | int cOptions = RE.MATCH_NORMAL; | ||||
| if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) | |||||
| if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) { | |||||
| cOptions |= RE.MATCH_CASEINDEPENDENT; | cOptions |= RE.MATCH_CASEINDEPENDENT; | ||||
| if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) | |||||
| } | |||||
| if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) { | |||||
| cOptions |= RE.MATCH_MULTILINE; | cOptions |= RE.MATCH_MULTILINE; | ||||
| if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) | |||||
| } | |||||
| if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) { | |||||
| cOptions |= RE.MATCH_SINGLELINE; | cOptions |= RE.MATCH_SINGLELINE; | ||||
| } | |||||
| return cOptions; | return cOptions; | ||||
| } | } | ||||
| @@ -73,8 +73,9 @@ public class JakartaRegexpRegexp extends JakartaRegexpMatcher implements Regexp | |||||
| protected int getSubsOptions(int options) | protected int getSubsOptions(int options) | ||||
| { | { | ||||
| int subsOptions = RE.REPLACE_FIRSTONLY; | int subsOptions = RE.REPLACE_FIRSTONLY; | ||||
| if (RegexpUtil.hasFlag(options, REPLACE_ALL)) | |||||
| if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { | |||||
| subsOptions = RE.REPLACE_ALL; | subsOptions = RE.REPLACE_ALL; | ||||
| } | |||||
| return subsOptions; | return subsOptions; | ||||
| } | } | ||||
| @@ -163,12 +163,15 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
| { | { | ||||
| int cOptions = 0; | int cOptions = 0; | ||||
| if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) | |||||
| if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) { | |||||
| cOptions |= Pattern.CASE_INSENSITIVE; | cOptions |= Pattern.CASE_INSENSITIVE; | ||||
| if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) | |||||
| } | |||||
| if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) { | |||||
| cOptions |= Pattern.MULTILINE; | cOptions |= Pattern.MULTILINE; | ||||
| if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) | |||||
| } | |||||
| if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) { | |||||
| cOptions |= Pattern.DOTALL; | cOptions |= Pattern.DOTALL; | ||||
| } | |||||
| return cOptions; | return cOptions; | ||||
| } | } | ||||
| @@ -75,8 +75,9 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp | |||||
| protected int getSubsOptions(int options) | protected int getSubsOptions(int options) | ||||
| { | { | ||||
| int subsOptions = REPLACE_FIRST; | int subsOptions = REPLACE_FIRST; | ||||
| if (RegexpUtil.hasFlag(options, REPLACE_ALL)) | |||||
| if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { | |||||
| subsOptions = REPLACE_ALL; | subsOptions = REPLACE_ALL; | ||||
| } | |||||
| return subsOptions; | return subsOptions; | ||||
| } | } | ||||
| @@ -89,12 +89,13 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| private void makeMaps() { | private void makeMaps() { | ||||
| int i; | int i; | ||||
| nInUse = 0; | nInUse = 0; | ||||
| for (i = 0; i < 256; i++) | |||||
| for (i = 0; i < 256; i++) { | |||||
| if (inUse[i]) { | if (inUse[i]) { | ||||
| seqToUnseq[nInUse] = (char)i; | seqToUnseq[nInUse] = (char)i; | ||||
| unseqToSeq[i] = (char)nInUse; | unseqToSeq[i] = (char)nInUse; | ||||
| nInUse++; | nInUse++; | ||||
| } | } | ||||
| } | |||||
| } | } | ||||
| /* | /* | ||||
| @@ -249,10 +250,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| storedBlockCRC = bsGetInt32(); | storedBlockCRC = bsGetInt32(); | ||||
| if (bsR(1) == 1) | |||||
| if (bsR(1) == 1) { | |||||
| blockRandomised = true; | blockRandomised = true; | ||||
| else | |||||
| } else { | |||||
| blockRandomised = false; | blockRandomised = false; | ||||
| } | |||||
| // currBlockNo++; | // currBlockNo++; | ||||
| getAndMoveToFrontDecode(); | getAndMoveToFrontDecode(); | ||||
| @@ -264,8 +266,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| private void endBlock() { | private void endBlock() { | ||||
| computedBlockCRC = mCrc.getFinalCRC(); | computedBlockCRC = mCrc.getFinalCRC(); | ||||
| /* A bad CRC is considered a fatal error. */ | /* A bad CRC is considered a fatal error. */ | ||||
| if (storedBlockCRC != computedBlockCRC) | |||||
| if (storedBlockCRC != computedBlockCRC) { | |||||
| crcError(); | crcError(); | ||||
| } | |||||
| computedCombinedCRC = (computedCombinedCRC << 1) | computedCombinedCRC = (computedCombinedCRC << 1) | ||||
| | (computedCombinedCRC >>> 31); | | (computedCombinedCRC >>> 31); | ||||
| @@ -274,8 +277,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| private void complete() { | private void complete() { | ||||
| storedCombinedCRC = bsGetInt32(); | storedCombinedCRC = bsGetInt32(); | ||||
| if (storedCombinedCRC != computedCombinedCRC) | |||||
| if (storedCombinedCRC != computedCombinedCRC) { | |||||
| crcError(); | crcError(); | ||||
| } | |||||
| bsFinishedWithStream(); | bsFinishedWithStream(); | ||||
| streamEnd = true; | streamEnd = true; | ||||
| @@ -357,23 +361,29 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| int pp, i, j, vec; | int pp, i, j, vec; | ||||
| pp = 0; | 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) { | if (length[j] == i) { | ||||
| perm[pp] = j; | perm[pp] = j; | ||||
| pp++; | pp++; | ||||
| }; | |||||
| } | |||||
| } | |||||
| }; | |||||
| for(i = 0; i < MAX_CODE_LEN; i++) | |||||
| for(i = 0; i < MAX_CODE_LEN; i++) { | |||||
| base[i] = 0; | base[i] = 0; | ||||
| for(i = 0; i < alphaSize; i++) | |||||
| } | |||||
| for(i = 0; i < alphaSize; i++) { | |||||
| base[length[i]+1]++; | 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]; | base[i] += base[i-1]; | ||||
| } | |||||
| for (i = 0; i < MAX_CODE_LEN; i++) | |||||
| for (i = 0; i < MAX_CODE_LEN; i++) { | |||||
| limit[i] = 0; | limit[i] = 0; | ||||
| } | |||||
| vec = 0; | vec = 0; | ||||
| for (i = minLen; i <= maxLen; i++) { | for (i = minLen; i <= maxLen; i++) { | ||||
| @@ -381,8 +391,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| limit[i] = vec-1; | limit[i] = vec-1; | ||||
| 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]; | base[i] = ((limit[i-1] + 1) << 1) - base[i]; | ||||
| } | |||||
| } | } | ||||
| private void recvDecodingTables() { | private void recvDecodingTables() { | ||||
| @@ -392,20 +403,27 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| boolean inUse16[] = new boolean[16]; | boolean inUse16[] = new boolean[16]; | ||||
| /* Receive the mapping table */ | /* 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; | inUse16[i] = true; | ||||
| else | |||||
| } else { | |||||
| inUse16[i] = false; | inUse16[i] = false; | ||||
| } | |||||
| } | |||||
| for (i = 0; i < 256; i++) | |||||
| for (i = 0; i < 256; i++) { | |||||
| inUse[i] = false; | 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; | inUse[i * 16 + j] = true; | ||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| makeMaps(); | makeMaps(); | ||||
| alphaSize = nInUse+2; | alphaSize = nInUse+2; | ||||
| @@ -415,8 +433,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| nSelectors = bsR(15); | nSelectors = bsR(15); | ||||
| for (i = 0; i < nSelectors; i++) { | for (i = 0; i < nSelectors; i++) { | ||||
| j = 0; | j = 0; | ||||
| while (bsR(1) == 1) | |||||
| while (bsR(1) == 1) { | |||||
| j++; | j++; | ||||
| } | |||||
| selectorMtf[i] = (char)j; | selectorMtf[i] = (char)j; | ||||
| } | } | ||||
| @@ -424,8 +443,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| { | { | ||||
| char pos[] = new char[N_GROUPS]; | char pos[] = new char[N_GROUPS]; | ||||
| char tmp, v; | char tmp, v; | ||||
| for (v = 0; v < nGroups; v++) | |||||
| for (v = 0; v < nGroups; v++) { | |||||
| pos[v] = v; | pos[v] = v; | ||||
| } | |||||
| for (i = 0; i < nSelectors; i++) { | for (i = 0; i < nSelectors; i++) { | ||||
| v = selectorMtf[i]; | v = selectorMtf[i]; | ||||
| @@ -444,10 +464,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| int curr = bsR ( 5 ); | int curr = bsR ( 5 ); | ||||
| for (i = 0; i < alphaSize; i++) { | for (i = 0; i < alphaSize; i++) { | ||||
| while (bsR(1) == 1) { | while (bsR(1) == 1) { | ||||
| if (bsR(1) == 0) | |||||
| if (bsR(1) == 0) { | |||||
| curr++; | curr++; | ||||
| else | |||||
| } else { | |||||
| curr--; | curr--; | ||||
| } | |||||
| } | } | ||||
| len[t][i] = (char)curr; | len[t][i] = (char)curr; | ||||
| } | } | ||||
| @@ -458,10 +479,12 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| minLen = 32; | minLen = 32; | ||||
| maxLen = 0; | maxLen = 0; | ||||
| for (i = 0; i < alphaSize; i++) { | for (i = 0; i < alphaSize; i++) { | ||||
| if (len[t][i] > maxLen) | |||||
| if (len[t][i] > maxLen) { | |||||
| maxLen = len[t][i]; | maxLen = len[t][i]; | ||||
| if (len[t][i] < minLen) | |||||
| } | |||||
| if (len[t][i] < minLen) { | |||||
| minLen = len[t][i]; | minLen = len[t][i]; | ||||
| } | |||||
| } | } | ||||
| hbCreateDecodeTables(limit[t], base[t], perm[t], len[t], minLen, | hbCreateDecodeTables(limit[t], base[t], perm[t], len[t], minLen, | ||||
| maxLen, alphaSize); | 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 | in a separate pass, and so saves a block's worth of | ||||
| cache misses. | cache misses. | ||||
| */ | */ | ||||
| for (i = 0; i <= 255; i++) | |||||
| for (i = 0; i <= 255; i++) { | |||||
| unzftab[i] = 0; | unzftab[i] = 0; | ||||
| } | |||||
| for (i = 0; i <= 255; i++) | |||||
| for (i = 0; i <= 255; i++) { | |||||
| yy[i] = (char) i; | yy[i] = (char) i; | ||||
| } | |||||
| last = -1; | last = -1; | ||||
| @@ -536,18 +561,20 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| while(true) { | while(true) { | ||||
| if (nextSym == EOB) | |||||
| if (nextSym == EOB) { | |||||
| break; | break; | ||||
| } | |||||
| if (nextSym == RUNA || nextSym == RUNB) { | if (nextSym == RUNA || nextSym == RUNB) { | ||||
| char ch; | char ch; | ||||
| int s = -1; | int s = -1; | ||||
| int N = 1; | int N = 1; | ||||
| do { | do { | ||||
| if (nextSym == RUNA) | |||||
| if (nextSym == RUNA) { | |||||
| s = s + (0+1) * N; | s = s + (0+1) * N; | ||||
| else if (nextSym == RUNB) | |||||
| } else if (nextSym == RUNB) { | |||||
| s = s + (1+1) * N; | s = s + (1+1) * N; | ||||
| } | |||||
| N = N * 2; | N = N * 2; | ||||
| { | { | ||||
| int zt, zn, zvec, zj; | int zt, zn, zvec, zj; | ||||
| @@ -598,14 +625,16 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| s--; | s--; | ||||
| }; | }; | ||||
| if (last >= limitLast) | |||||
| if (last >= limitLast) { | |||||
| blockOverrun(); | blockOverrun(); | ||||
| } | |||||
| continue; | continue; | ||||
| } else { | } else { | ||||
| char tmp; | char tmp; | ||||
| last++; | last++; | ||||
| if (last >= limitLast) | |||||
| if (last >= limitLast) { | |||||
| blockOverrun(); | blockOverrun(); | ||||
| } | |||||
| tmp = yy[nextSym-1]; | tmp = yy[nextSym-1]; | ||||
| unzftab[seqToUnseq[tmp]]++; | unzftab[seqToUnseq[tmp]]++; | ||||
| @@ -625,8 +654,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| yy[j-2] = yy[j-3]; | yy[j-2] = yy[j-3]; | ||||
| yy[j-3] = yy[j-4]; | yy[j-3] = yy[j-4]; | ||||
| } | } | ||||
| for (; j > 0; j--) | |||||
| for (; j > 0; j--) { | |||||
| yy[j] = yy[j-1]; | yy[j] = yy[j-1]; | ||||
| } | |||||
| yy[0] = tmp; | yy[0] = tmp; | ||||
| { | { | ||||
| @@ -673,10 +703,12 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| char ch; | char ch; | ||||
| cftab[0] = 0; | cftab[0] = 0; | ||||
| for (i = 1; i <= 256; i++) | |||||
| for (i = 1; i <= 256; i++) { | |||||
| cftab[i] = unzftab[i-1]; | cftab[i] = unzftab[i-1]; | ||||
| for (i = 1; i <= 256; i++) | |||||
| } | |||||
| for (i = 1; i <= 256; i++) { | |||||
| cftab[i] += cftab[i-1]; | cftab[i] += cftab[i-1]; | ||||
| } | |||||
| for (i = 0; i <= last; i++) { | for (i = 0; i <= last; i++) { | ||||
| ch = (char)ll8[i]; | ch = (char)ll8[i]; | ||||
| @@ -708,8 +740,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| if (rNToGo == 0) { | if (rNToGo == 0) { | ||||
| rNToGo = rNums[rTPos]; | rNToGo = rNums[rTPos]; | ||||
| rTPos++; | rTPos++; | ||||
| if(rTPos == 512) | |||||
| if(rTPos == 512) { | |||||
| rTPos = 0; | rTPos = 0; | ||||
| } | |||||
| } | } | ||||
| rNToGo--; | rNToGo--; | ||||
| ch2 ^= (int)((rNToGo == 1) ? 1 : 0); | ch2 ^= (int)((rNToGo == 1) ? 1 : 0); | ||||
| @@ -755,8 +788,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| if (rNToGo == 0) { | if (rNToGo == 0) { | ||||
| rNToGo = rNums[rTPos]; | rNToGo = rNums[rTPos]; | ||||
| rTPos++; | rTPos++; | ||||
| if(rTPos == 512) | |||||
| if(rTPos == 512) { | |||||
| rTPos = 0; | rTPos = 0; | ||||
| } | |||||
| } | } | ||||
| rNToGo--; | rNToGo--; | ||||
| z ^= ((rNToGo == 1) ? 1 : 0); | z ^= ((rNToGo == 1) ? 1 : 0); | ||||
| @@ -824,8 +858,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||||
| blockSize100k = newSize100k; | blockSize100k = newSize100k; | ||||
| if(newSize100k == 0) | |||||
| if(newSize100k == 0) { | |||||
| return; | return; | ||||
| } | |||||
| int n = baseBlockSize * newSize100k; | int n = baseBlockSize * newSize100k; | ||||
| ll8 = new char[n]; | ll8 = new char[n]; | ||||
| @@ -678,10 +678,11 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||||
| fave[t] = 0; | fave[t] = 0; | ||||
| } | } | ||||
| for (t = 0; t < nGroups; t++) | |||||
| for (t = 0; t < nGroups; t++) { | |||||
| for (v = 0; v < alphaSize; v++) { | for (v = 0; v < alphaSize; v++) { | ||||
| rfreq[t][v] = 0; | rfreq[t][v] = 0; | ||||
| } | } | ||||
| } | |||||
| nSelectors = 0; | nSelectors = 0; | ||||
| totc = 0; | totc = 0; | ||||
| @@ -771,8 +772,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||||
| fave = null; | fave = null; | ||||
| cost = null; | cost = null; | ||||
| if (!(nGroups < 8)) | |||||
| if (!(nGroups < 8)) { | |||||
| panic(); | panic(); | ||||
| } | |||||
| if (!(nSelectors < 32768 && nSelectors <= (2 + (900000 / G_SIZE)))) { | if (!(nSelectors < 32768 && nSelectors <= (2 + (900000 / G_SIZE)))) { | ||||
| panic(); | panic(); | ||||
| } | } | ||||
| @@ -1192,8 +1194,9 @@ public class CBZip2OutputStream extends OutputStream implements BZip2Constants { | |||||
| simpleSort ( 0, last, 0 ); | simpleSort ( 0, last, 0 ); | ||||
| } else { | } else { | ||||
| numQSorted = 0; | numQSorted = 0; | ||||
| for (i = 0; i <= 255; i++) | |||||
| for (i = 0; i <= 255; i++) { | |||||
| bigDone[i] = false; | bigDone[i] = false; | ||||
| } | |||||
| for (i = 0; i <= 65536; i++) { | for (i = 0; i <= 65536; i++) { | ||||
| ftab[i] = 0; | ftab[i] = 0; | ||||