5 # Author: Andrew Dunstan
7 # Script to add PostgreSQL markers to source files that are lacking them.
8 # currently only works for .c and .h files
10 # Needs a sed that understands the -i switch.
11 # Really only tested on my Linux box.
13 # We try to avoid adding markers to third party files, or files that will
14 # cause regression problems (e.g. some ecpg headers).
16 # If the file begins with a comment, we put the marker in there,
17 # otherwise we add a new comment at the top of the file. This makes things
20 # This script should be run at the top of the source tree.
21 # If we're in the tools directory, the script tries to take us to the
24 test "`basename $CWD`" = "tools" && cd ..
/..
26 # need a dummy file in case we don't find any with missing markers,
27 # to suppress messages about sed not finding any input files
30 # first process the files that already start with a comment:
32 find . \
( \
( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \
33 -o -name 'regression.h' -o -name 'sql3types.h' -o -name 'sqlca.h' \
) \
34 -prune \
) -o \
( -name '*.[ch]' \
) \
( -exec grep -q '\$PostgreSQL' {} \
; \
36 { while read file ; do
37 head -n 1 < $file |
grep -q '^/\*' && echo $file
38 done ; echo dummy
;} | \
39 xargs -l sed -i -e '1s/^\// /' -e '1i/*\n * \x24PostgreSQL:$ \n *'
41 # now all the rest (i.e. the files that don't start with a comment)
43 { find . \
( \
( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \
44 -o -name 'regression.h' -o -name 'sql3types.h' -o -name 'sqlca.h' \
) \
45 -prune \
) -o \
( -name '*.[ch]' \
) \
( -exec grep -q '\$PostgreSQL' {} \
; \
46 -o -print \
) ; echo dummy
;} | \
47 xargs -l sed -i -e '1i/*\n * \x24PostgreSQL:$ \n */'