#! /bin/sh
set -e
for i in "$@" ; do
	i=${i#./}
	dotdot=$(echo $i | sed -e "s|[^/]\+/|../|g" -e 's|/\?[^/]*$||')
	if test "$dotdot" ; then
		dotdot="${dotdot}/"
	fi
	sed -e "s|http://www.w3.org/Icons/w3c_home|${dotdot}w3c_home.png|"\
		-e "s|http://www.w3.org/StyleSheets/TR/W3C-REC\\(\\.css\\)\\?|${dotdot}W3C-REC.css|" \
		-e "s|\"www.w3.org/StyleSheets/TR/base.css\"|\"${dotdot}base.css\"|" \
		-e "s|\"http://www.w3.org/StyleSheets/TR/W3C-errata.css\"|\"${dotdot}W3C-errata.css\"|" \
		-e "s|http://www.w3.org/StyleSheets/TR/logo-REC.png|${dotdot}logo-REC.png|" \
		 "$i" > "$i.tmp"
	touch -r "$i" "$i.tmp"
	mv "$i.tmp" "$i"
done
