ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/etc/testcases/filters tokenfilter.xml
Date Wed, 28 May 2003 15:31:07 GMT
peterreilly    2003/05/28 08:31:07

  Modified:    src/main/org/apache/tools/ant/util/regexp
                        JakartaOroRegexp.java Jdk14RegexpRegexp.java
               src/testcases/org/apache/tools/ant/filters
                        TokenFilterTest.java
               src/etc/testcases/filters tokenfilter.xml
  Log:
  fix for bug 20306 - regex handling of $ in replace string
  
  Revision  Changes    Path
  1.10      +4 -1      ant/src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java
  
  Index: JakartaOroRegexp.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JakartaOroRegexp.java	10 Feb 2003 14:14:41 -0000	1.9
  +++ JakartaOroRegexp.java	28 May 2003 15:31:07 -0000	1.10
  @@ -76,7 +76,10 @@
           StringBuffer subst = new StringBuffer();
           for (int i = 0; i < argument.length(); i++) {
               char c = argument.charAt(i);
  -            if (c == '\\') {
  +            if (c == '$') {
  +                subst.append('\\');
  +                subst.append('$');
  +            } else if (c == '\\') {
                   if (++i < argument.length()) {
                       c = argument.charAt(i);
                       int value = Character.digit(c, 10);
  
  
  
  1.12      +4 -1      ant/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java
  
  Index: Jdk14RegexpRegexp.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Jdk14RegexpRegexp.java	10 Feb 2003 14:14:41 -0000	1.11
  +++ Jdk14RegexpRegexp.java	28 May 2003 15:31:07 -0000	1.12
  @@ -83,7 +83,10 @@
           StringBuffer subst = new StringBuffer();
           for (int i = 0; i < argument.length(); i++) {
               char c = argument.charAt(i);
  -            if (c == '\\') {
  +            if (c == '$') {
  +                subst.append('\\');
  +                subst.append('$');
  +            } else if (c == '\\') {
                   if (++i < argument.length()) {
                       c = argument.charAt(i);
                       int value = Character.digit(c, 10);
  
  
  
  1.3       +7 -1      ant/src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java
  
  Index: TokenFilterTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TokenFilterTest.java	15 Apr 2003 13:19:41 -0000	1.2
  +++ TokenFilterTest.java	28 May 2003 15:31:07 -0000	1.3
  @@ -77,7 +77,7 @@
       }
   
       public void tearDown() {
  -        //executeTarget("cleanup");
  +        executeTarget("cleanup");
       }
   
       /** make sure tokenfilter exists */
  @@ -147,6 +147,12 @@
           assertStringContains(contents, "world world world world");
       }
   
  +    public void testHandleDollerMatch() throws IOException {
  +        if (! hasRegex("testFilterReplaceRegex"))
  +            return;
  +        executeTarget("dollermatch");
  +    }
  +    
       public void testTrimFile() throws IOException {
           String contents = getFileString(
               "trimfile", "result/trimfile");
  
  
  
  1.3       +9 -0      ant/src/etc/testcases/filters/tokenfilter.xml
  
  Index: tokenfilter.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/filters/tokenfilter.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- tokenfilter.xml	15 Apr 2003 13:19:41 -0000	1.2
  +++ tokenfilter.xml	28 May 2003 15:31:07 -0000	1.3
  @@ -181,6 +181,15 @@
       </concat>
     </target>
   
  +  <target name="dollermatch">
  +    <concat>
  +      @hello@
  +      <filterchain>
  +        <replaceregex pattern="@([^@]*)@" replace="${\1}"/>
  +      </filterchain>
  +    </concat>
  +  </target>
  +
     <!-- need to check for existance of regex -->
     <target name="containsregex">
       <concat destfile="result/input">
  
  
  

Mime
View raw message