bodewig     2003/02/18 06:12:41

  Modified:    src/main/org/apache/tools/ant/filters Tag: ANT_15_BRANCH
                        LineContains.java LineContainsRegExp.java
                        StripLineComments.java
  Log:
  Merge fix for 15528 from HEAD
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.7   +3 -3      
ant/src/main/org/apache/tools/ant/filters/LineContains.java
  
  Index: LineContains.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/filters/LineContains.java,v
  retrieving revision 1.4.2.6
  retrieving revision 1.4.2.7
  diff -u -r1.4.2.6 -r1.4.2.7
  --- LineContains.java 17 Feb 2003 15:49:18 -0000      1.4.2.6
  +++ LineContains.java 18 Feb 2003 14:12:41 -0000      1.4.2.7
  @@ -72,9 +72,9 @@
    *
    * Or:
    *
  - * <pre>&lt;filterreader 
classname="org.apache.tools.ant.filters.LineContains"&gt;
  - *    &lt;param type="contains" value="foo"/&gt;
  - *    &lt;param type="contains" value="bar"/&gt;
  + * <pre>&lt;filterreader 
classname=&quot;org.apache.tools.ant.filters.LineContains&quot;&gt;
  + *    &lt;param type=&quot;contains&quot; value=&quot;foo&quot;/&gt;
  + *    &lt;param type=&quot;contains&quot; value=&quot;bar&quot;/&gt;
    * &lt;/filterreader&gt;</pre>
    *
    * This will include only those lines that contain <code>foo</code> and
  
  
  
  1.4.2.3   +17 -9     
ant/src/main/org/apache/tools/ant/filters/LineContainsRegExp.java
  
  Index: LineContainsRegExp.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/filters/LineContainsRegExp.java,v
  retrieving revision 1.4.2.2
  retrieving revision 1.4.2.3
  diff -u -r1.4.2.2 -r1.4.2.3
  --- LineContainsRegExp.java   10 Feb 2003 14:24:40 -0000      1.4.2.2
  +++ LineContainsRegExp.java   18 Feb 2003 14:12:41 -0000      1.4.2.3
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -89,7 +89,7 @@
       /** Vector that holds the expressions that input lines must contain. */
       private Vector regexps = new Vector();
   
  -    /** 
  +    /**
        * Remaining line to be read from this filter, or <code>null</code> if
        * the next call to <code>read()</code> should read the original stream
        * to find the next matching line.
  @@ -98,7 +98,7 @@
   
       /**
        * Constructor for "dummy" instances.
  -     * 
  +     *
        * @see BaseFilterReader#BaseFilterReader()
        */
       public LineContainsRegExp() {
  @@ -122,9 +122,9 @@
        * 
        * @return the next character in the resulting stream, or -1
        * if the end of the resulting stream has been reached
  -     * 
  +     *
        * @exception IOException if the underlying stream throws an IOException
  -     * during reading     
  +     * during reading
        */
       public final int read() throws IOException {
           if (!getInitialized()) {
  @@ -143,10 +143,9 @@
               }
           } else {
               line = readLine();
  -            if (line == null) {
  -                ch = -1;
  -            } else {
  -                final int regexpsSize = regexps.size();
  +            final int regexpsSize = regexps.size();
  +
  +            while (line != null) {
                   for (int i = 0; i < regexpsSize; i++) {
                       RegularExpression regexp = (RegularExpression)
                                                           regexps.elementAt(i);
  @@ -158,6 +157,15 @@
                       }
                   }
   
  +                if (line == null) {
  +                    // line didn't match
  +                    line = readLine();
  +                } else {
  +                    break;
  +                }
  +            }
  +
  +            if (line != null) {
                   return read();
               }
           }
  
  
  
  1.4.2.3   +14 -5     
ant/src/main/org/apache/tools/ant/filters/StripLineComments.java
  
  Index: StripLineComments.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/filters/StripLineComments.java,v
  retrieving revision 1.4.2.2
  retrieving revision 1.4.2.3
  diff -u -r1.4.2.2 -r1.4.2.3
  --- StripLineComments.java    10 Feb 2003 14:24:40 -0000      1.4.2.2
  +++ StripLineComments.java    18 Feb 2003 14:12:41 -0000      1.4.2.3
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -143,10 +143,9 @@
               }
           } else {
               line = readLine();
  -            if (line == null) {
  -                ch = -1;
  -            } else {
  -                int commentsSize = comments.size();
  +            final int commentsSize = comments.size();
  +
  +            while (line != null) {
                   for (int i = 0; i < commentsSize; i++) {
                       String comment = (String) comments.elementAt(i);
                       if (line.startsWith(comment)) {
  @@ -154,6 +153,16 @@
                           break;
                       }
                   }
  +
  +                if (line == null) {
  +                    // line started with comment
  +                    line = readLine();
  +                } else {
  +                    break;
  +                }
  +            }
  +
  +            if (line != null) {
                   return read();
               }
           }
  
  
  

Reply via email to