cvs commit: jakarta-oro/src/java/org/apache/oro/util CacheLRU.java

[email protected]
Newsgroups gmane.comp.jakarta.oro.devel
Message-ID <[email protected]>
dfs         2002/11/20 13:31:03

  Modified:    src/java/examples substituteExample.java
               src/java/examples/awk substituteExample.java
               src/java/org/apache/oro/text/awk AwkCompiler.java
                        AwkMatcher.java SyntaxTree.java
               src/java/org/apache/oro/text/regex Perl5Compiler.java
                        Perl5Matcher.java Perl5Substitution.java Util.java
               src/java/org/apache/oro/util CacheLRU.java
  Log:
  Took care of some code rot and eliminated a bunch of unused variables that
  had crept into the code as it evolved.  Used Tom Copeland's PMD tool run
  data at http://pmd.sourceforge.net/cgi-bin/webpmd.pl to find the spots.
  
  Revision  Changes    Path
  1.6       +2 -2      jakarta-oro/src/java/examples/substituteExample.java
  
  Index: substituteExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/examples/substituteExample.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- substituteExample.java	1 Feb 2002 01:38:58 -0000	1.5
  +++ substituteExample.java	20 Nov 2002 21:31:02 -0000	1.6
  @@ -99,7 +99,7 @@
      *
      */
     public static final void main(String args[]) {
  -    int limit, interps, i;
  +    int limit, interps;
       PatternMatcher matcher = new Perl5Matcher();
       Pattern pattern = null;
       PatternCompiler compiler = new Perl5Compiler();
  
  
  
  1.5       +2 -2      jakarta-oro/src/java/examples/awk/substituteExample.java
  
  Index: substituteExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/examples/awk/substituteExample.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- substituteExample.java	20 May 2001 23:55:16 -0000	1.4
  +++ substituteExample.java	20 Nov 2002 21:31:02 -0000	1.5
  @@ -94,7 +94,7 @@
      *          java substituteExample '1' '4' '381298175 1111'
      */
     public static final void main(String args[]) {
  -    int limit, interps, i;
  +    int limit;
       PatternMatcher matcher = new AwkMatcher();
       Pattern pattern = null;
       PatternCompiler compiler = new AwkCompiler();
  
  
  
  1.6       +4 -2      jakarta-oro/src/java/org/apache/oro/text/awk/AwkCompiler.java
  
  Index: AwkCompiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/awk/AwkCompiler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AwkCompiler.java	20 May 2001 23:55:21 -0000	1.5
  +++ AwkCompiler.java	20 Nov 2002 21:31:03 -0000	1.6
  @@ -172,6 +172,9 @@
   
     static final char _END_OF_INPUT = '\uFFFF';
     
  +  // All of these are initialized by the compile() and _parse() methods
  +  // so there is no need or use in initializing them in the constructor
  +  // although this may change in the future.
     private boolean __inCharacterClass, __caseSensitive, __multiline;
     private boolean __beginAnchor, __endAnchor;
     private char __lookahead;
  @@ -341,7 +344,6 @@
     private SyntaxNode __repetition(SyntaxNode atom)
       throws MalformedPatternException {
       int min, max, startPosition[];
  -    StringBuffer minBuffer, maxBuffer;
       SyntaxNode root = null;
       CatNode catNode;
   
  
  
  
  1.8       +2 -4      jakarta-oro/src/java/org/apache/oro/text/awk/AwkMatcher.java
  
  Index: AwkMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/awk/AwkMatcher.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AwkMatcher.java	30 Oct 2002 17:49:10 -0000	1.7
  +++ AwkMatcher.java	20 Nov 2002 21:31:03 -0000	1.8
  @@ -633,7 +633,7 @@
   
   
     private int __streamMatchPrefix() throws IOException {
  -    int token, current = AwkPattern._START_STATE, lastState, transition;
  +    int token, current = AwkPattern._START_STATE, lastState;
       int offset, initialOffset, maxOffset;
       int lastMatchedOffset = -1;
       int[] tstateArray;
  @@ -696,9 +696,7 @@
   
   
      void _search() throws IOException {
  -    char[] currentLine;
       int position, tokensMatched;
  -    String currentString;
   
       __lastMatchResult = null;
   
  
  
  
  1.5       +1 -2      jakarta-oro/src/java/org/apache/oro/text/awk/SyntaxTree.java
  
  Index: SyntaxTree.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/awk/SyntaxTree.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SyntaxTree.java	20 May 2001 23:55:22 -0000	1.4
  +++ SyntaxTree.java	20 Nov 2002 21:31:03 -0000	1.5
  @@ -113,7 +113,6 @@
   
     boolean[] createFastMap(){
       boolean[] fastMap, done;
  -    int token;
   
       fastMap  = new boolean[LeafNode._NUM_TOKENS]; 
       done     = new boolean[_positions];
  
  
  
  1.16      +7 -5      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Perl5Compiler.java	14 Oct 2002 16:39:06 -0000	1.15
  +++ Perl5Compiler.java	20 Nov 2002 21:31:03 -0000	1.16
  @@ -91,7 +91,6 @@
       __EXTENDED         = 0x0020,
       __READ_ONLY        = 0x8000;
   
  -  private static final String __META_CHARS = "^$.[()|?+*\\";
     private static final String __HEX_DIGIT =
     "0123456789abcdef0123456789ABCDEFx";
     private CharStringPointer __input;
  @@ -312,7 +311,7 @@
     private static int __parseOctal(char[] str, int offset, int maxLength,
   				 int[] scanned)
     {
  -    int val = 0, index;
  +    int val = 0;
   
       scanned[0] = 0;
       while(offset < str.length && 
  @@ -954,7 +953,10 @@
       }
     }
   
  -
  +  // This is the original 8-bit character class handling method.
  +  // We don't want to delete it just yet only to have to dig it out
  +  // of revision control later.
  +  /*
     private int __parseCharacterClass() throws MalformedPatternException {
       boolean range = false, skipTest;
       char clss, deflt, lastclss = Character.MAX_VALUE;
  @@ -1104,7 +1106,7 @@
   
       return offset;
     }
  -
  +  */
   
     private int __parseUnicodeClass() throws MalformedPatternException {
       boolean range = false, skipTest;
  
  
  
  1.20      +41 -43    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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Perl5Matcher.java	27 Jun 2002 22:38:20 -0000	1.19
  +++ Perl5Matcher.java	20 Nov 2002 21:31:03 -0000	1.20
  @@ -345,32 +345,30 @@
         }
   
         if((expression._anchor & Perl5Pattern._OPT_ANCH) != 0) {
  -	if(__currentOffset == beginOffset &&
  -	   __tryExpression(expression, beginOffset))
  +	if(__currentOffset == beginOffset && __tryExpression(beginOffset)) {
  +	  success = true;
  +	  break _mainLoop;
  +	} else if(__multiline
  +		  || (expression._anchor & Perl5Pattern._OPT_ANCH_MBOL) != 0
  +		  || (expression._anchor & Perl5Pattern._OPT_IMPLICIT) != 0)
   	  {
  -	    success = true;
  -	    break _mainLoop;
  -	  } else if(__multiline
  -		    || (expression._anchor & Perl5Pattern._OPT_ANCH_MBOL) != 0
  -		    || (expression._anchor & Perl5Pattern._OPT_IMPLICIT) != 0)
  -	    {
  -	      if(minLength > 0)
  -		dontTry = minLength - 1;
  -	      endOffset-=dontTry;
  -
  -	      if(__currentOffset > currentOffset)
  -		--__currentOffset;
  -
  -	      while(__currentOffset < endOffset) {
  -		if(__input[__currentOffset++] == '\n') {
  -		  if(__currentOffset < endOffset &&
  -		     __tryExpression(expression, __currentOffset)) {
  -		    success = true;
  -		    break _mainLoop;
  -		  }
  +	    if(minLength > 0)
  +	      dontTry = minLength - 1;
  +	    endOffset-=dontTry;
  +
  +	    if(__currentOffset > currentOffset)
  +	      --__currentOffset;
  +
  +	    while(__currentOffset < endOffset) {
  +	      if(__input[__currentOffset++] == '\n') {
  +		if(__currentOffset < endOffset &&
  +		   __tryExpression(__currentOffset)) {
  +		  success = true;
  +		  break _mainLoop;
   		}
   	      }
   	    }
  +	  }
   
   	break _mainLoop;
         }
  @@ -383,7 +381,7 @@
   
   	  while(__currentOffset < endOffset) {
   	    if(ch == __input[__currentOffset]) {
  -	      if(__tryExpression(expression, __currentOffset)){
  +	      if(__tryExpression(__currentOffset)){
   		success = true;
   		break _mainLoop;
   	      }
  @@ -399,7 +397,7 @@
   	  while((__currentOffset =
   		 __findFirst(__input, __currentOffset, endOffset, mustString))
   		< endOffset){
  -	    if(__tryExpression(expression, __currentOffset)) {
  +	    if(__tryExpression(__currentOffset)) {
   	      success = true;
   	      break _mainLoop;
   	    }
  @@ -429,7 +427,7 @@
   
   	    if(ch < 256 &&
   	       (__program[offset + (ch >> 4)] & (1 << (ch & 0xf))) == 0) {
  -	      if(tmp && __tryExpression(expression, __currentOffset)) {
  +	      if(tmp && __tryExpression(__currentOffset)) {
   		success = true;
   		break _mainLoop;
   	      } else
  @@ -448,7 +446,7 @@
   	    ch = __input[__currentOffset];
   
   	    if(__matchUnicodeClass(ch, __program, offset, op)) {
  -	      if(tmp && __tryExpression(expression, __currentOffset)) {
  +	      if(tmp && __tryExpression(__currentOffset)) {
   		success = true;
   		break _mainLoop;
   	      } else
  @@ -476,7 +474,7 @@
   	    ch = __input[__currentOffset];
   	    if(tmp != OpCode._isWordCharacter(ch)){
   	      tmp = !tmp;
  -	      if(__tryExpression(expression, __currentOffset)) {
  +	      if(__tryExpression(__currentOffset)) {
   		success = true;
   		break _mainLoop;
   	      }
  @@ -485,7 +483,7 @@
   	  }
   
   	  if((minLength > 0 || tmp) && 
  -	     __tryExpression(expression, __currentOffset)) {
  +	     __tryExpression(__currentOffset)) {
   	    success = true;
   	    break _mainLoop;
   	  }
  @@ -507,7 +505,7 @@
   	    ch = __input[__currentOffset];
   	    if(tmp != OpCode._isWordCharacter(ch))
   	      tmp = !tmp;
  -	    else if(__tryExpression(expression, __currentOffset)) {
  +	    else if(__tryExpression(__currentOffset)) {
   	      success = true;
   	      break _mainLoop;
   	    }
  @@ -516,7 +514,7 @@
   	  }
   
   	  if((minLength > 0 || !tmp) &&
  -	     __tryExpression(expression, __currentOffset)) {
  +	     __tryExpression(__currentOffset)) {
   	    success = true;
   	    break _mainLoop;
   	  }
  @@ -526,7 +524,7 @@
   	  while(__currentOffset < endOffset) {
   	    ch = __input[__currentOffset];
   	    if(OpCode._isWordCharacter(ch)) {
  -	      if(tmp && __tryExpression(expression, __currentOffset)) {
  +	      if(tmp && __tryExpression(__currentOffset)) {
   		success = true;
   		break _mainLoop;
   	      } else
  @@ -541,7 +539,7 @@
   	  while(__currentOffset < endOffset) {
   	    ch = __input[__currentOffset];
   	    if(!OpCode._isWordCharacter(ch)) {
  -	      if(tmp && __tryExpression(expression, __currentOffset)) {
  +	      if(tmp && __tryExpression(__currentOffset)) {
   		success = true;
   		break _mainLoop;
   	      } else
  @@ -555,7 +553,7 @@
   	case OpCode._SPACE:
   	  while(__currentOffset < endOffset) {
   	    if(Character.isWhitespace(__input[__currentOffset])) {
  -	      if(tmp && __tryExpression(expression, __currentOffset)) {
  +	      if(tmp && __tryExpression(__currentOffset)) {
   		success = true;
   		break _mainLoop;
   	      } else
  @@ -569,7 +567,7 @@
   	case OpCode._NSPACE:
   	  while(__currentOffset < endOffset) {
   	    if(!Character.isWhitespace(__input[__currentOffset])) {
  -	      if(tmp && __tryExpression(expression, __currentOffset)) {
  +	      if(tmp && __tryExpression(__currentOffset)) {
   		success = true;
   		break _mainLoop;
   	      } else
  @@ -583,7 +581,7 @@
   	case OpCode._DIGIT:
   	  while(__currentOffset < endOffset) {
   	    if(Character.isDigit(__input[__currentOffset])) {
  -	      if(tmp && __tryExpression(expression, __currentOffset)) {
  +	      if(tmp && __tryExpression(__currentOffset)) {
   		success = true;
   		break _mainLoop;
   	      } else
  @@ -598,7 +596,7 @@
   	case OpCode._NDIGIT:
   	  while(__currentOffset < endOffset) {
   	    if(!Character.isDigit(__input[__currentOffset])) {
  -	      if(tmp && __tryExpression(expression, __currentOffset)) {
  +	      if(tmp && __tryExpression(__currentOffset)) {
   		success = true;
   		break _mainLoop;
   	      } else
  @@ -616,7 +614,7 @@
   	endOffset-=dontTry;
   
   	do {
  -	  if(__tryExpression(expression, __currentOffset)) {
  +	  if(__tryExpression(__currentOffset)) {
   	    success = true;
   	    break _mainLoop;
   	  }
  @@ -739,7 +737,7 @@
       return !isANYOF;
     }
     
  -  private boolean __tryExpression(Perl5Pattern expression, int offset) {
  +  private boolean __tryExpression(int offset) {
       int count;
       
       __inputOffset = offset;
  @@ -1423,7 +1421,7 @@
   
       __initInterpreterGlobals(expression, input, 0, input.length, offset);
   
  -    __lastSuccess = __tryExpression(expression, offset);
  +    __lastSuccess = __tryExpression(offset);
       __lastMatchResult = null;
   
       return __lastSuccess;
  @@ -1501,7 +1499,7 @@
   
       __initInterpreterGlobals(expression, inp, input._beginOffset,
   			     input._endOffset, input._currentOffset);
  -    __lastSuccess = __tryExpression(expression, input._currentOffset);
  +    __lastSuccess = __tryExpression(input._currentOffset);
       __lastMatchResult = null;
   
       return __lastSuccess;
  @@ -1556,7 +1554,7 @@
         input = _toLower(input);
   
       __initInterpreterGlobals(expression, input, 0, input.length, 0);
  -    __lastSuccess = (__tryExpression(expression, 0) &&
  +    __lastSuccess = (__tryExpression(0) &&
   		     __endMatchOffsets[0] == input.length);
       __lastMatchResult = null;
   
  @@ -1669,7 +1667,7 @@
   
       __lastMatchResult = null;
   
  -    if(__tryExpression(expression, input._beginOffset)) {
  +    if(__tryExpression(input._beginOffset)) {
         if(__endMatchOffsets[0] == input._endOffset ||
   	 input.length() == 0 || input._beginOffset == input._endOffset) {
   	__lastSuccess = true;
  
  
  
  1.10      +1 -2      jakarta-oro/src/java/org/apache/oro/text/regex/Perl5Substitution.java
  
  Index: Perl5Substitution.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/regex/Perl5Substitution.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Perl5Substitution.java	14 Mar 2002 21:30:41 -0000	1.9
  +++ Perl5Substitution.java	20 Nov 2002 21:31:03 -0000	1.10
  @@ -337,7 +337,6 @@
   
     void _calcSub(StringBuffer buffer, MatchResult result) {
       int size, offset, count, caseMode;
  -    String group;
       char[] sub, str, match;
       int[] subOpcodes = _subOpcodes;
   
  
  
  
  1.11      +1 -2      jakarta-oro/src/java/org/apache/oro/text/regex/Util.java
  
  Index: Util.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/text/regex/Util.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Util.java	19 Feb 2002 04:54:29 -0000	1.10
  +++ Util.java	20 Nov 2002 21:31:03 -0000	1.11
  @@ -346,7 +346,6 @@
     public static String substitute(PatternMatcher matcher, Pattern pattern,
   				  Substitution sub, String input, int numSubs)
     {
  -    int substitutions;
       StringBuffer buffer = new StringBuffer(input.length());
       PatternMatcherInput pinput = new PatternMatcherInput(input);
       
  
  
  
  1.5       +1 -2      jakarta-oro/src/java/org/apache/oro/util/CacheLRU.java
  
  Index: CacheLRU.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/util/CacheLRU.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CacheLRU.java	20 May 2001 23:55:24 -0000	1.4
  +++ CacheLRU.java	20 Nov 2002 21:31:03 -0000	1.5
  @@ -162,7 +162,6 @@
      * @param value The value to add to the cache.
      */
     public final synchronized void addElement(Object key, Object value) {
  -    int index;
       Object obj;
   
       obj = _table.get(key);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.