Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 150591 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/compare/internal/core/patch/Hunk.java (-1 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 314-319 Link Here
314
		List contextLines = new ArrayList();
314
		List contextLines = new ArrayList();
315
		boolean contextLinesMatched = true;
315
		boolean contextLinesMatched = true;
316
		boolean precedingLinesChecked = false;
316
		boolean precedingLinesChecked = false;
317
		
318
		String lineDelimiter = getLineDelimiter(lines);
319
		
317
		for (int i= 0; i < fLines.length; i++) {
320
		for (int i= 0; i < fLines.length; i++) {
318
			String s= fLines[i];
321
			String s= fLines[i];
319
			Assert.isTrue(s.length() > 0);
322
			Assert.isTrue(s.length() > 0);
Lines 372-377 Link Here
372
				contextLines.clear();
375
				contextLines.clear();
373
				contextLinesMatched = true;
376
				contextLinesMatched = true;
374
				
377
				
378
				// if the line contains a delimiter, use a proper one
379
				if (line.length() > LineReader.length(line))
380
					line = line.substring(0, LineReader.length(line)) + lineDelimiter;
381
				
375
				if (getLength(reverse) == 0 && pos+1 < lines.size())
382
				if (getLength(reverse) == 0 && pos+1 < lines.size())
376
					lines.add(pos+1, line);
383
					lines.add(pos+1, line);
377
				else
384
				else
Lines 412-417 Link Here
412
		return true;
419
		return true;
413
	}
420
	}
414
421
422
	private String getLineDelimiter(List lines) {
423
		String separator = System.getProperty("line.separator");
424
		if (lines.size() > 0) {
425
			String line0 = (String) lines.get(0);
426
			separator = line0.substring(LineReader.length(line0));
427
		} else if (fLines.length > 0) {
428
			String line0 = fLines[0];
429
			separator = line0.substring(LineReader.length(line0));
430
		} 
431
		return separator;
432
	}
433
	
415
	/*
434
	/*
416
	 * Returns the given string with all whitespace characters removed.
435
	 * Returns the given string with all whitespace characters removed.
417
	 * Whitespace is defined by <code>Character.isWhitespace(...)</code>.
436
	 * Whitespace is defined by <code>Character.isWhitespace(...)</code>.

Return to bug 150591