Patch: remove nntp protocol constants from include/nntp.h in inn-CURRENT-20061121

Adam J. Richter adam at yggdrasil.com
Wed Nov 22 15:13:45 UTC 2006


I wrote:
>	The change is entirely the output of a shell script, which I can
>also post if there is interest [...]

	Come to think of it, since there two daily snapshot trees and
released versions, I really should post the script to have it in the
mail list archives, even if nobody cares about it right now, just in
case someone decides later to do the same change to one of the other
trees.  Here it is.

Adam Richter

----------------------------------------------------------------------
#!/bin/sh

mkdir -p /tmp/unpack
rm -rf /tmp/unpack/inn-CURRENT

cd /tmp/unpack || exit 1
tar xfpz /tmp/inn-CURRENT-20061121.tar.gz || exit 1
mv inn-CURRENT-20061121 inn-CURRENT || exit 1
cd /tmp/unpack/inn-CURRENT || exit 1

replace_everywhere()
{
	local pattern="$1"
	local replacement="$2"
	local file

	for file in $(find . -type f | xargs grep -l "$pattern") ; do
		ed -s $file << DONE
1,\$s|$pattern|$replacement|g
w
q
DONE
	done
}

rm -rf /tmp/vals
mkdir -p /tmp/vals/{new,old}

egrep ^#define include/nntp.h |
	egrep -v '"' |
	egrep -v \'.\*\' |
	( while read define sym val junk ; do
		if [ -e /tmp/vals/old/$val ] ;then
			echo Duplicate old: $val
		 fi
		echo $sym >> /tmp/vals/old/$val
	  done )


egrep '=' include/inn/nntp.h |
	( while read sym equal val junk ; do
		val=${val%,}
		if [ -e /tmp/vals/new/$val ] ; then
			echo Duplicate new: $val
		fi
		echo $sym >> /tmp/vals/new/$val
	  done )

# These are message lengths rather than command codes:
rm /tmp/vals/old/{250,512}

for symbol in $(cat /tmp/vals/old/*) ; do echo "#define $symbol " ; echo "#define $symbol	" ; done > /tmp/removable
fgrep -v -f /tmp/removable include/nntp.h > /tmp/small-nntp.h
( head -23 /tmp/small-nntp.h ; echo '' ; echo '#include "inn/nntp.h"' ; echo '' ; tail +24 /tmp/small-nntp.h ) > include/nntp.h

ed include/nntp.h <<EOF
1,\$s|NNTP_CONT_XBATCH	|NNTP_CONT_XBATCH_STR	|g
w
q
EOF

ed innd/nc.c <<EOF
1,\$s|NNTP_CONT_XBATCH|NNTP_CONT_XBATCH_STR|g
w
q
EOF


ed backends/innxbatch.c <<EOF
1,\$s|NNTP_RESENDIT_VAL|NNTP_FAIL_XBATCH|g
w
q
EOF

replace_everywhere NNTP_RESENDIT_VAL NNTP_FAIL_IHAVE_DEFER
replace_everywhere NNTP_AUTH_BAD_VAL NNTP_FAIL_AUTHINFO_BAD
replace_everywhere NNTP_OK_RECID_VAL NNTP_OK_TAKETHIS
replace_everywhere NNTP_OK_XBATCHED_VAL NNTP_OK_XBATCH
replace_everywhere NNTP_XGTITLE_BAD NNTP_FAIL_XGTITLE




rm /tmp/vals/old/{481,239}

# Leave NNTP_CONT_XBATCH alone for the moment
# rm /tmp/vals/old/339

vals=$(cd /tmp/vals/old && echo [0-9]*)
for val in $vals ; do
	for old in $(cat /tmp/vals/old/$val) ; do
		replace_everywhere $old $(cat /tmp/vals/new/$val)
	done
done

./configure --prefix=/usr && make all
# ./configure --prefix=/usr && make all && make install
find . -name '*.o' | xargs strip
find . -name '*.o' |
	( while read file ; do
		cmp $file /tmp/inn-CURRENT-20061121/$file
	  done )



More information about the inn-workers mailing list