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 | }
|
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.4 |
Clones location | Clones are in the same method |
Number of node comparisons | 42 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 9 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 3.7 |
Clone type | Type 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 | | | 48 | |
38 | pw.print(res); | | 49 | pw.print(res); |
39 | if (hasCR) | | 50 | if (hasCR) |
40 | | | 51 | |
41 | | | 52 | |
42 | pw.print('\n'); | | | |
43 | linebuf = new StringBuffer(); | | 53 | linebuf = new StringBuffer(); |
Precondition Violations (1)
Row |
Violation |
1 | Clone fragment #1 returns variables hasCR, linebuf, changes , while Clone fragment #2 returns variables hasCR, linebuf, changes |