On Thursday 05 September 2002 8:08 am, Lars Gullik Bjønnes wrote:

> | Just so I'm perfectly clear:
> |
> | /*
> |  *  \file PreviewLoader.C
> |  *  Read the file COPYING
> |  *
> |  * \author Angus Leeming
> |  *
> |  * Full author contact details available in file CREDITS
> |  */

The script below will modify existing "new style" headers to the format 
above. I applied it successfully to files in src/graphics.

Angus

#! /bin/sh

for FILE in $*
do
        SED=${FILE}.sed
        cat - > ${SED} <<EOF
# delete all lines containing "the LyX Team"
/[tT][hH][eE] [lL][yY][xX] [Tt][eE][aA][mM]/d

# On lines 1 and 2 of the file only, replace /* with /**
1,2 s/^\/\*$/\/**/

# delete an email address
/\\author/s/\(.*\),\(.*\)/\1/

# delete an email address
/\\author/s/\(.*\)\([   ]*\)<\(.*\)>/\1/
EOF

        LINES=`grep -n '\author' ${FILE}`
        if [ $? -eq 0 ]; then
                LINES=`echo "${LINES}" | sed 's/\([0-9]*\):\(.*\)/\1/'`
                LINE=`echo "${LINES}" | sed '$ !d'`
                cat - >> ${SED} <<EOF

# append this line after the last occurance of author
${LINE} a\\
 *\\
 * Full author contact details available in file CREDITS
EOF
        fi

        TMP=${FILE}.tmp
        sed -f ${SED} < ${FILE} > ${TMP}
        rm -f ${SED}

        cmp -s ${FILE} ${TMP}
        if [ $? -eq 1 ]; then
                diff -u ${FILE} ${TMP}
                mv -i ${TMP} ${FILE}
        fi
        rm -f ${TMP}
done

Reply via email to