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();
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2 |
Clones location | Clones are in the same method |
Number of node comparisons | 11 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 1.5 |
Clone type | Type 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 | | | 48 | |
Precondition Violations (1)
Row |
Violation |
1 | Clone fragment #1 returns variables res, changes , while Clone fragment #2 returns variables res, changes |