From e2ca50cce1c1d277d17d23a0d4682e48310ded10 Mon Sep 17 00:00:00 2001
From: Diane Holt
Date: Mon, 1 Apr 2002 08:14:33 +0000
Subject: [PATCH] Allow 'dirsep' and 'pathsep' to contain multi-character
values. (Submitted by M. Kerkhoff, PR 6543) PR: Obtained from: Submitted by:
Reviewed by:
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272149 13f79535-47bb-0310-9956-ffa450edef68
---
docs/manual/CoreTasks/pathconvert.html | 6 +++--
.../tools/ant/taskdefs/PathConvert.java | 26 ++++++++++++++++---
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/docs/manual/CoreTasks/pathconvert.html b/docs/manual/CoreTasks/pathconvert.html
index 4f8daa6e5..a53e384cf 100644
--- a/docs/manual/CoreTasks/pathconvert.html
+++ b/docs/manual/CoreTasks/pathconvert.html
@@ -43,14 +43,16 @@ drive letters to Unix paths, and vice-versa.
dirsep |
- The character to use as the directory separator in the generated paths.
+ The character(s) to use as the directory separator in the
+ generated paths.
|
No, defaults to current JVM File.separator |
pathsep |
- The character to use as the path element separator in the generated paths.
+ The character(s) to use as the path-element separator in the
+ generated paths.
|
No, defaults to current JVM File.pathSeparator |
diff --git a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
index 271df93f0..cb588a0f8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
+++ b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
@@ -63,6 +63,7 @@ import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.DirSet;
import org.apache.tools.ant.types.FileList;
+import java.util.StringTokenizer;
import java.util.Vector;
import java.io.File;
@@ -267,8 +268,10 @@ public class PathConvert extends Task {
(osname.indexOf("netware") >= 0) );
// Determine the from/to char mappings for dir sep
- char fromDirSep = onWindows ? '\\' : '/';
- char toDirSep = dirSep.charAt(0);
+// char fromDirSep = onWindows ? '\\' : '/';
+// char toDirSep = dirSep.charAt(0);
+
+ String fromDirSep = onWindows ? "\\" : "/";
StringBuffer rslt = new StringBuffer( 100 );
@@ -280,15 +283,30 @@ public class PathConvert extends Task {
elem = mapElement( elem ); // Apply the path prefix map
+
// Now convert the path and file separator characters from the
// current os to the target os.
- elem = elem.replace( fromDirSep, toDirSep );
+// elem = elem.replace( fromDirSep, toDirSep );
if( i != 0 ) {
rslt.append( pathSep );
}
- rslt.append( elem );
+// rslt.append( elem );
+
+ StringTokenizer stDirectory = new StringTokenizer(elem, fromDirSep, true);
+ String token = null;
+
+ while ( stDirectory.hasMoreTokens() ) {
+ token = stDirectory.nextToken();
+
+ if (fromDirSep.equals(token)) {
+ rslt.append( dirSep );
+ }
+ else {
+ rslt.append( token );
+ }
+ }
}
// Place the result into the specified property