if (hasCR) { // second CR -> EOL + possibly empty line line = linebuf.toString(); res = doReplace(regex, subs, line, options); if (!res.equals(line)) { changes = true; } pw.print(res); pw.print('\r'); linebuf = new StringBuffer(); // hasCR is still true (for the second one) } else { // first CR in this line hasCR = true; }
line = linebuf.toString(); res = doReplace(regex, subs, line, options); if (!res.equals(line)) { changes = true; } pw.print(res); if (hasCR) { pw.print('\r'); hasCR = false; } linebuf = new StringBuffer();
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
Method name: void doReplace(File, int) Method name: void doReplace(File, int)
Number of AST nodes: 9 Number of AST nodes: 9
1
if (hasCR) {
2
                            // second CR -> EOL + possibly empty line
3
                            line = linebuf.toString();
1
line = linebuf.toString();
4
                            res  = doReplace(regex, subs, line, options);
2
                            res  = doReplace(regex, subs, line, options);
5
                            if (!res.equals(line)) {
3
                            if (!res.equals(line)) {
6
                                changes = true;
4
                                changes = true;
7
                            }
5
                            }
8
                            pw.print(res);
6
                            pw.print(res);
9
                            pw.print('\r');
7
                            
8
if (hasCR) {
10
                            linebuf = new StringBuffer();
9
                                pw.print('\r');
11
                            // hasCR is still true (for the second one)
10
                                hasCR = false;
12
                        } else {
11
                        
13
  
12
    }
14
                          // first CR in this line
13
                          
15
                            hasCR = true;
16
                        }
14
  linebuf = new StringBuffer();
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)0.2
Clones locationClones are in the same method
Number of node comparisons11
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.5
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    25
    line = linebuf.toString();
    45
    line = linebuf.toString();
    26
    res = doReplace(regex, subs, line, options);
    46
    res = doReplace(regex, subs, line, options);
    27
    if (!res.equals(line))
    47
    if (!res.equals(line))
    28
    changes = true;
    48
    changes = true;
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables res, changes , while Clone fragment #2 returns variables res, changes