Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2002-05-28 10:22:57 +0000
committerAndre Weinand2002-05-28 10:22:57 +0000
commit894744ec6d6233cd66942ccd7f476f7b5f1ca5a8 (patch)
tree0c8b1c420040938be817d2d14b44f1d8cac49ab6 /bundles/org.eclipse.compare
parent25cbee6f9acfa32a7e85d271988a88c08b62651e (diff)
downloadeclipse.platform.team-894744ec6d6233cd66942ccd7f476f7b5f1ca5a8.tar.gz
eclipse.platform.team-894744ec6d6233cd66942ccd7f476f7b5f1ca5a8.tar.xz
eclipse.platform.team-894744ec6d6233cd66942ccd7f476f7b5f1ca5a8.zip
#16936v20020528
Diffstat (limited to 'bundles/org.eclipse.compare')
-rw-r--r--bundles/org.eclipse.compare/buildnotes_compare.html2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java53
-rw-r--r--bundles/org.eclipse.compare/plugin.properties1
-rw-r--r--bundles/org.eclipse.compare/plugin.xml2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java53
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties1
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml2
8 files changed, 92 insertions, 24 deletions
diff --git a/bundles/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/buildnotes_compare.html
index 2b68a3cbe..05ac3c7e8 100644
--- a/bundles/org.eclipse.compare/buildnotes_compare.html
+++ b/bundles/org.eclipse.compare/buildnotes_compare.html
@@ -34,6 +34,8 @@ Problem reports fixed</h2>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=17678">#17678</a>: Applying a patch does many compiles<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=17536">#17536</a>: NPE in compare<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=17121">#17121</a>: Casing of message when end of changes needs to be sentence style<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=17648">#17648</a>: Can't apply patch w/o ignoring whitespace<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=16936">#16936</a>: Compare with patch requires "Ignore Whitespace" to be turned off<br>
<h2>
Problem reports closed</h2>
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
index 782348d45..7205786c9 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
@@ -47,7 +47,9 @@ public class Patcher {
// patch options
private int fStripPrefixSegments;
private int fFuzz;
- private boolean fIgnoreWhitespace;
+ private boolean fIgnoreWhitespace= false;
+ private boolean fIgnoreLineDelimiter= true;
+ private boolean fPreserveLineDelimiters= false;
private boolean fReverse= false;
@@ -910,13 +912,27 @@ public class Patcher {
}
/**
- * Concatenates all strings found in the gievn List.
+ * Concatenates all strings found in the given List.
*/
private String createString(List lines) {
StringBuffer sb= new StringBuffer();
Iterator iter= lines.iterator();
- while (iter.hasNext())
- sb.append((String)iter.next());
+ if (fPreserveLineDelimiters) {
+ while (iter.hasNext())
+ sb.append((String)iter.next());
+ } else {
+ String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$
+ while (iter.hasNext()) {
+ String line= (String)iter.next();
+ int l= length(line);
+ if (l < line.length()) { // line has delimiter
+ sb.append(line.substring(0, l));
+ sb.append(lineSeparator);
+ } else {
+ sb.append(line);
+ }
+ }
+ }
return sb.toString();
}
@@ -924,12 +940,13 @@ public class Patcher {
if (failedHunks.size() <= 0)
return null;
+ String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$
StringBuffer sb= new StringBuffer();
Iterator iter= failedHunks.iterator();
while (iter.hasNext()) {
Hunk hunk= (Hunk) iter.next();
sb.append(hunk.getRejectedDescription());
- sb.append('\n');
+ sb.append(lineSeparator);
sb.append(hunk.getContent());
}
return sb.toString();
@@ -965,23 +982,37 @@ public class Patcher {
/**
* Compares two strings.
- * If fIgnoreWhitespace is true whitespace and line endings are ignored.
+ * If fIgnoreWhitespace is true whitespace is ignored.
*/
private boolean linesMatch(String line1, String line2) {
if (fIgnoreWhitespace)
return stripWhiteSpace(line1).equals(stripWhiteSpace(line2));
+ if (fIgnoreLineDelimiter) {
+ int l1= length(line1);
+ int l2= length(line2);
+ if (l1 != l2)
+ return false;
+ return line1.regionMatches(0, line2, 0, l1);
+ }
return line1.equals(line2);
}
/**
- * Returns the length (exluding end-of-line characters) of the given string.
+ * Returns the length (exluding a line delimiter CR, LF, CR/LF)
+ * of the given string.
*/
/* package */ static int length(String s) {
int l= s.length();
- if (l > 0 && s.charAt(l-1) == '\n')
- l--;
- if (l > 1 && s.charAt(l-2) == '\r')
- l--;
+ if (l > 0) {
+ char c= s.charAt(l-1);
+ if (c == '\r')
+ return l-1;
+ if (c == '\n') {
+ if (l > 1 && s.charAt(l-2) == '\r')
+ return l-2;
+ return l-1;
+ }
+ }
return l;
}
}
diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties
index fb649b510..3efaf2b91 100644
--- a/bundles/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugin.properties
@@ -6,6 +6,7 @@
# Resource strings for Compare Plug-in
#
pluginName= Compare Support
+providerName=Eclipse.org
#
# Extension point names
diff --git a/bundles/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugin.xml
index 1debb4608..3d67a73a0 100644
--- a/bundles/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugin.xml
@@ -8,7 +8,7 @@
name="%pluginName"
id="org.eclipse.compare"
version="2.0.0"
- provider-name="Object Technology International, Inc."
+ provider-name="%providerName"
class="org.eclipse.compare.internal.CompareUIPlugin">
<requires>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
index 2b68a3cbe..05ac3c7e8 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
@@ -34,6 +34,8 @@ Problem reports fixed</h2>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=17678">#17678</a>: Applying a patch does many compiles<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=17536">#17536</a>: NPE in compare<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=17121">#17121</a>: Casing of message when end of changes needs to be sentence style<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=17648">#17648</a>: Can't apply patch w/o ignoring whitespace<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=16936">#16936</a>: Compare with patch requires "Ignore Whitespace" to be turned off<br>
<h2>
Problem reports closed</h2>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
index 782348d45..7205786c9 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
@@ -47,7 +47,9 @@ public class Patcher {
// patch options
private int fStripPrefixSegments;
private int fFuzz;
- private boolean fIgnoreWhitespace;
+ private boolean fIgnoreWhitespace= false;
+ private boolean fIgnoreLineDelimiter= true;
+ private boolean fPreserveLineDelimiters= false;
private boolean fReverse= false;
@@ -910,13 +912,27 @@ public class Patcher {
}
/**
- * Concatenates all strings found in the gievn List.
+ * Concatenates all strings found in the given List.
*/
private String createString(List lines) {
StringBuffer sb= new StringBuffer();
Iterator iter= lines.iterator();
- while (iter.hasNext())
- sb.append((String)iter.next());
+ if (fPreserveLineDelimiters) {
+ while (iter.hasNext())
+ sb.append((String)iter.next());
+ } else {
+ String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$
+ while (iter.hasNext()) {
+ String line= (String)iter.next();
+ int l= length(line);
+ if (l < line.length()) { // line has delimiter
+ sb.append(line.substring(0, l));
+ sb.append(lineSeparator);
+ } else {
+ sb.append(line);
+ }
+ }
+ }
return sb.toString();
}
@@ -924,12 +940,13 @@ public class Patcher {
if (failedHunks.size() <= 0)
return null;
+ String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$
StringBuffer sb= new StringBuffer();
Iterator iter= failedHunks.iterator();
while (iter.hasNext()) {
Hunk hunk= (Hunk) iter.next();
sb.append(hunk.getRejectedDescription());
- sb.append('\n');
+ sb.append(lineSeparator);
sb.append(hunk.getContent());
}
return sb.toString();
@@ -965,23 +982,37 @@ public class Patcher {
/**
* Compares two strings.
- * If fIgnoreWhitespace is true whitespace and line endings are ignored.
+ * If fIgnoreWhitespace is true whitespace is ignored.
*/
private boolean linesMatch(String line1, String line2) {
if (fIgnoreWhitespace)
return stripWhiteSpace(line1).equals(stripWhiteSpace(line2));
+ if (fIgnoreLineDelimiter) {
+ int l1= length(line1);
+ int l2= length(line2);
+ if (l1 != l2)
+ return false;
+ return line1.regionMatches(0, line2, 0, l1);
+ }
return line1.equals(line2);
}
/**
- * Returns the length (exluding end-of-line characters) of the given string.
+ * Returns the length (exluding a line delimiter CR, LF, CR/LF)
+ * of the given string.
*/
/* package */ static int length(String s) {
int l= s.length();
- if (l > 0 && s.charAt(l-1) == '\n')
- l--;
- if (l > 1 && s.charAt(l-2) == '\r')
- l--;
+ if (l > 0) {
+ char c= s.charAt(l-1);
+ if (c == '\r')
+ return l-1;
+ if (c == '\n') {
+ if (l > 1 && s.charAt(l-2) == '\r')
+ return l-2;
+ return l-1;
+ }
+ }
return l;
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
index fb649b510..3efaf2b91 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
@@ -6,6 +6,7 @@
# Resource strings for Compare Plug-in
#
pluginName= Compare Support
+providerName=Eclipse.org
#
# Extension point names
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
index 1debb4608..3d67a73a0 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
@@ -8,7 +8,7 @@
name="%pluginName"
id="org.eclipse.compare"
version="2.0.0"
- provider-name="Object Technology International, Inc."
+ provider-name="%providerName"
class="org.eclipse.compare.internal.CompareUIPlugin">
<requires>

Back to the top