You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Frederic Pesquet <fp...@ilog.fr> on 2002/05/24 11:23:17 UTC
[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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [PATCH] a patch for 'org.apache.tools.ant.filters.LineContains' to work with large files
Posted by Magesh Umasankar <um...@apache.org>.
I will take care of this. Thanks for reporting the
problem as well as sending in a patch! The way you
have submitted the patch is correct - though we do
prefer if it gets submitted through BugZilla - so
that it doesn't get buried in somebody's mail-archive.
Cheers,
Magesh
***********************************************************
* Classic: A book which people praise, but do not read. *
***********************************************************
----- Original Message -----
From: "Frederic Pesquet" <fp...@ilog.fr>
To: "Ant Developers List" <an...@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: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [PATCH] a patch for 'org.apache.tools.ant.filters.LineContains' to work with large files
Posted by Frederic Pesquet <fp...@ilog.fr>.
Thanks Magesh.
I'll try to be carefull with indentation next time.
Regards,
Frederic
> -----Original Message-----
> From: Magesh Umasankar [mailto:umagesh@apache.org]
> Sent: Friday, May 24, 2002 3:55 PM
> To: Ant Developers List
> Subject: Re: [PATCH] a patch for
> 'org.apache.tools.ant.filters.LineContains' to work with large files
>
>
> 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" <fp...@ilog.fr>
> To: "Ant Developers List" <an...@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:
<ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [PATCH] a patch for 'org.apache.tools.ant.filters.LineContains' to work with large files
Posted by Magesh Umasankar <um...@apache.org>.
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" <fp...@ilog.fr>
To: "Ant Developers List" <an...@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: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>