update_headers.sh 1.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

# $Id: update_headers.sh 5393 2008-01-18 12:20:54Z zalila $

# This script has to ve invoked from the PolyORB-HI main directory

headers_po_hi="support/headers_po_hi"

usage () {
    cat <<EOF
Usage: ${0} [OPTIONS]
Options:
        No option:
           Update the Copyright headers only for the newly added files and
           the modified files (using SVN).

        [all]
           Updates the Copyright headers of all files.
EOF
}

if ! test -x ${headers_po_hi}; then
    make -C support headers-po_hi
fi;

if test $# = 0 ; then
    echo "Updating headers for changed and new files"
    
    changed_files=`svn status -q | grep "^[M]" | grep '\.\(\([ch]\)\)' | awk '{print $NF}'`
    added_files=`svn status -q | grep "^[A]" | grep '\.\(\([ch]\)\)' | awk '{print $NF}'`
    
    # For changed files, update the header

    for i in ${changed_files}; do
	${headers_po_hi} ${i}
    done

    # For Added files, create a new header

    for i in ${added_files}; do
	${headers_po_hi} -noh ${i} > /dev/null 2>&1
	${headers_po_hi} ${i}
    done
else
    if test x${1} = xall ; then
	echo "Updating headers for all files"
	
	find . -name "*.c" -exec ${headers_po_hi} $1 '{}' \;
	find . -name "*.h" -exec ${headers_po_hi} $1 '{}' \;
    else
	usage 1>&2
	exit 1
    fi
fi

exit 0