Browse Source

Changes after static code analysis.

Code totally equivalent

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@526545 13f79535-47bb-0310-9956-ffa450edef68
master
Jacobus Martinus Kruithof 18 years ago
parent
commit
d5836ac061
15 changed files with 28 additions and 35 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/ComponentHelper.java
  2. +1
    -3
      src/main/org/apache/tools/ant/Main.java
  3. +1
    -1
      src/main/org/apache/tools/ant/filters/StripJavaComments.java
  4. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Execute.java
  5. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  6. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/SignJar.java
  7. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Tar.java
  8. +6
    -9
      src/main/org/apache/tools/ant/taskdefs/UpToDate.java
  9. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
  10. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java
  11. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  12. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  13. +1
    -1
      src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java
  14. +5
    -7
      src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java
  15. +1
    -1
      src/main/org/apache/tools/ant/util/ContainerMapper.java

+ 1
- 1
src/main/org/apache/tools/ant/ComponentHelper.java View File

@@ -1046,7 +1046,7 @@ public class ComponentHelper {
boolean found = false;
if (clazz instanceof Class) {
for (Iterator i = values().iterator(); i.hasNext() && !found;) {
found |= (((AntTypeDefinition) (i.next())).getExposedClass(
found = (((AntTypeDefinition) (i.next())).getExposedClass(
project) == clazz);
}
}


+ 1
- 3
src/main/org/apache/tools/ant/Main.java View File

@@ -821,9 +821,7 @@ public class Main implements AntMain {
handler = (InputHandler) ClasspathUtils.newInstance(
inputHandlerClassname, Main.class.getClassLoader(),
InputHandler.class);
if (project != null) {
project.setProjectReference(handler);
}
project.setProjectReference(handler);
}
project.setInputHandler(handler);
}


+ 1
- 1
src/main/org/apache/tools/ant/filters/StripJavaComments.java View File

@@ -105,7 +105,7 @@ public final class StripJavaComments
ch = in.read();
if (ch == '*') {
ch = in.read();
while (ch == '*' && ch != -1) {
while (ch == '*') {
ch = in.read();
}



+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -1047,7 +1047,7 @@ public class Execute {

// Build the command
File commandDir = workingDir;
if (workingDir == null && project != null) {
if (workingDir == null) {
commandDir = project.getBaseDir();
}
String[] newcmd = new String[cmd.length + 2];
@@ -1106,7 +1106,7 @@ public class Execute {

// Build the command
File commandDir = workingDir;
if (workingDir == null && project != null) {
if (workingDir == null) {
commandDir = project.getBaseDir();
}
String[] newcmd = new String[cmd.length + 3];


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -571,7 +571,7 @@ public class Jar extends Zip {
long lastModified, File fromArchive, int mode)
throws IOException {
if (MANIFEST_NAME.equalsIgnoreCase(vPath)) {
if (!doubleFilePass || (doubleFilePass && skipWriting)) {
if (!doubleFilePass || skipWriting) {
filesetManifest(fromArchive, is);
}
} else if (INDEX_NAME.equalsIgnoreCase(vPath) && index) {
@@ -779,7 +779,7 @@ public class Jar extends Zip {
super.cleanUp();

// we want to save this info if we are going to make another pass
if (!doubleFilePass || (doubleFilePass && !skipWriting)) {
if (!doubleFilePass || !skipWriting) {
manifest = null;
configuredManifest = savedConfiguredManifest;
filesetManifest = null;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/SignJar.java View File

@@ -376,7 +376,7 @@ public class SignJar extends AbstractJarSignerTask {

//DO NOT SET THE -signedjar OPTION if source==dest
//unless you like fielding hotspot crash reports
if (null != targetFile && !jarSource.equals(targetFile)) {
if (!jarSource.equals(targetFile)) {
addValue(cmd, "-signedjar");
addValue(cmd, targetFile.getPath());
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Tar.java View File

@@ -584,7 +584,7 @@ public class Tar extends MatchingTask {
Iterator iter = rc.iterator();
while (upToDate && iter.hasNext()) {
Resource r = (Resource) iter.next();
upToDate &= archiveIsUpToDate(r);
upToDate = archiveIsUpToDate(r);
}
}
return upToDate;


+ 6
- 9
src/main/org/apache/tools/ant/taskdefs/UpToDate.java View File

@@ -185,14 +185,12 @@ public class UpToDate extends Task implements Condition {
boolean upToDate = true;
if (sourceFile != null) {
if (mapperElement == null) {
upToDate = upToDate
&& (targetFile.lastModified() >= sourceFile.lastModified());
upToDate = targetFile.lastModified() >= sourceFile.lastModified();
} else {
SourceFileScanner sfs = new SourceFileScanner(this);
upToDate = upToDate
&& (sfs.restrict(new String[] {sourceFile.getAbsolutePath()},
upToDate = sfs.restrict(new String[] {sourceFile.getAbsolutePath()},
null, null,
mapperElement.getImplementation()).length == 0);
mapperElement.getImplementation()).length == 0;
}
}

@@ -204,15 +202,14 @@ public class UpToDate extends Task implements Condition {
while (upToDate && e.hasMoreElements()) {
FileSet fs = (FileSet) e.nextElement();
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
upToDate = upToDate && scanDir(fs.getDir(getProject()),
upToDate = scanDir(fs.getDir(getProject()),
ds.getIncludedFiles());
}

if (upToDate) {
Resource[] r = sourceResources.listResources();
upToDate = upToDate
&& (ResourceUtils.selectOutOfDateSources(
this, r, getMapper(), getProject()).length == 0);
upToDate = ResourceUtils.selectOutOfDateSources(
this, r, getMapper(), getProject()).length == 0;
}

return upToDate;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java View File

@@ -111,7 +111,7 @@ public class IsSigned extends DataType implements Condition {
if (file == null) {
throw new BuildException("The file attribute must be set.");
}
if (file != null && !file.exists()) {
if (!file.exists()) {
log("The file \"" + file.getAbsolutePath()
+ "\" does not exist.", Project.MSG_VERBOSE);
return false;


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagEntry.java View File

@@ -92,15 +92,15 @@ public class CvsTagEntry {
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(filename);
if ((revision == null)) {
if (revision == null) {
buffer.append(" was removed");
if (prevRevision != null) {
buffer.append("; previous revision was ").append(prevRevision);
}
} else if (revision != null && prevRevision == null) {
} else if (prevRevision == null) {
buffer.append(" is new; current revision is ")
.append(revision);
} else if (revision != null && prevRevision != null) {
} else {
buffer.append(" has changed from ")
.append(prevRevision).append(" to ").append(revision);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java View File

@@ -290,7 +290,7 @@ public class ANTLR extends Task {
if (targetIsOutOfDate) {
log("Compiling " + targetFile + " as it is newer than "
+ generatedFile, Project.MSG_VERBOSE);
} else if (superGrammarIsOutOfDate) {
} else {
log("Compiling " + targetFile + " as " + superGrammar
+ " is newer than " + generatedFile, Project.MSG_VERBOSE);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java View File

@@ -417,7 +417,7 @@ public class Depend extends MatchingTask {
}
classpathFileCache.put(dependency, classpathFileObject);
}
if (classpathFileObject != null && classpathFileObject != nullFileMarker) {
if (classpathFileObject != nullFileMarker) {
// we need to add this jar to the list for this class.
File jarFile = (File) classpathFileObject;
dependencies.put(jarFile, jarFile);


+ 1
- 1
src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java View File

@@ -150,7 +150,7 @@ public abstract class BaseResourceCollectionContainer
//first the easy way, if all children are filesystem-only, return true:
boolean goEarly = true;
for (Iterator i = rc.iterator(); goEarly && i.hasNext();) {
goEarly &= ((ResourceCollection) i.next()).isFilesystemOnly();
goEarly = ((ResourceCollection) i.next()).isFilesystemOnly();
}
if (goEarly) {
return true;


+ 5
- 7
src/main/org/apache/tools/ant/types/selectors/ContainsRegexpSelector.java View File

@@ -158,13 +158,11 @@ public class ContainsRegexpSelector extends BaseExtendSelector
} catch (IOException ioe) {
throw new BuildException("Could not read " + r.toLongString());
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
throw new BuildException("Could not close "
+ r.toLongString());
}
try {
in.close();
} catch (Exception e) {
throw new BuildException("Could not close "
+ r.toLongString());
}
}
}


+ 1
- 1
src/main/org/apache/tools/ant/util/ContainerMapper.java View File

@@ -83,7 +83,7 @@ public abstract class ContainerMapper implements FileNameMapper {
boolean foundit = false;
for (Iterator iter = mappers.iterator(); iter.hasNext() && !foundit;) {
FileNameMapper next = (FileNameMapper) (iter.next());
foundit |= (next == fileNameMapper
foundit = (next == fileNameMapper
|| (next instanceof ContainerMapper
&& ((ContainerMapper) next).contains(fileNameMapper)));
}


Loading…
Cancel
Save