for <linecontains>. PR: 15528 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274106 13f79535-47bb-0310-9956-ffa450edef68master
@@ -1 +1,4 @@ | |||||
This is line 2 with beta. | 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,3 +1,7 @@ | |||||
This is line 1 with alpha. | This is line 1 with alpha. | ||||
This is line 2 with beta. | 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,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * 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. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -143,10 +143,9 @@ public final class LineContains | |||||
} | } | ||||
} else { | } else { | ||||
line = readLine(); | 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++) { | for (int i = 0; i < containsSize; i++) { | ||||
String containsStr = (String) contains.elementAt(i); | String containsStr = (String) contains.elementAt(i); | ||||
if (line.indexOf(containsStr) == -1) { | if (line.indexOf(containsStr) == -1) { | ||||
@@ -155,6 +154,15 @@ public final class LineContains | |||||
} | } | ||||
} | } | ||||
if (line == null) { | |||||
// line didn't match | |||||
line = readLine(); | |||||
} else { | |||||
break; | |||||
} | |||||
} | |||||
if (line != null) { | |||||
return read(); | return read(); | ||||
} | } | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * 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. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -81,7 +81,8 @@ public class LineContainsTest extends BuildFileTest { | |||||
executeTarget("testLineContains"); | executeTarget("testLineContains"); | ||||
File expected = getProject().resolveFile("expected/linecontains.test"); | File expected = getProject().resolveFile("expected/linecontains.test"); | ||||
File result = getProject().resolveFile("result/linecontains.test"); | File result = getProject().resolveFile("result/linecontains.test"); | ||||
assertTrue(FileUtils.newFileUtils().contentEquals(expected, result)); | |||||
FileUtils fu = FileUtils.newFileUtils(); | |||||
assertTrue(fu.contentEquals(expected, result)); | |||||
} | } | ||||
} | } |