Browse Source

PathConvert on Windows should process forward and back slashes equivalently.

Bugzilla report 32884.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@454032 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
a5360da98a
4 changed files with 27 additions and 8 deletions
  1. +3
    -0
      WHATSNEW
  2. +18
    -5
      docs/manual/CoreTasks/pathconvert.html
  3. +5
    -2
      src/main/org/apache/tools/ant/taskdefs/PathConvert.java
  4. +1
    -1
      src/tests/antunit/taskdefs/pathconvert-test.xml

+ 3
- 0
WHATSNEW View File

@@ -48,6 +48,9 @@ Fixed bugs:
* junit4 did not work with fork=no and junit4 in $ANT_HOME/lib.
Bugzilla report 40697.

* PathConvert on Windows should process forward and back slashes equivalently.
Bugzilla report 32884.

Other changes:
--------------



+ 18
- 5
docs/manual/CoreTasks/pathconvert.html View File

@@ -107,9 +107,13 @@ drive letters to Unix paths, and vice-versa.</p>
</tr>
<tr>
<td valign="top">from</td>
<td valign="top">The prefix to match. Note that this value is case-insensitive when
the build is running on a Windows platform and case-sensitive when running on a
Unix platform.</td>
<td valign="top">
The prefix to match. Note that this value is case-insensitive when
the build is running on a Windows platform and case-sensitive
when running on a Unix platform.
<em>Since Ant 1.7.0</em>, on Windows this value is also insensitive
to the slash style used for directories, one can use '/' or '\'.
</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
@@ -197,8 +201,17 @@ it defaults to the appropriate character for the current platform. Such a list
then be used in another task, like <tt>javadoc</tt>, that requires a comma separated
list of files.
</p>


<h4>Example 4</h4>
<pre>
&lt;pathconvert property="prop" dirsep="|"&gt;
&lt;map from="${basedir}/abc/" to=''/&gt;
&lt;path location="abc/def/ghi"/&gt;
&lt;/pathconvert&gt;
</pre>
<p>
This example sets the property "prop" to "def|ghi" on
Windows and on Unix.
</p>
</body>
</html>



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

@@ -139,8 +139,11 @@ public class PathConvert extends Task {
+ "in a map entry");
}
// If we're on windows, then do the comparison ignoring case
String cmpElem = onWindows ? elem.toLowerCase() : elem;
String cmpFrom = onWindows ? from.toLowerCase() : from;
// and treat the two directory characters the same
String cmpElem =
onWindows ? elem.toLowerCase().replace('\\', '/') : elem;
String cmpFrom =
onWindows ? from.toLowerCase().replace('\\', '/') : from;

// If the element starts with the configured prefix, then
// convert the prefix to the configured 'to' value.


+ 1
- 1
src/tests/antunit/taskdefs/pathconvert-test.xml View File

@@ -3,7 +3,7 @@
<target name="test-dir-char">
<pathconvert property="def|ghi" dirsep="|">
<map from="${basedir}/abc/" to=''/>
<path path="${basedir}/abc/def/ghi"/>
<path location="abc/def/ghi"/>
</pathconvert>
<au:assertTrue>
<equals arg1="${def|ghi}" arg2="def|ghi"/>


Loading…
Cancel
Save