ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Magesh Umasankar" <umag...@apache.org>
Subject Re: [PATCH] a patch for 'org.apache.tools.ant.filters.LineContains' to work with large files
Date Fri, 24 May 2002 13:54:32 GMT
Patched, thanks!

Please send your future patches with 4-space
indentations as we like the code that way.

Cheers,
Magesh

**********************************************
*  Philosopher: A fool who torments himself  *
*  during life, to be spoken of when dead.   *
**********************************************
----- Original Message -----
From: "Frederic Pesquet" <fpesquet@ilog.fr>
To: "Ant Developers List" <ant-dev@jakarta.apache.org>
Sent: Friday, May 24, 2002 5:23 AM
Subject: [PATCH] a patch for 'org.apache.tools.ant.filters.LineContains' to
work with large files


> Hello,
>
> The filter 'org.apache.tools.ant.filters.LineContains' does not work well
> with big files.
> There is a recursive call in read() to find a matching line, which causes
a
> stack overflow in the JVM when the file is too large.
> I've patched the code of read() so that the loop to find a matching line
> does not perform a recursive call.
> It works for me.
> Joined is the patch file of LineContains.java on the source of Ant1.5
beta1
> (=the current CVS source as far as I can see through the CVS Web
interface).
> Can someone integrate this patch in the source tree?
> Thanks,
> Frederic
>
> PS: this is the first time I submit a patch, please forgive me if this is
> not the right procedure: I just tried to follow the guidelines.
>
> --
> Frederic Pesquet - ILOG S.A. (Sophia-Antipolis)
> mail:fpesquet@ilog.fr
>
> *************************** diff file begin ***********************
> --- LineContains.java.orig Fri May 24 11:13:42 2002
> +++ LineContains.java Fri May 24 11:13:35 2002
> @@ -143,21 +143,25 @@
>                  line = line.substring(1);
>              }
>          } else {
> -            line = readLine();
> -            if (line == null) {
> -                ch = -1;
> -            } else {
> -                int containsSize = contains.size();
> -                for (int i = 0; i < containsSize; i++) {
> -                    String containsStr = (String) contains.elementAt(i);
> -                    if (line.indexOf(containsStr) == -1) {
> -                        line = null;
> -                        break;
> -                    }
> +          String goodLine=null;
> +          line = readLine();
> +          while((line!=null) && (goodLine==null))
> +          {
> +            goodLine=line;
> +            int containsSize = contains.size();
> +            for (int i = 0; i < containsSize; i++) {
> +                String containsStr = (String) contains.elementAt(i);
> +                if (line.indexOf(containsStr) == -1) {
> +                    goodLine = null;
> +                    break;
>                  }
> -
> -                return read();
>              }
> +            line = readLine();
> +          }
> +          if (goodLine != null) {
> +                line=goodLine;
> +                return read();
> +            };
>          }
>
>          return ch;
> *************************** diff file end ***********************
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message