### Eclipse Workspace Patch 1.0 #P org.eclipse.compare.core Index: src/org/eclipse/compare/internal/core/patch/Hunk.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java,v retrieving revision 1.1 diff -u -r1.1 Hunk.java --- src/org/eclipse/compare/internal/core/patch/Hunk.java 15 Jul 2008 14:43:27 -0000 1.1 +++ src/org/eclipse/compare/internal/core/patch/Hunk.java 11 Aug 2008 10:53:05 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -314,6 +314,9 @@ List contextLines = new ArrayList(); boolean contextLinesMatched = true; boolean precedingLinesChecked = false; + + String lineDelimiter = getLineDelimiter(lines); + for (int i= 0; i < fLines.length; i++) { String s= fLines[i]; Assert.isTrue(s.length() > 0); @@ -372,6 +375,10 @@ contextLines.clear(); contextLinesMatched = true; + // if the line contains a delimiter, use a proper one + if (line.length() > LineReader.length(line)) + line = line.substring(0, LineReader.length(line)) + lineDelimiter; + if (getLength(reverse) == 0 && pos+1 < lines.size()) lines.add(pos+1, line); else @@ -412,6 +419,18 @@ return true; } + private String getLineDelimiter(List lines) { + String separator = System.getProperty("line.separator"); + if (lines.size() > 0) { + String line0 = (String) lines.get(0); + separator = line0.substring(LineReader.length(line0)); + } else if (fLines.length > 0) { + String line0 = fLines[0]; + separator = line0.substring(LineReader.length(line0)); + } + return separator; + } + /* * Returns the given string with all whitespace characters removed. * Whitespace is defined by Character.isWhitespace(...).