public int read() { // If we have buffered replace data, use it. 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; } /** * Returns false. REFilterInputStream does not support mark() and * reset() methods. */ public boolean markSupported() { return false; } /** Reads from the stream into the provided array. */ public int read(byte[] b, int off, int len) { int i; int ok = 0; while (len-- > 0) { i = read(); if (i == -1) return (ok == 0) ? -1 : ok; b[off++] = (byte) i; ok++; } return ok; } /** Reads from the stream into the provided array. */ public int read(byte[] b) { return read(b,0,b.length);
public int read() { // If we have buffered replace data, use it. 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; } /** * Returns false. REFilterReader does not support mark() and * reset() methods. */ public boolean markSupported() { return false; } /** Reads from the stream into the provided array. */ public int read(char[] b, int off, int len) { int i; int ok = 0; while (len-- > 0) { i = read(); if (i == -1) return (ok == 0) ? -1 : ok; b[off++] = (char) i; ok++; } return ok; } /** Reads from the stream into the provided array. */ public int read(char[] b) { return read(b,0,b.length);
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: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public int read() {
1
public int read() {
2
    // If we have buffered replace data, use it.
2
    // If we have buffered replace data, use it.
3
    if ((buffer != null) && (bufpos < buffer.length())) {
3
    if ((buffer != null) && (bufpos < buffer.length())) {
4
      return (int) buffer.charAt(bufpos++);
4
      return (int) buffer.charAt(bufpos++);
5
    }
5
    }
6
    // check if input is at a valid position
6
    // check if input is at a valid position
7
    if (!stream.isValid()) return -1;
7
    if (!stream.isValid()) return -1;
8
    REMatch mymatch = new REMatch(expr.getNumSubs(),offset,0);
8
    REMatch mymatch = new REMatch(expr.getNumSubs(),offset,0);
9
    if (expr.match(stream, mymatch)) {
9
    if (expr.match(stream,mymatch)) {
10
      mymatch.end[0] = mymatch.index;
10
      mymatch.end[0] = mymatch.index;
11
      mymatch.finish(stream);
11
      mymatch.finish(stream);
12
      stream.move(mymatch.toString().length());
12
      stream.move(mymatch.toString().length());
13
      offset += mymatch.toString().length();
13
      offset += mymatch.toString().length();
14
      buffer = mymatch.substituteInto(replace);
14
      buffer = mymatch.substituteInto(replace);
15
      bufpos = 1;
15
      bufpos = 1;
16
      // This is prone to infinite loops if replace string turns out empty.
17
      if (buffer.length() > 0) {
16
      if (buffer.length() > 0) {
18
	  return buffer.charAt(0);
17
	  return buffer.charAt(0);
19
      }
18
      }
20
    }
19
    }
21
    char ch = stream.charAt(0);
20
    char ch = stream.charAt(0);
22
    if (ch == CharIndexed.OUT_OF_BOUNDS) return -1;
21
    if (ch == CharIndexed.OUT_OF_BOUNDS) return -1;
23
    stream.move(1);
22
    stream.move(1);
24
    offset++;
23
    offset++;
25
    return ch;
24
    return ch;
26
  }
25
  }
27
  /** 
26
  /** 
28
   * Returns false.  REFilterInputStream does not support mark() and
27
   * Returns false.  REFilterReader does not support mark() and
29
   * reset() methods. 
28
   * reset() methods. 
30
   */
29
   */
31
  public boolean markSupported() {
30
  public boolean markSupported() {
32
    return false;
31
    return false;
33
  }
32
  }
34
  /** Reads from the stream into the provided array. */
33
  /** Reads from the stream into the provided array. */
35
  public int read(byte[] b, int off, int len) {
34
  public int read(char[] b, int off, int len) {
36
    int i;
35
    int i;
37
    int ok = 0;
36
    int ok = 0;
38
    while (len-- > 0) {
37
    while (len-- > 0) {
39
      i = read();
38
      i = read();
40
      if (i == -1) return (ok == 0) ? -1 : ok;
39
      if (i == -1) return (ok == 0) ? -1 : ok;
41
      b[off++] = (byte) i;
40
      b[off++] = (char) i;
42
      ok++;
41
      ok++;
43
    }
42
    }
44
    return ok;
43
    return ok;
45
  }
44
  }
46
  /** Reads from the stream into the provided array. */
45
  /** Reads from the stream into the provided array. */
47
  public int read(byte[] b) {
46
  public int read(char[] b) {
48
    return read(b,0,b.length);
47
    return read(b,0,b.length);
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0