if ((buffer != null) && (bufpos < buffer.length())) { return (int) buffer.charAt(bufpos++); } // check if input is at a valid position if (!stream.isValid()) return -1; REMatch mymatch = new REMatch(expr.getNumSubs(),offset,0); if (expr.match(stream, mymatch)) { mymatch.end[0] = mymatch.index; mymatch.finish(stream); stream.move(mymatch.toString().length()); offset += mymatch.toString().length(); buffer = mymatch.substituteInto(replace); bufpos = 1; // This is prone to infinite loops if replace string turns out empty. if (buffer.length() > 0) { return buffer.charAt(0); } } char ch = stream.charAt(0); if (ch == CharIndexed.OUT_OF_BOUNDS) return -1; stream.move(1); offset++; return ch;
if ((buffer != null) && (bufpos < buffer.length())) { return (int) buffer.charAt(bufpos++); } // check if input is at a valid position if (!stream.isValid()) return -1; REMatch mymatch = new REMatch(expr.getNumSubs(),offset,0); if (expr.match(stream,mymatch)) { mymatch.end[0] = mymatch.index; mymatch.finish(stream); stream.move(mymatch.toString().length()); offset += mymatch.toString().length(); buffer = mymatch.substituteInto(replace); bufpos = 1; if (buffer.length() > 0) { return buffer.charAt(0); } } char ch = stream.charAt(0); if (ch == CharIndexed.OUT_OF_BOUNDS) return -1; stream.move(1); offset++; return ch;
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/gnu/regexp/REFilterInputStream.java File path: /jEdit-4.2/src/gnu/regexp/REFilterReader.java
Method name: int read() Method name: int read()
Number of AST nodes: 20 Number of AST nodes: 20
1
if ((buffer != null) && (bufpos < buffer.length())) {
1
if ((buffer != null) && (bufpos < buffer.length())) {
2
      return (int) buffer.charAt(bufpos++);
2
      return (int) buffer.charAt(bufpos++);
3
    }
3
    }
4
    // check if input is at a valid position
4
    // check if input is at a valid position
5
    if (!stream.isValid()) return -1;
5
    if (!stream.isValid()) return -1;
6
    REMatch mymatch = new REMatch(expr.getNumSubs(),offset,0);
6
    REMatch mymatch = new REMatch(expr.getNumSubs(),offset,0);
7
    if (expr.match(stream, mymatch)) {
7
    if (expr.match(stream,mymatch)) {
8
      mymatch.end[0] = mymatch.index;
8
      mymatch.end[0] = mymatch.index;
9
      mymatch.finish(stream);
9
      mymatch.finish(stream);
10
      stream.move(mymatch.toString().length());
10
      stream.move(mymatch.toString().length());
11
      offset += mymatch.toString().length();
11
      offset += mymatch.toString().length();
12
      buffer = mymatch.substituteInto(replace);
12
      buffer = mymatch.substituteInto(replace);
13
      bufpos = 1;
13
      bufpos = 1;
14
      // This is prone to infinite loops if replace string turns out empty.
15
      if (buffer.length() > 0) {
14
      if (buffer.length() > 0) {
16
	  return buffer.charAt(0);
15
	  return buffer.charAt(0);
17
      }
16
      }
18
    }
17
    }
19
    char ch = stream.charAt(0);
18
    char ch = stream.charAt(0);
20
    if (ch == CharIndexed.OUT_OF_BOUNDS) return -1;
19
    if (ch == CharIndexed.OUT_OF_BOUNDS) return -1;
21
    stream.move(1);
20
    stream.move(1);
22
    offset++;
21
    offset++;
23
    return ch;
22
    return ch;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)1.3
Clones locationClones are in different classes
Number of node comparisons83
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements20
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)29.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if ((buffer != null) && (bufpos < buffer.length()))
    1
    if ((buffer != null) && (bufpos < buffer.length()))
    2
    return (int)buffer.charAt(bufpos++);
    2
    return (int)buffer.charAt(bufpos++);
    3
    if (!stream.isValid())
    3
    if (!stream.isValid())
    3
    if (!stream.isValid())
    Differences
    Expression1Expression2Difference
    gnu.regexp.CharIndexedInputStreamgnu.regexp.CharIndexedReaderSUBCLASS_TYPE_MISMATCH
    3
    if (!stream.isValid())
    4
    return -1;
    4
    return -1;
    5
    REMatch mymatch = new REMatch(expr.getNumSubs(), offset, 0);
    5
    REMatch mymatch = new REMatch(expr.getNumSubs(), offset, 0);
    6
    if (expr.match(stream, mymatch))
    6
    if (expr.match(stream, mymatch))
    6
    if (expr.match(stream, mymatch))
    Differences
    Expression1Expression2Difference
    gnu.regexp.CharIndexedInputStreamgnu.regexp.CharIndexedReaderSUBCLASS_TYPE_MISMATCH
    6
    if (expr.match(stream, mymatch))
    7
    mymatch.end[0] = mymatch.index;
    7
    mymatch.end[0] = mymatch.index;
    8
    mymatch.finish(stream);
    8
    mymatch.finish(stream);
    8
    mymatch.finish(stream);
    Differences
    Expression1Expression2Difference
    gnu.regexp.CharIndexedInputStreamgnu.regexp.CharIndexedReaderSUBCLASS_TYPE_MISMATCH
    8
    mymatch.finish(stream);
    9
    stream.move(mymatch.toString().length());
    9
    stream.move(mymatch.toString().length());
    9
    stream.move(mymatch.toString().length());
    Differences
    Expression1Expression2Difference
    gnu.regexp.CharIndexedInputStreamgnu.regexp.CharIndexedReaderSUBCLASS_TYPE_MISMATCH
    9
    stream.move(mymatch.toString().length());
    10
    offset += mymatch.toString().length();
    10
    offset += mymatch.toString().length();
    11
    buffer = mymatch.substituteInto(replace);
    11
    buffer = mymatch.substituteInto(replace);
    12
    bufpos = 1;
    12
    bufpos = 1;
    13
    if (buffer.length() > 0)
    13
    if (buffer.length() > 0)
    14
    return buffer.charAt(0);
    14
    return buffer.charAt(0);
    15
    char ch = stream.charAt(0);
    15
    char ch = stream.charAt(0);
    15
    char ch = stream.charAt(0);
    Differences
    Expression1Expression2Difference
    gnu.regexp.CharIndexedInputStreamgnu.regexp.CharIndexedReaderSUBCLASS_TYPE_MISMATCH
    15
    char ch = stream.charAt(0);
    16
    if (ch == CharIndexed.OUT_OF_BOUNDS)
    16
    if (ch == CharIndexed.OUT_OF_BOUNDS)
    17
    return -1;
    17
    return -1;
    18
    stream.move(1);
    18
    stream.move(1);
    18
    stream.move(1);
    Differences
    Expression1Expression2Difference
    gnu.regexp.CharIndexedInputStreamgnu.regexp.CharIndexedReaderSUBCLASS_TYPE_MISMATCH
    18
    stream.move(1);
    19
    offset++;
    19
    offset++;
    20
    return ch;
    20
    return ch;
    Precondition Violations (1)
    Row Violation
    1The refactoring of the clones is infeasible, because classes gnu.regexp.REFilterInputStream and gnu.regexp.REFilterReader do not have a common superclass