From fe66d2fc61e4d4fa9c82b715b500132d83a36377 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Mon, 17 Apr 2006 21:28:11 +0000 Subject: [PATCH] Nicer version cpd.sh from Jarkko git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4345 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/bin/cpd.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pmd/bin/cpd.sh b/pmd/bin/cpd.sh index 8dc99cf838..e35be901d6 100755 --- a/pmd/bin/cpd.sh +++ b/pmd/bin/cpd.sh @@ -3,10 +3,14 @@ ## This will work in the majority of shells out there... ## This will parse a directory named on the command line and produce a -## cut and paste report for c++ files in that directory. +## cut and paste report for c++ files in that directory (or 'c', if you +## set the environment variable LANGUAGE to 'c'). ## Note that other rules are only for Java code not C source. +## If you run into java.lang.OutOfMemoryError, try setting the environment +## variable HEAPSIZE to e.g. 512m + DIRECTORY=$1 if [ -z "$1" ]; then @@ -39,10 +43,23 @@ for jarfile in `ls $LIB_DIR/*.jar`; do classpath=$classpath:$jarfile done +HEAPSIZE=${HEAPSIZE:-512m} +LANGUAGE=${LANGUAGE:-cpp} +MINIMUM_TOKENS=${MINIMUM_TOKENS:-100} -MINIMUM_SIZE=100 -LANGUAGE=cpp +case "$HEAPSIZE" in +[1-9]*[mgMG]) HEAPSIZE=-Xmx$HEAPSIZE ;; +'') ;; +*) echo "HEAPSIZE '$HEAPSIZE' unknown (try: 512m)" + exit 1 +esac + +case "$LANGUAGE" in +cpp|c) ;; +*) echo "Language '$LANGUAGE' unknown (try: cpp, c)" + exit 1 +esac # echo "CLASSPATH: $classpath" -java -cp $classpath net.sourceforge.pmd.cpd.CPD --minimum-tokens $MINIMUM_SIZE --files $DIRECTORY --language $LANGUAGE +java $HEAPSIZE -cp $classpath net.sourceforge.pmd.cpd.CPD --minimum-tokens $MINIMUM_TOKENS --files $DIRECTORY --language $LANGUAGE