[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-oro-dev
Subject:    cvs commit: jakarta-oro/src/java/org/apache/oro/text/regex Perl5MatchResult.java Perl5Matcher.java
From:       dfs () apache ! org
Date:       2002-06-27 22:38:20
[Download RAW message or body]

dfs         2002/06/27 15:38:20

  Modified:    src/java/org/apache/oro/text/regex Perl5MatchResult.java
                        Perl5Matcher.java
  Log:
  Applied fix for Bug report 9556 concerning storig of captured group
  offests when capturing parentheses occur inside of a lookahead
  assertion figuring it will only get tested if it's applied.
  
  Revision  Changes    Path
  1.5       +6 -2      jakarta-oro/src/java/org/apache/oro/text/regex/Perl5MatchResult.java
  
  Index: Perl5MatchResult.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/regex/Perl5MatchResult.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Perl5MatchResult.java	17 May 2001 21:59:33 -0000	1.4
  +++ Perl5MatchResult.java	27 Jun 2002 22:38:20 -0000	1.5
  @@ -125,7 +125,11 @@
      * @return The length of the match.
      */
     public int length(){
  -    return _match.length();
  +    int length;
  +
  +    length = (_endGroupOffset[0] - _beginGroupOffset[0]);
  +
  +    return (length > 0 ? length : 0);
     }
   
   
  
  
  
  1.19      +10 -8     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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Perl5Matcher.java	25 Jan 2002 09:32:28 -0000	1.18
  +++ Perl5Matcher.java	27 Jun 2002 22:38:20 -0000	1.19
  @@ -241,7 +241,7 @@
     // Set the match result information.  Only call this if we successfully
     // matched.
     private void __setLastMatchResult() {
  -    int offs;
  +    int offs, maxEndOffs = 0;
   
       //endOffset+=dontTry;
   
  @@ -251,10 +251,6 @@
       if(__endMatchOffsets[0] > __originalInput.length)
         throw new ArrayIndexOutOfBoundsException();
   
  -    __lastMatchResult._match =
  -      new String(__originalInput, __beginMatchOffsets[0],
  -		 __endMatchOffsets[0] - __beginMatchOffsets[0]);
  -
       __lastMatchResult._matchBeginOffset = __beginMatchOffsets[0];
   
       while(__numParentheses >= 0) {
  @@ -269,15 +265,21 @@
   
         offs = __endMatchOffsets[__numParentheses];
   
  -      if(offs >= 0)
  +      if(offs >= 0) {
   	__lastMatchResult._endGroupOffset[__numParentheses] =
   	  offs - __lastMatchResult._matchBeginOffset;
  -      else
  +	if(offs > maxEndOffs && offs <= __originalInput.length)
  +	  maxEndOffs = offs;
  +      } else
   	__lastMatchResult._endGroupOffset[__numParentheses] =
   	  OpCode._NULL_OFFSET;
   
         --__numParentheses;
       }
  +
  +    __lastMatchResult._match =
  +      new String(__originalInput, __beginMatchOffsets[0],
  +		 maxEndOffs - __beginMatchOffsets[0]);
   
       // Free up for garbage collection
       __originalInput = null;
  
  
  

--
To unsubscribe, e-mail:   <mailto:oro-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:oro-dev-help@jakarta.apache.org>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic