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) { | |||
| 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")) { | |||
| @@ -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; | |||
| @@ -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++; | |||
| } | |||
| @@ -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(); | |||
| @@ -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) {} | |||
| } | |||
| @@ -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(); | |||
| } | |||
| @@ -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(); | |||
| @@ -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); | |||
| @@ -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) { | |||
| @@ -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(); | |||
| } | |||
| @@ -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]; | |||
| @@ -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. | |||
| @@ -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(); ) { | |||
| @@ -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 ); | |||
| @@ -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) { | |||
| @@ -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"); | |||
| @@ -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; | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| /** | |||
| @@ -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 | |||
| @@ -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()) | |||
| { | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -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); | |||
| @@ -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(); | |||
| @@ -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); | |||
| @@ -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; | |||
| @@ -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; | |||
| @@ -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); | |||
| } | |||
| @@ -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; | |||
| } | |||
| @@ -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); | |||
| @@ -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() { | |||
| @@ -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)); | |||
| } | |||
| } | |||
| @@ -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)); | |||
| } | |||
| } | |||
| @@ -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)); | |||
| } | |||
| } | |||
| @@ -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)); | |||
| } | |||
| @@ -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"; | |||
| } | |||
| @@ -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"; | |||
| } | |||
| } | |||
| /** | |||
| @@ -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); | |||
| @@ -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); | |||
| } | |||
| @@ -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<l.length; i++) { | |||
| if (elements.indexOf(l[i]) == -1) { | |||
| @@ -319,7 +321,9 @@ public class Path extends DataType implements Cloneable { | |||
| final String[] list = list(); | |||
| // empty path return empty string | |||
| if (list.length == 0) return ""; | |||
| if (list.length == 0) { | |||
| return ""; | |||
| } | |||
| // path containing one or more elements | |||
| 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) { | |||
| final Vector result = new Vector(); | |||
| if (source == null) return new String[0]; | |||
| if (source == null) { | |||
| return new String[0]; | |||
| } | |||
| PathTokenizer tok = new PathTokenizer(source); | |||
| StringBuffer element = new StringBuffer(); | |||
| @@ -365,7 +371,9 @@ public class Path extends DataType implements Cloneable { | |||
| * replaced so that they match the local OS conventions. | |||
| */ | |||
| public static String translateFile(String source) { | |||
| if (source == null) return ""; | |||
| if (source == null) { | |||
| return ""; | |||
| } | |||
| final StringBuffer result = new StringBuffer(source); | |||
| 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. | |||
| */ | |||
| private String[] makeArray(Vector list, Project p) { | |||
| if (list.size() == 0) return null; | |||
| if (list.size() == 0) { | |||
| return null; | |||
| } | |||
| Vector tmpNames = new Vector(); | |||
| for (Enumeration e = list.elements() ; e.hasMoreElements() ;) { | |||
| @@ -417,10 +419,11 @@ public class PatternSet extends DataType { | |||
| String fileName = ne.evalName(p); | |||
| if (fileName != null) { | |||
| File inclFile = p.resolveFile(fileName); | |||
| if (!inclFile.exists()) | |||
| if (!inclFile.exists()) { | |||
| throw new BuildException("Includesfile " | |||
| + inclFile.getAbsolutePath() | |||
| + " not found."); | |||
| } | |||
| readPatterns(inclFile, includeList, p); | |||
| } | |||
| } | |||
| @@ -434,10 +437,11 @@ public class PatternSet extends DataType { | |||
| String fileName = ne.evalName(p); | |||
| if (fileName != null) { | |||
| File exclFile = p.resolveFile(fileName); | |||
| if (!exclFile.exists()) | |||
| if (!exclFile.exists()) { | |||
| throw new BuildException("Excludesfile " | |||
| + exclFile.getAbsolutePath() | |||
| + " not found."); | |||
| } | |||
| readPatterns(exclFile, excludeList, p); | |||
| } | |||
| } | |||
| @@ -119,16 +119,18 @@ public class RegularExpression extends DataType | |||
| */ | |||
| public String getPattern(Project p) | |||
| { | |||
| if (isReference()) | |||
| if (isReference()) { | |||
| return getRef(p).getPattern(p); | |||
| } | |||
| return regexp.getPattern(); | |||
| } | |||
| public Regexp getRegexp(Project p) | |||
| { | |||
| if (isReference()) | |||
| if (isReference()) { | |||
| return getRef(p).getRegexp(p); | |||
| } | |||
| return this.regexp; | |||
| } | |||
| @@ -95,8 +95,9 @@ public class Dependencies implements Visitor { | |||
| public void visitConstantNameAndType(ConstantNameAndType obj) {} | |||
| public void visitConstantPool(ConstantPool obj) { | |||
| if (verbose) | |||
| if (verbose) { | |||
| System.out.println("visit ConstantPool"); | |||
| } | |||
| this.constantPool = obj; | |||
| // visit constants | |||
| @@ -203,8 +204,9 @@ public class Dependencies implements Visitor { | |||
| for (int i=o; i < args.length; i++) { | |||
| 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()); | |||
| } | |||
| newSet.add(fileName); | |||
| } | |||
| set.addAll(newSet); | |||
| @@ -228,8 +230,9 @@ public class Dependencies implements Visitor { | |||
| applyFilter(newSet, new Filter() { | |||
| public boolean accept(Object object) { | |||
| String fileName = object + ".class"; | |||
| if (base != null) | |||
| if (base != null) { | |||
| fileName = base + fileName; | |||
| } | |||
| return new File(fileName).exists(); | |||
| } | |||
| }); | |||
| @@ -149,12 +149,15 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||
| { | |||
| int cOptions = RE.MATCH_NORMAL; | |||
| if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) | |||
| if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) { | |||
| cOptions |= RE.MATCH_CASEINDEPENDENT; | |||
| if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) | |||
| } | |||
| if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) { | |||
| cOptions |= RE.MATCH_MULTILINE; | |||
| if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) | |||
| } | |||
| if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) { | |||
| cOptions |= RE.MATCH_SINGLELINE; | |||
| } | |||
| return cOptions; | |||
| } | |||
| @@ -73,8 +73,9 @@ public class JakartaRegexpRegexp extends JakartaRegexpMatcher implements Regexp | |||
| protected int getSubsOptions(int options) | |||
| { | |||
| int subsOptions = RE.REPLACE_FIRSTONLY; | |||
| if (RegexpUtil.hasFlag(options, REPLACE_ALL)) | |||
| if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { | |||
| subsOptions = RE.REPLACE_ALL; | |||
| } | |||
| return subsOptions; | |||
| } | |||
| @@ -163,12 +163,15 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||
| { | |||
| int cOptions = 0; | |||
| if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) | |||
| if (RegexpUtil.hasFlag(options, MATCH_CASE_INSENSITIVE)) { | |||
| cOptions |= Pattern.CASE_INSENSITIVE; | |||
| if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) | |||
| } | |||
| if (RegexpUtil.hasFlag(options, MATCH_MULTILINE)) { | |||
| cOptions |= Pattern.MULTILINE; | |||
| if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) | |||
| } | |||
| if (RegexpUtil.hasFlag(options, MATCH_SINGLELINE)) { | |||
| cOptions |= Pattern.DOTALL; | |||
| } | |||
| return cOptions; | |||
| } | |||
| @@ -75,8 +75,9 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp | |||
| protected int getSubsOptions(int options) | |||
| { | |||
| int subsOptions = REPLACE_FIRST; | |||
| if (RegexpUtil.hasFlag(options, REPLACE_ALL)) | |||
| if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { | |||
| subsOptions = REPLACE_ALL; | |||
| } | |||
| return subsOptions; | |||
| } | |||
| @@ -89,12 +89,13 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| private void makeMaps() { | |||
| int i; | |||
| nInUse = 0; | |||
| for (i = 0; i < 256; i++) | |||
| for (i = 0; i < 256; i++) { | |||
| if (inUse[i]) { | |||
| seqToUnseq[nInUse] = (char)i; | |||
| unseqToSeq[i] = (char)nInUse; | |||
| nInUse++; | |||
| } | |||
| } | |||
| } | |||
| /* | |||
| @@ -249,10 +250,11 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| storedBlockCRC = bsGetInt32(); | |||
| if (bsR(1) == 1) | |||
| if (bsR(1) == 1) { | |||
| blockRandomised = true; | |||
| else | |||
| } else { | |||
| blockRandomised = false; | |||
| } | |||
| // currBlockNo++; | |||
| getAndMoveToFrontDecode(); | |||
| @@ -264,8 +266,9 @@ public class CBZip2InputStream extends InputStream implements BZip2Constants { | |||
| private void endBlock() { | |||
| computedBlockCRC = mCrc.getFinalCRC(); | |||
| /* A bad CRC is considered a fatal error. */ | |||
| if (storedBlockCRC != computedBlockCRC) | |||
| if (storedBlockCRC != computedBlockCRC) { | |||
| crcError(); | |||
| } | |||
| computedCombinedCRC = (computedCombinedCRC << 1) | |||
| | (computedCombinedCRC >>> 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]; | |||
| @@ -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; | |||