db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcai...@apache.org
Subject svn commit: r611281 - /db/jdo/bin/behead
Date Fri, 11 Jan 2008 19:53:52 GMT
Author: mcaisse
Date: Fri Jan 11 11:53:51 2008
New Revision: 611281

URL: http://svn.apache.org/viewvc?rev=611281&view=rev
Log:
Script for removing boilerplate text from the head of annotation and enum files.

Added:
    db/jdo/bin/behead   (with props)

Added: db/jdo/bin/behead
URL: http://svn.apache.org/viewvc/db/jdo/bin/behead?rev=611281&view=auto
==============================================================================
--- db/jdo/bin/behead (added)
+++ db/jdo/bin/behead Fri Jan 11 11:53:51 2008
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Read .java files in source directory,
+#   copying lines from the first line matching
+#   the start pattern to the end of the file
+#   to a file of the same name in the target directory
+#
+# Designed to be used to remove license header and imports from
+#    annotation and enum files in the JDO api project for import
+#    into the FrameMaker specification
+#
+# Tested on cygwin and Mac
+#
+USAGE="behead <source dir> <target dir>"
+if [ $# -ne 2 ]
+    then
+        echo $USAGE
+        exit -1
+fi
+
+SRCDIR=$1
+TARGETDIR=$2
+
+STARTPATTERN="^@"
+ENUMSTARTPATTERN="public enum"
+
+for FILE in `ls $SRCDIR/*.java`
+do
+    ROOT=`basename $FILE .java`
+    OUTFILE=${TARGETDIR}/${ROOT}.txt
+    if [ `grep -c "public enum" $FILE` -gt 0 ]
+    then
+        STARTINDEX=`grep --max-count=1 -n "${ENUMSTARTPATTERN}" $FILE | cut -d: -f1 `
+    else
+        STARTINDEX=`grep --max-count=1 -n $STARTPATTERN $FILE | cut -d: -f1 `
+    fi
+        #echo $STARTINDEX
+        ENDINDEX=`wc -l $FILE | sed -e "s/^  *//" | cut -f1 -d" " `
+        #echo $ENDINDEX
+        NUMLINES=`expr $ENDINDEX - $STARTINDEX + 1`
+        echo Copying ${NUMLINES} lines from $FILE to $OUTFILE
+        tail -n ${NUMLINES} $FILE > ${OUTFILE}
+done

Propchange: db/jdo/bin/behead
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message