if (c == '\\') { if (++i < argument.length()) { c = argument.charAt(i); int value = Character.digit(c, 10); if (value > -1) { subst.append("$").append(value); } else { subst.append(c); } } else { // XXX - should throw an exception instead? subst.append('\\'); } } else { subst.append(c); }
if (c == '\\') { if (++i < argument.length()) { c = argument.charAt(i); int value = Character.digit(c, 10); if (value > -1) { result.append((String) v.elementAt(value)); } else { result.append(c); } } else { // XXX - should throw an exception instead? result.append('\\'); } } else { result.append(c); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java
Method name: String substitute(String, String, int) Method name: String substitute(String, String, int)
Number of AST nodes: 9 Number of AST nodes: 9
1
if (c == '\\') {
1
if (c == '\\') {
2
                if (++i < argument.length()) {
2
                if (++i < argument.length()) {
3
                    c = argument.charAt(i);
3
                    c = argument.charAt(i);
4
                    int value = Character.digit(c, 10);
4
                    int value = Character.digit(c, 10);
5
                    if (value > -1) {
5
                    if (value > -1) {
6
                        subst.append("$").append(value);
6
                        result.append((String) v.elementAt(value));
7
                    } else {
7
                    } else {
8
                        subst.append(c);
8
                        result.append(c);
9
                    }
9
                    }
10
                } else {
10
                } else {
11
                    // XXX - should throw an exception instead?
11
                    // XXX - should throw an exception instead?
12
                    subst.append('\\');
12
                    result.append('\\');
13
                }
13
                }
14
            } else {
14
            } else {
15
                subst.append(c);
15
                result.append(c);
16
            }
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.3
Clones locationClones are in different classes
Number of node comparisons30
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)3.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    7
    if (c == '\\')
    5
    if (c == '\\')
    8
    if (++i < argument.length())
    6
    if (++i < argument.length())
    9
    c = argument.charAt(i);
    7
    c = argument.charAt(i);
    10
    int value = Character.digit(c, 10);
    8
    int value = Character.digit(c, 10);
    11
    if (value > -1)
    9
    if (value > -1)
                                                                                                
    10
    result.append((String)v.elementAt(value));
    Preondition Violations
    Unmatched statement result.append((String)v.elementAt(value)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    result.append((String)v.elementAt(value));
    12
    subst.append("$").append(value);
    12
    subst.append("$").append(value);
    Preondition Violations
    Unmatched statement subst.append("$").append(value); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                            
    else
    else
    13
    subst.append(c);
    13
    subst.append(c);
    11
    result.append(c);
    Differences
    Expression1Expression2Difference
    substresultVARIABLE_NAME_MISMATCH
    11
    result.append(c);
    else
    else
    14
    subst.append('\\');
    14
    subst.append('\\');
    12
    result.append('\\');
    Differences
    Expression1Expression2Difference
    substresultVARIABLE_NAME_MISMATCH
    12
    result.append('\\');
    else
    else
    15
    subst.append(c);
    15
    subst.append(c);
    13
    result.append(c);
    Differences
    Expression1Expression2Difference
    substresultVARIABLE_NAME_MISMATCH
    13
    result.append(c);
    Precondition Violations (3)
    Row Violation
    1Unmatched statement result.append((String)v.elementAt(value)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement subst.append("$").append(value); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables i, value , while Clone fragment #2 returns variables i, value