bodewig 2003/03/19 02:09:38
Modified: . WHATSNEW src/main/org/apache/tools/tar TarEntry.java Log: TarEntry's File-constructor didn't work for many OSes. PR: 18105 At the same time, make the OS check Locale independent. Revision Changes Path 1.367 +4 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.366 retrieving revision 1.367 diff -u -r1.366 -r1.367 --- WHATSNEW 14 Mar 2003 16:01:03 -0000 1.366 +++ WHATSNEW 19 Mar 2003 10:09:38 -0000 1.367 @@ -66,6 +66,10 @@ * <exec> output and error streams can now be redirected independently to either a property or a file (or both) +* TarEntry's File-arg constructor would fail with a + StringIndexOutOfBoundsException on all OSes where os.name is shorter + than seven characters. Bugzilla Report 18105. + Other changes: -------------- * The filesetmanifest attribute of <jar> has been reenabled. 1.15 +5 -6 ant/src/main/org/apache/tools/tar/TarEntry.java Index: TarEntry.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/tar/TarEntry.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- TarEntry.java 10 Feb 2003 14:14:42 -0000 1.14 +++ TarEntry.java 19 Mar 2003 10:09:38 -0000 1.15 @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,6 +61,7 @@ import java.io.File; import java.util.Date; +import java.util.Locale; /** * This class represents an entry in a Tar archive. It consists @@ -200,16 +201,14 @@ this.file = file; String name = file.getPath(); - String osname = System.getProperty("os.name"); + String osname = System.getProperty("os.name").toLowerCase(Locale.US); if (osname != null) { // Strip off drive letters! // REVIEW Would a better check be "(File.separator == '\')"? - String win32Prefix = "Windows"; - String prefix = osname.substring(0, win32Prefix.length()); - if (prefix.equalsIgnoreCase(win32Prefix)) { + if (osname.startsWith("windows")) { if (name.length() > 2) { char ch1 = name.charAt(0); char ch2 = name.charAt(1); @@ -220,7 +219,7 @@ name = name.substring(2); } } - } else if (osname.toLowerCase().indexOf("netware") > -1) { + } else if (osname.indexOf("netware") > -1) { int colon = name.indexOf(':'); if (colon != -1) { name = name.substring(colon + 1);