jakarta-regexp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@locus.apache.org
Subject cvs commit: jakarta-regexp/src/java/org/apache/regexp RE.java
Date Thu, 22 Jun 2000 20:39:03 GMT
jon         00/06/22 13:39:02

  Modified:    src/java/org/apache/regexp RE.java
  Log:
  If I create a regular expression using the expression "foo" with case
  independence turned on, the RE class will not match "Foo", nor will it
  match
  "the Foo".
  
  The problem seems to be related to some "prefix optimization" code I
  found.
  If a prefix match is to be performed, the code does not match the prefix
  when the case independent flag is on.
  
  Kurt Westerfeld <kurt@ManagedObjects.com>
  
  Revision  Changes    Path
  1.5       +13 -3     jakarta-regexp/src/java/org/apache/regexp/RE.java
  
  Index: RE.java
  ===================================================================
  RCS file: /home/cvs/jakarta-regexp/src/java/org/apache/regexp/RE.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RE.java	2000/05/26 18:13:46	1.4
  +++ RE.java	2000/06/22 20:39:01	1.5
  @@ -347,7 +347,7 @@
    * @see RECompiler
    *
    * @author <a href="mailto:jonl@muppetlabs.com">Jonathan Locke</a>
  - * @version $Id: RE.java,v 1.4 2000/05/26 18:13:46 jon Exp $
  + * @version $Id: RE.java,v 1.5 2000/06/22 20:39:01 jon Exp $
    */
   public class RE
   {
  @@ -1488,11 +1488,17 @@
           else
           {
               // Prefix-anchored matching is possible
  +            boolean caseIndependent = (matchFlags & MATCH_CASEINDEPENDENT) != 0;
               char[] prefix = program.prefix;
               for ( ;! search.isEnd(i + prefix.length - 1); i++)
               {
                   // If the first character of the prefix matches
  -                if (search.charAt(i) == prefix[0])
  +                boolean match = false;
  +                if (caseIndependent)
  +                    match = Character.toLowerCase(search.charAt(i)) == Character.toLowerCase(prefix[0]);
  +                else
  +                    match = search.charAt(i) == prefix[0];
  +                if (match)
                   {
                       // Save first character position
                       int firstChar = i++;
  @@ -1500,7 +1506,11 @@
                       for (k = 1; k < prefix.length; )
                       {
                           // If there's a mismatch of any character in the prefix, give up
  -                        if (search.charAt(i++) != prefix[k++])
  +                        if (caseIndependent)
  +                            match = Character.toLowerCase(search.charAt(i++)) == Character.toLowerCase(prefix[k++]);
  +                        else
  +                            match = search.charAt(i++) == prefix[k++];
  +                        if (!match)
                           {
                               break;
                           }
  
  
  

Mime
View raw message