From 02307f7dea1fb0177a13e50d7037c0f6286de1e7 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 23 Jun 2003 14:56:32 +0000 Subject: [PATCH] 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 --- WHATSNEW | 3 +++ .../org/apache/tools/ant/taskdefs/Expand.java | 20 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 0b7db89f9..7fd8d0657 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -165,6 +165,9 @@ Fixed bugs: Prevent the task from being blocked by error messages coming from java2iiop. Bugzilla Report 19385. +* 's and '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. diff --git a/src/main/org/apache/tools/ant/taskdefs/Expand.java b/src/main/org/apache/tools/ant/taskdefs/Expand.java index 85848bd03..7a5441f5d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Expand.java +++ b/src/main/org/apache/tools/ant/taskdefs/Expand.java @@ -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; }