ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/types CommandlineTest.java PathTest.java
Date Thu, 10 Aug 2000 08:42:31 GMT
bodewig     00/08/10 01:42:30

  Modified:    src/main/org/apache/tools/ant Project.java
               src/main/org/apache/tools/ant/types Commandline.java
               src/testcases/org/apache/tools/ant/types
                        CommandlineTest.java PathTest.java
  Log:
  \ is no special character for Commandline anymore.
  
  Also made Project.resolveFile more consistent. /a would have been an
  absolute filename on all platform while \a would be considered a
  relative filename on Unix like systems.
  
  Revision  Changes    Path
  1.34      +4 -3      jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Project.java	2000/08/04 13:30:53	1.33
  +++ Project.java	2000/08/10 08:42:29	1.34
  @@ -453,9 +453,10 @@
       }
   
       public File resolveFile(String fileName) {
  +        fileName = fileName.replace('/', File.separatorChar).replace('\\', File.separatorChar);
  +
           // deal with absolute files
  -        if (fileName.startsWith("/")) return new File( fileName );
  -        if (fileName.startsWith(System.getProperty("file.separator")))
  +        if (fileName.startsWith(File.separator)) 
               return new File( fileName );
   
           // Eliminate consecutive slashes after the drive spec
  @@ -488,7 +489,7 @@
           }
   
           File file = new File(baseDir.getAbsolutePath());
  -        StringTokenizer tok = new StringTokenizer(fileName, "/", false);
  +        StringTokenizer tok = new StringTokenizer(fileName, File.separator, false);
           while (tok.hasMoreTokens()) {
               String part = tok.nextToken();
               if (part.equals("..")) {
  
  
  
  1.9       +1 -16     jakarta-ant/src/main/org/apache/tools/ant/types/Commandline.java
  
  Index: Commandline.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/Commandline.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Commandline.java	2000/08/09 06:29:14	1.8
  +++ Commandline.java	2000/08/10 08:42:29	1.9
  @@ -265,7 +265,7 @@
           final int inQuote = 1;
           final int inDoubleQuote = 2;
           int state = normal;
  -        StringTokenizer tok = new StringTokenizer(to_process, "\\\"\' ", true);
  +        StringTokenizer tok = new StringTokenizer(to_process, "\"\' ", true);
           Vector v = new Vector();
           StringBuffer current = new StringBuffer();
   
  @@ -295,21 +295,6 @@
                       if (current.length() != 0) {
                           v.addElement(current.toString());
                           current.setLength(0);
  -                    }
  -                } else if ("\\".equals(nextTok)) {
  -                    if (tok.hasMoreTokens()) {
  -                        String escapedToken = tok.nextToken();
  -                        char escapedChar = escapedToken.charAt(0);
  -                        if (escapedChar == '\\' || escapedChar == '\'' ||
  -                            escapedChar == '\"') {
  -                            current.append(escapedToken);
  -                        }
  -                        else {
  -                            current.append("\\" + escapedToken);
  -                        }
  -                    } else {
  -                        // just add the backslash
  -                        current.append("\\");
                       }
                   } else {
                       current.append(nextTok);
  
  
  
  1.4       +7 -10     jakarta-ant/src/testcases/org/apache/tools/ant/types/CommandlineTest.java
  
  Index: CommandlineTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/CommandlineTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CommandlineTest.java	2000/08/07 11:17:12	1.3
  +++ CommandlineTest.java	2000/08/10 08:42:30	1.4
  @@ -111,17 +111,14 @@
           assertEquals("Single quotes stripped, double quote included", "2\"3",
                        s[1]);
   
  -        s = Commandline.translateCommandline("1 2\\\'3 4");
  -        assertEquals("Case with quoted single quote", 3, s.length);
  -        assertEquals("single quote included", "2\'3", s[1]);
  +        // \ doesn't have a special meaning anymore - this is different from
  +        // what the Unix sh does but causes a lot of problems on DOS
  +        // based platforms otherwise
  +        s = Commandline.translateCommandline("1 2\\ 3 4");
  +        assertEquals("case with quotes whitespace", 4, s.length);
  +        assertEquals("Single quotes stripped, double quote included", "2\\",
  +                     s[1]);
   
  -        s = Commandline.translateCommandline("1 2\\\"3 4");
  -        assertEquals("Case with quoted double quote", 3, s.length);
  -        assertEquals("double quote included", "2\"3", s[1]);
  -
  -        s = Commandline.translateCommandline("1 2\\\\3 4");
  -        assertEquals("Case with quoted backslash", 3, s.length);
  -        assertEquals("backslash included", "2\\3", s[1]);
   
           // now to the expected failures
           
  
  
  
  1.3       +4 -2      jakarta-ant/src/testcases/org/apache/tools/ant/types/PathTest.java
  
  Index: PathTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/PathTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PathTest.java	2000/08/02 09:24:24	1.2
  +++ PathTest.java	2000/08/10 08:42:30	1.3
  @@ -124,7 +124,8 @@
           l = p.list();
           if (isUnixStyle) {
               assertEquals("no drives on Unix", 2, l.length);
  -            assertEquals("c", l[0]);
  +            assert("c resolved relative to project\'s basedir", 
  +                   l[0].endsWith("/c"));
               assertEquals("/test", l[1]);
           } else {
               assertEquals("drives on DOS", 1, l.length);
  @@ -135,7 +136,8 @@
           l = p.list();
           if (isUnixStyle) {
               assertEquals("no drives on Unix", 2, l.length);
  -            assertEquals("c", l[0]);
  +            assert("c resolved relative to project\'s basedir", 
  +                   l[0].endsWith("/c"));
               assertEquals("/test", l[1]);
           } else {
               assertEquals("drives on DOS", 1, l.length);
  
  
  

Mime
View raw message