You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-dev@jakarta.apache.org by jo...@locus.apache.org on 2000/09/02 08:28:35 UTC

cvs commit: jakarta-oro/src/java/org/apache/oro/text/regex Perl5Compiler.java Perl5Matcher.java Perl5Pattern.java

jon         00/09/01 23:28:35

  Modified:    src/java/org/apache/oro/text/regex Perl5Compiler.java
                        Perl5Matcher.java Perl5Pattern.java
  Log:
  Dan Lipofsky <dl...@kurion.com> wrote:
  >I am trying to use ^ and $ with a multiline string.
  >Passing Perl5Compiler.MULTILINE_MASK to the compile
  >method seems to have no effect.  However, doing
  >setMultiline(true) on the matcher seems to work.
  >Is this a known bug?
  
  Without a code example, I can't tell what you mean when you say it
  doesn't work.  Perl5Compiler.MULTILINE_MASK corresponds to the Perl5
  /m modifier and setMultiline(true) corresponds to the Perl $* variable.
  It's possible a bug may have been introduced that wasn't present in
  OROMatcher when it was being converted to Jakarta-ORO because the
  default behavior of ^, $, and . was changed to match that of Perl because
  it deviated slightly through an oversight.
  
  ....
  
  After a quick test it looks like the behavior ^ with MULTILINE_MASK
  got messed up in the transition to Jakarta-ORO.
  
  daniel
  
  Revision  Changes    Path
  1.3       +7 -2      jakarta-oro/src/java/org/apache/oro/text/regex/Perl5Compiler.java
  
  Index: Perl5Compiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/regex/Perl5Compiler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Perl5Compiler.java	2000/07/23 23:25:26	1.2
  +++ Perl5Compiler.java	2000/09/02 06:28:34	1.3
  @@ -65,7 +65,7 @@
    * information about Perl5 regular expressions.
   
    @author <a href="mailto:dfs@savarese.org">Daniel F. Savarese</a>
  - @version $Id: Perl5Compiler.java,v 1.2 2000/07/23 23:25:26 jon Exp $
  + @version $Id: Perl5Compiler.java,v 1.3 2000/09/02 06:28:34 jon Exp $
   
    * @see PatternCompiler
    * @see MalformedPatternException
  @@ -1541,7 +1541,12 @@
   	else if(op == OpCode._BOUND || op == OpCode._NBOUND)
   	  regexp._startClassOffset = first;
   	else if(OpCode._opType[op] == OpCode._BOL) {
  -	  regexp._anchor = Perl5Pattern._OPT_ANCH;
  +	  if(op == OpCode._BOL)
  +	    regexp._anchor = Perl5Pattern._OPT_ANCH_BOL;
  +	  else if(op == OpCode._MBOL)
  +	    regexp._anchor = Perl5Pattern._OPT_ANCH_MBOL;
  +	  else
  +	    regexp._anchor = Perl5Pattern._OPT_ANCH;
   	  first = OpCode._getNextOperator(first);
   	  doItAgain = true;
   	  continue;
  
  
  
  1.3       +6 -2      jakarta-oro/src/java/org/apache/oro/text/regex/Perl5Matcher.java
  
  Index: Perl5Matcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/regex/Perl5Matcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Perl5Matcher.java	2000/07/23 23:25:26	1.2
  +++ Perl5Matcher.java	2000/09/02 06:28:34	1.3
  @@ -66,7 +66,7 @@
    * Perl5Compiler.
   
    @author <a href="mailto:dfs@savarese.org">Daniel F. Savarese</a>
  - @version $Id: Perl5Matcher.java,v 1.2 2000/07/23 23:25:26 jon Exp $
  + @version $Id: Perl5Matcher.java,v 1.3 2000/09/02 06:28:34 jon Exp $
   
    * @see PatternMatcher
    * @see Perl5Compiler
  @@ -292,7 +292,10 @@
   
         if(mustString != null &&
   	 ((expression._anchor & Perl5Pattern._OPT_ANCH) == 0 ||
  -	  (__multiline && expression._back >= 0))) {
  +	  ((__multiline || 
  +	   (expression._anchor & Perl5Pattern._OPT_ANCH_MBOL) != 0)
  +	   && expression._back >= 0)))
  +	{
   
   	__currentOffset =
   	  __findFirst(__input, __currentOffset, endOffset, mustString);
  @@ -326,6 +329,7 @@
   	  success = true;
   	  break _mainLoop;
   	} else if(__multiline ||
  +		  (expression._anchor & Perl5Pattern._OPT_ANCH_MBOL) != 0 ||
   		  (expression._anchor & Perl5Pattern._OPT_IMPLICIT) != 0) {
   
   	  if(minLength > 0)
  
  
  
  1.3       +7 -2      jakarta-oro/src/java/org/apache/oro/text/regex/Perl5Pattern.java
  
  Index: Perl5Pattern.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/regex/Perl5Pattern.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Perl5Pattern.java	2000/07/23 23:25:27	1.2
  +++ Perl5Pattern.java	2000/09/02 06:28:34	1.3
  @@ -73,13 +73,18 @@
    * saved to disk if desired.
   
    @author <a href="mailto:dfs@savarese.org">Daniel F. Savarese</a>
  - @version $Id: Perl5Pattern.java,v 1.2 2000/07/23 23:25:27 jon Exp $
  + @version $Id: Perl5Pattern.java,v 1.3 2000/09/02 06:28:34 jon Exp $
   
    * @see Perl5Compiler
    * @see Perl5Matcher
    */
   public final class Perl5Pattern implements Pattern, Serializable, Cloneable {
  -  static final int _OPT_ANCH = 1, _OPT_SKIP = 2, _OPT_IMPLICIT = 4;
  +  static final int
  +    _OPT_ANCH_BOL  = 0x01,
  +    _OPT_ANCH_MBOL = 0x02,
  +    _OPT_SKIP      = 0x04,
  +    _OPT_IMPLICIT  = 0x08;
  +  static final int _OPT_ANCH = (_OPT_ANCH_BOL | _OPT_ANCH_MBOL);
   
     String _expression;
     char[] _program;