From 6836ae8bcd28993ede079b2b036aa894ac0ac60e Mon Sep 17 00:00:00 2001 From: Romain Pelisse Date: Mon, 24 Nov 2008 19:04:55 +0000 Subject: [PATCH] Committing small patch for CPD (Ruby). See https://sourceforge.net/tracker/index.php?func=detail&aid=2338341&group_id=56262&atid=479921 for more details. This small fix does not break unit test, but more testing will be nice. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6698 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/src/net/sourceforge/pmd/cpd/SourceCode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmd/src/net/sourceforge/pmd/cpd/SourceCode.java b/pmd/src/net/sourceforge/pmd/cpd/SourceCode.java index c05f600acb..3c819d6b17 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/SourceCode.java +++ b/pmd/src/net/sourceforge/pmd/cpd/SourceCode.java @@ -126,8 +126,8 @@ public class SourceCode { public String getSlice(int startLine, int endLine) { StringBuffer sb = new StringBuffer(); List lines = cl.getCode(); - for (int i = startLine - 1; i < endLine && i < lines.size(); i++) { - if (sb.length() != 0) { + for (int i = (startLine == 0 ? startLine :startLine - 1); i < endLine && i < lines.size(); i++) { + if (sb.length() != 0) { sb.append(PMD.EOL); } sb.append((String) lines.get(i));