[CLN-list] [PATCH] Use file names relative to the source directory in the #include directives.

Alexei Sheplyakov varg at theor.jinr.ru
Tue Feb 12 10:21:01 CET 2008


Hello!

I've got tired typing "find src -type f -name 'cl_foo.h'" ever and ever, hence
this patch:

http://theor.jinr.ru/~varg/patchbomb/0001-Use-file-names-relative-to-the-source-directory-in-t.patch.bz2

(I don't post it here since it's quite big: ~ 500kb uncompressed).

All (except src/Makefile.in) hunks were automagically generated with
the following shell script:

if [ ! -f src/base/cl_free.cc ]; then
    	echo "`basename $0`: please chdir to the CLN top source directory."
    	exit 2
fi

FILES=$(find src -type f -name '*.cc' -or -name '*.h' | \
    	xargs grep -l -e '#include\ "cl_.*\.h' | sort -n | uniq)

SED_SCRIPT=$0.sed
for FILE in $FILES; do
	sed -n -e \
    	's,^#include[ \t]\+\"cl_\([^.]\+\)\.\(h\|\(cc\)\)\"[ \t]*$,cl_\1.\2,p' \
    	$FILE
done | sort -n | uniq | \
while read inc; do
    	real_inc=$(find src -type f -name $inc)
    	if [ `echo $real_inc | wc -l` -ge 2 ]; then
    		echo "***" >&2
    		echo "*** ${inc} included by $FILE is ambigous" >&2
    		echo "***" >&2
    		exit 1
    	elif [ -z "$real_inc" ]; then
    		# Probably configure-generated file?
    		inc_in=$(find src -type f -name ${inc}.in)
    		if [ -n "inc_in" ]; then
    			real_inc=${inc_in%%.in}
    		fi
    	fi
    	if [ -n "$real_inc" ]; then
    		echo "s%^#include[ \\\\t]\\+\\\"${inc}\\\"%#include\\ \\\"${real_inc##src/}\\\"%g"
    	fi
done | sort -n | uniq > $SED_SCRIPT

for FILE in $FILES; do
    	sed --in-place=.bak -f $SED_SCRIPT $FILE
done


Best regards,
	Alexei

-- 
All science is either physics or stamp collecting.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/cln-list/attachments/20080212/77bff2ce/attachment.sig 


More information about the CLN-list mailing list