You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2003/02/17 16:47:46 UTC
cvs commit: ant/src/testcases/org/apache/tools/ant/filters LineContainsTest.java
bodewig 2003/02/17 07:47:46
Modified: src/etc/testcases/filters/expected linecontains.test
src/etc/testcases/filters/input linecontains.test
src/main/org/apache/tools/ant/filters LineContains.java
src/testcases/org/apache/tools/ant/filters
LineContainsTest.java
Log:
Use a non-recursive (well, less recursive, max depth is 2) approach
for <linecontains>.
PR: 15528
Revision Changes Path
1.2 +3 -0 ant/src/etc/testcases/filters/expected/linecontains.test
Index: linecontains.test
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/filters/expected/linecontains.test,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- linecontains.test 30 Sep 2002 12:08:20 -0000 1.1
+++ linecontains.test 17 Feb 2003 15:47:45 -0000 1.2
@@ -1 +1,4 @@
This is line 2 with beta.
+This is line 3 with beta.
+This is line 5 with beta.
+This is line 7 with beta.
1.2 +5 -1 ant/src/etc/testcases/filters/input/linecontains.test
Index: linecontains.test
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/filters/input/linecontains.test,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- linecontains.test 30 Sep 2002 12:08:20 -0000 1.1
+++ linecontains.test 17 Feb 2003 15:47:45 -0000 1.2
@@ -1,3 +1,7 @@
This is line 1 with alpha.
This is line 2 with beta.
-This is line 3 with gamma.
+This is line 3 with beta.
+This is line 4 with gamma.
+This is line 5 with beta.
+This is line 6 with delta.
+This is line 7 with beta.
1.11 +13 -5 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- LineContains.java 10 Feb 2003 14:13:32 -0000 1.10
+++ LineContains.java 17 Feb 2003 15:47:45 -0000 1.11
@@ -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 {
- final int containsSize = contains.size();
+ final int containsSize = contains.size();
+
+ while (line != null) {
for (int i = 0; i < containsSize; i++) {
String containsStr = (String) contains.elementAt(i);
if (line.indexOf(containsStr) == -1) {
@@ -155,6 +154,15 @@
}
}
+ if (line == null) {
+ // line didn't match
+ line = readLine();
+ } else {
+ break;
+ }
+ }
+
+ if (line != null) {
return read();
}
}
1.3 +3 -2 ant/src/testcases/org/apache/tools/ant/filters/LineContainsTest.java
Index: LineContainsTest.java
===================================================================
RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/filters/LineContainsTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LineContainsTest.java 10 Feb 2003 14:14:45 -0000 1.2
+++ LineContainsTest.java 17 Feb 2003 15:47:45 -0000 1.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
@@ -81,7 +81,8 @@
executeTarget("testLineContains");
File expected = getProject().resolveFile("expected/linecontains.test");
File result = getProject().resolveFile("result/linecontains.test");
- assertTrue(FileUtils.newFileUtils().contentEquals(expected, result));
+ FileUtils fu = FileUtils.newFileUtils();
+ assertTrue(fu.contentEquals(expected, result));
}
}