ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant/util/regexp RegexpMatcherTest.java
Date Fri, 28 Mar 2003 14:52:24 GMT
bodewig     2003/03/28 06:52:24

  Modified:    src/main/org/apache/tools/ant/util/regexp
                        JakartaOroMatcher.java JakartaRegexpMatcher.java
                        Jdk14RegexpMatcher.java
               src/testcases/org/apache/tools/ant/util/regexp
                        RegexpMatcherTest.java
  Log:
  Insert empty strings instead of "null" for groups that didn't match.
  
  PR: 14619
  
  Revision  Changes    Path
  1.12      +7 -2      ant/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java
  
  Index: JakartaOroMatcher.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JakartaOroMatcher.java	7 Mar 2003 11:23:09 -0000	1.11
  +++ JakartaOroMatcher.java	28 Mar 2003 14:52:23 -0000	1.12
  @@ -1,7 +1,7 @@
   /*
    * 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.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -144,7 +144,12 @@
           MatchResult mr = matcher.getMatch();
           int cnt = mr.groups();
           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;
       }
  
  
  
  1.14      +7 -2      ant/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java
  
  Index: JakartaRegexpMatcher.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JakartaRegexpMatcher.java	7 Mar 2003 11:23:09 -0000	1.13
  +++ JakartaRegexpMatcher.java	28 Mar 2003 14:52:23 -0000	1.14
  @@ -1,7 +1,7 @@
   /*
    * 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.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -133,7 +133,12 @@
           Vector v = new Vector();
           int cnt = reg.getParenCount();
           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;
       }
  
  
  
  1.13      +7 -2      ant/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java
  
  Index: Jdk14RegexpMatcher.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Jdk14RegexpMatcher.java	7 Mar 2003 11:23:09 -0000	1.12
  +++ Jdk14RegexpMatcher.java	28 Mar 2003 14:52:23 -0000	1.13
  @@ -1,7 +1,7 @@
   /*
    * 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.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -144,7 +144,12 @@
           Vector v = new Vector();
           int cnt = matcher.groupCount();
           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;
       }
  
  
  
  1.15      +11 -1     ant/src/testcases/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java
  
  Index: RegexpMatcherTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- RegexpMatcherTest.java	7 Mar 2003 11:23:15 -0000	1.14
  +++ RegexpMatcherTest.java	28 Mar 2003 14:52:23 -0000	1.15
  @@ -1,7 +1,7 @@
   /*
    * 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.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -131,6 +131,16 @@
           assertEquals("aabb", (String) v.elementAt(0));
           assertEquals("aa", (String) v.elementAt(1));
           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() {
  
  
  

Mime
View raw message