PR: 14619 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274344 13f79535-47bb-0310-9956-ffa450edef68master
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2000-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 | ||||
@@ -144,7 +144,12 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||||
MatchResult mr = matcher.getMatch(); | MatchResult mr = matcher.getMatch(); | ||||
int cnt = mr.groups(); | int cnt = mr.groups(); | ||||
for (int i = 0; i < cnt; i++) { | for (int i = 0; i < cnt; i++) { | ||||
v.addElement(mr.group(i)); | |||||
String match = mr.group(i); | |||||
// treat non-matching groups as empty matches | |||||
if (match == null) { | |||||
match = ""; | |||||
} | |||||
v.addElement(match); | |||||
} | } | ||||
return v; | return v; | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2000-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 | ||||
@@ -133,7 +133,12 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||||
Vector v = new Vector(); | Vector v = new Vector(); | ||||
int cnt = reg.getParenCount(); | int cnt = reg.getParenCount(); | ||||
for (int i = 0; i < cnt; i++) { | for (int i = 0; i < cnt; i++) { | ||||
v.addElement(reg.getParen(i)); | |||||
String match = reg.getParen(i); | |||||
// treat non-matching groups as empty matches | |||||
if (match == null) { | |||||
match = ""; | |||||
} | |||||
v.addElement(match); | |||||
} | } | ||||
return v; | return v; | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001-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 | ||||
@@ -144,7 +144,12 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
Vector v = new Vector(); | Vector v = new Vector(); | ||||
int cnt = matcher.groupCount(); | int cnt = matcher.groupCount(); | ||||
for (int i = 0; i <= cnt; i++) { | for (int i = 0; i <= cnt; i++) { | ||||
v.addElement(matcher.group(i)); | |||||
String match = matcher.group(i); | |||||
// treat non-matching groups as empty matches | |||||
if (match == null) { | |||||
match = ""; | |||||
} | |||||
v.addElement(match); | |||||
} | } | ||||
return v; | return v; | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2000-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 | ||||
@@ -133,6 +133,16 @@ public abstract class RegexpMatcherTest extends TestCase { | |||||
assertEquals("b", (String) v.elementAt(2)); | assertEquals("b", (String) v.elementAt(2)); | ||||
} | } | ||||
public void testBugzillaReport14619() { | |||||
reg.setPattern("^(.*)/src/((.*/)*)([a-zA-Z0-9_\\.]+)\\.java$"); | |||||
Vector v = reg.getGroups("de/tom/src/Google.java"); | |||||
assertEquals(5, v.size()); | |||||
assertEquals("de/tom", v.elementAt(1)); | |||||
assertEquals("", v.elementAt(2)); | |||||
assertEquals("", v.elementAt(3)); | |||||
assertEquals("Google", v.elementAt(4)); | |||||
} | |||||
public void testCaseInsensitiveMatch() { | public void testCaseInsensitiveMatch() { | ||||
reg.setPattern("aaaa"); | reg.setPattern("aaaa"); | ||||
assertTrue("aaaa doesn't match AAaa", !reg.matches("AAaa")); | assertTrue("aaaa doesn't match AAaa", !reg.matches("AAaa")); | ||||