head	1.3;
access;
symbols
	REL9_0_0:1.2
	REL9_1_ALPHA1:1.3
	REL9_0_RC1:1.2
	REL9_0_BETA4:1.2
	REL9_0_STABLE:1.2.0.14
	REL9_0_BETA3:1.2
	REL9_0_BETA2:1.2
	REL8_4_4:1.2
	REL9_0_BETA1:1.2
	REL9_0_ALPHA5_BRANCH:1.2.0.12
	REL9_0_ALPHA5:1.2
	REL8_4_3:1.2
	REL9_0_ALPHA4:1.2
	REL9_0_ALPHA4_BRANCH:1.2.0.10
	REL8_5_ALPHA3:1.2
	REL8_5_ALPHA3_BRANCH:1.2.0.8
	REL8_4_2:1.2
	REL8_5_ALPHA2:1.2
	REL8_5_ALPHA2_BRANCH:1.2.0.6
	REL8_4_1:1.2
	REL8_5_ALPHA1:1.2
	REL8_5_ALPHA1_BRANCH:1.2.0.4
	REL8_4_STABLE:1.2.0.2
	REL8_4_0:1.2
	REL8_4_RC2:1.2
	REL8_4_RC1:1.2
	REL8_4_BETA2:1.2
	REL8_4_BETA1:1.2;
locks; strict;
comment	@# @;


1.3
date	2010.08.19.05.57.35;	author petere;	state Exp;
branches;
next	1.2;

1.2
date	2008.06.15.21.58.55;	author adunstan;	state Exp;
branches;
next	1.1;

1.1
date	2008.06.15.21.46.02;	author adunstan;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Remove extra newlines at end and beginning of files, add missing newlines
at end of files.
@
text
@#!/bin/sh

# $PostgreSQL: pgsql/src/tools/add_cvs_markers,v 1.2 2008/06/15 21:58:55 adunstan Exp $

# Author: Andrew Dunstan

# Script to add PostgreSQL markers to source files that are lacking them.
# currently only works for .c and .h files

# Needs a sed that understands the -i switch. 
# Really only tested on my Linux box.

# We try to avoid adding markers to third party files, or files that will
# cause regression problems (e.g. some ecpg headers).

# If the file begins with a comment, we put the marker in there, 
# otherwise we add a new comment at the top of the file. This makes things
# a bit prettier.

# This script should be run at the top of the source tree. 
# If we're in the tools directory, the script tries to take us to the 
# right spot.
CWD=`pwd`
test "`basename $CWD`" = "tools" && cd ../.. 

# need a dummy file in case we don't find any with missing markers,
# to suppress messages about sed not finding any input files
touch dummy

# first process the files that already start with a comment:

find . \( \( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \
     -o -name 'regression.h' -o -name 'sql3types.h' -o -name 'sqlca.h' \) \
     -prune \) -o  \( -name '*.[ch]' \) \( -exec grep -q '\$PostgreSQL' {} \; \
     -o -print \) | \
  { while read file ; do 
      head -n 1 < $file | grep -q '^/\*' && echo $file 
    done ; echo dummy ;} |  \
  xargs -l sed -i -e '1s/^\// /' -e '1i/*\n * \x24PostgreSQL:$ \n *'

# now all the rest (i.e. the files that don't start with a comment)

{ find . \( \( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \
     -o -name 'regression.h' -o -name 'sql3types.h' -o -name 'sqlca.h' \) \
     -prune \) -o  \( -name '*.[ch]' \) \( -exec grep -q '\$PostgreSQL' {} \; \
     -o -print \) ; echo dummy ;} | \
  xargs -l sed -i -e '1i/*\n * \x24PostgreSQL:$ \n */'

rm -f dummy
@


1.2
log
@Prevent CVS from mangling script
@
text
@d3 1
a3 1
# $PostgreSQL: pgsql/src/tools/add_cvs_markers,v 1.1 2008/06/15 21:46:02 adunstan Exp $
a49 1

@


1.1
log
@Add script to find .c and .h files that are missing CVS PostgreSQL markers
and add them. Avoids third party files or those that would cause regression
failures.
@
text
@d3 1
a3 1
# $PostgreSQL:$
d39 1
a39 1
  xargs -l sed -i -e '1s/^\// /' -e '1i/*\n * $PostgreSQL:$ \n *'
d47 1
a47 1
  xargs -l sed -i -e '1i/*\n * $PostgreSQL:$ \n */'
@

