peterreilly    2004/01/07 02:10:36

  Modified:    src/main/org/apache/tools/ant/types FilterSet.java
               src/testcases/org/apache/tools/ant/taskdefs CopyTest.java
               src/etc/testcases/taskdefs copy.xml
  Log:
  Fix for error in inifinite loop checking in filtersets
  PR: 23154
  
  Revision  Changes    Path
  1.24      +5 -3      ant/src/main/org/apache/tools/ant/types/FilterSet.java
  
  Index: FilterSet.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/FilterSet.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- FilterSet.java    13 Aug 2003 15:14:31 -0000      1.23
  +++ FilterSet.java    7 Jan 2004 10:10:36 -0000       1.24
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -357,6 +357,8 @@
        * @return      The string with the tokens replaced.
        */
       public String replaceTokens(String line) {
  +        passedTokens = null; // reset for new line
  +        
           String beginToken = getBeginToken();
           String endToken = getEndToken();
           int index = line.indexOf(beginToken);
  @@ -415,7 +417,7 @@
        * This parses tokens which point to tokens.
        * It also maintains a list of currently used tokens, so we cannot
        * get into an infinite loop
  -     * @param value the value / token to parse
  +     * @param line the value / token to parse
        * @param parent the parant token (= the token it was parsed from)
        */
       private String replaceTokens(String line, String parent)
  @@ -426,7 +428,7 @@
           if (passedTokens.contains(parent) && !duplicateToken) {
               duplicateToken = true;
               StringBuffer sb = new StringBuffer();
  -            sb.append("Inifinite loop in tokens. Currently known tokens : ");
  +            sb.append("Infinite loop in tokens. Currently known tokens : ");
               sb.append(passedTokens);
               sb.append("\nProblem token : " + getBeginToken() + parent
                   + getEndToken());
  
  
  
  1.13      +6 -1      
ant/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java
  
  Index: CopyTest.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CopyTest.java     28 Mar 2003 07:33:05 -0000      1.12
  +++ CopyTest.java     7 Jan 2004 10:10:36 -0000       1.13
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2004 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -126,6 +126,11 @@
   
       }
   
  +    public void testFilterTest() {
  +        executeTarget("filtertest");
  +        assertTrue(getOutput().indexOf("loop in tokens") == -1);
  +    }
  +    
       public void testFilterSet() throws IOException {
           executeTarget("testFilterSet");
           FileUtils fileUtils = FileUtils.newFileUtils();
  
  
  
  1.12      +22 -0     ant/src/etc/testcases/taskdefs/copy.xml
  
  Index: copy.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/copy.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- copy.xml  28 Mar 2003 07:35:31 -0000      1.11
  +++ copy.xml  7 Jan 2004 10:10:36 -0000       1.12
  @@ -10,6 +10,24 @@
       <copy file="copy.xml" todir="copytest1dir" overwrite="true"/>
     </target>
   
  +  <target name="filtertest">
  +    <!-- check fix for bugzilla 23154 -->
  +    <delete quiet="yes" file="copy.filter.out"/>
  +    <delete quiet="yes" file="copy.filter.inp"/>
  +    <concat destfile="copy.filter.inp">
  +PRODUCT_VERSION=6.2.1.4
  +PRODUCT_BUILD=6.5 (BLD_65036)
  +PRODUCT_VERSION=6.2.1.4
  +PRODUCT_BUILD=6.5 (BLD_65036)
  +    </concat>
  +    <copy file="copy.filter.inp" tofile="copy.filter.out">
  +      <filterset begintoken="6" endtoken="4">
  +        <filter token=".2.1." value="2.6.4" />
  +      </filterset>
  +    </copy>
  +    <concat><path path="copy.filter.out"/></concat>
  +  </target>
  +
     <target name="test3">
       <!-- create an empty file -->
       <touch file="copytest3.tmp"/>
  @@ -89,6 +107,8 @@
       </copy>
     </target>
   
  +    
  +  
     <target name="cleanup"> 
       <delete file="copytest1.tmp"/>
       <delete file="copytest3.tmp"/>
  @@ -99,6 +119,8 @@
       <delete file="copy.filterset.tmp"/>
       <delete file="copy.filterchain.tmp"/>
       <delete dir="copytest1dir"/>
  +    <delete quiet="yes" file="copy.filter.out"/>
  +    <delete quiet="yes" file="copy.filter.inp"/>
     </target>
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to