Browse Source

Make Expand behave like DirectoryScanner if a pattern ends with a

trailing slash or backslash.

PR: 20696


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274692 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
02307f7dea
2 changed files with 20 additions and 3 deletions
  1. +3
    -0
      WHATSNEW
  2. +17
    -3
      src/main/org/apache/tools/ant/taskdefs/Expand.java

+ 3
- 0
WHATSNEW View File

@@ -165,6 +165,9 @@ Fixed bugs:
Prevent the task from being blocked by error messages coming from java2iiop.
Bugzilla Report 19385.

* <unzip>'s and <untar>'s nested patternsets didn't work as documented
when the pattern ended in a slash or backslash. Bugzilla Report 20969.

Other changes:
--------------
* Six new Clearcase tasks added.


+ 17
- 3
src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -72,6 +72,7 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;
import org.apache.tools.ant.types.selectors.SelectorUtils;
import org.apache.tools.ant.util.FileUtils;

/**
@@ -213,7 +214,8 @@ public class Expand extends Task {
throws IOException {

if (patternsets != null && patternsets.size() > 0) {
String name = entryName;
String name = entryName.replace('/', File.separatorChar)
.replace('\\', File.separatorChar);
boolean included = false;
for (int v = 0; v < patternsets.size(); v++) {
PatternSet p = (PatternSet) patternsets.elementAt(v);
@@ -224,7 +226,13 @@ public class Expand extends Task {
}
for (int w = 0; w < incls.length; w++) {
included = DirectoryScanner.match(incls[w], name);
String pattern = incls[w].replace('/', File.separatorChar)
.replace('\\', File.separatorChar);
if (pattern.endsWith(File.separator)) {
pattern += "**";
}
included = SelectorUtils.matchPath(pattern, name);
if (included) {
break;
}
@@ -238,7 +246,13 @@ public class Expand extends Task {
String[] excls = p.getExcludePatterns(getProject());
if (excls != null) {
for (int w = 0; w < excls.length; w++) {
included = !(DirectoryScanner.match(excls[w], name));
String pattern = excls[w]
.replace('/', File.separatorChar)
.replace('\\', File.separatorChar);
if (pattern.endsWith(File.separator)) {
pattern += "**";
}
included = !(SelectorUtils.matchPath(pattern, name));
if (!included) {
break;
}


Loading…
Cancel
Save