Browse Source

Make sure random component of names is always purely numeric - no negative signs

PR:	15399
Submitted by:	Rob Shafer


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273673 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
58f3cad4fb
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      src/main/org/apache/tools/ant/util/FileUtils.java

+ 6
- 5
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -706,7 +706,8 @@ public class FileUtils {
synchronized (rand) {
do {
result = new File(parent,
prefix + fmt.format(rand.nextInt())
prefix
+ fmt.format(rand.nextInt(Integer.MAX_VALUE))
+ suffix);
} while (result.exists());
}
@@ -924,14 +925,14 @@ public class FileUtils {
if (!path.startsWith("/")) {
sb.append("/");
}
} catch (BuildException e) {
// relative path
}
path = path.replace('\\', '/');
CharacterIterator iter = new StringCharacterIterator(path);
for (char c = iter.first(); c != CharacterIterator.DONE;
for (char c = iter.first(); c != CharacterIterator.DONE;
c = iter.next()) {
if (isSpecial[c]) {
sb.append('%');
@@ -972,7 +973,7 @@ public class FileUtils {

StringBuffer sb = new StringBuffer();
CharacterIterator iter = new StringCharacterIterator(uri);
for (char c = iter.first(); c != CharacterIterator.DONE;
for (char c = iter.first(); c != CharacterIterator.DONE;
c = iter.next()) {
if (c == '%') {
char c1 = iter.next();


Loading…
Cancel
Save