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; } pw.print('\n'); linebuf = new StringBuffer();
if ((hasCR) || (c < 0)) { // Mac-style linebreak or EOF (or both) 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: 10 Number of AST nodes: 10
1
if ((hasCR) || (c < 0)) {
2
                            // Mac-style linebreak or EOF (or both)
1
line = linebuf.toString();
3
                            line = linebuf.toString();
2
                        res  = doReplace(regex, subs, line, options);
4
                            res  = doReplace(regex, subs, line, options);
3
                        if (!res.equals(line)) {
5
                            if (!res.equals(line)) {
4
                            changes = true;
6
                                changes = true;
5
                        }
7
                            }
6
                        pw.print(res);
8
                            pw.print(res);
7
                        if (hasCR) {
9
                            if (hasCR) {
8
                            pw.print('\r');
10
                                pw.print('\r');
9
                            hasCR = false;
11
                                hasCR = false;
10
                        }
12
                 
11
           
13
           }
12
             pw.print('\n');
14
    
13
                        linebuf = new StringBuffer();
15
                        linebuf = new StringBuffer();
16
                        }
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.4
Clones locationClones are in the same method
Number of node comparisons42
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    34
    line = linebuf.toString();
    45
    line = linebuf.toString();
    35
    res = doReplace(regex, subs, line, options);
    46
    res = doReplace(regex, subs, line, options);
    36
    if (!res.equals(line))
    47
    if (!res.equals(line))
    37
    changes = true;
    48
    changes = true;
    38
    pw.print(res);
    49
    pw.print(res);
    39
    if (hasCR)
    50
    if (hasCR)
    40
    pw.print('\r');
    51
    pw.print('\r');
    41
    hasCR = false;
    52
    hasCR = false;
    42
    pw.print('\n');
                                          
    43
    linebuf = new StringBuffer();
    53
    linebuf = new StringBuffer();
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables hasCR, linebuf, changes , while Clone fragment #2 returns variables hasCR, linebuf, changes