function formatpatch
{
# --- src/gdb/ChangeLog 2008/04/24 08:46:17 1.9308
- diffdecvs | if [ -z "$changelog" ];then perl -p -e '$c=1 if s{^(?:---|\Q+++\E)(?= \S+/ChangeLog\t)}{###};s{^@@}{##} if $c;'; else cat; fi
+ diffdecvs | if [ -z "$changelog" ];then perl -p -e '$r=qr/^(?:---|\Q+++\E) /o;$c=0 if m{$r}o;$c=1 if s{$r(?=\S+/ChangeLog(?:\t|$))}{### }o;s{^@@}{##} if $c;'; else cat; fi
}
-for arg in "$@";do
+if [ "$*" = "-f" ];then
+ formatpatch
+else for arg in "$@";do
+ arg="$(echo "$arg"|sed 's/^https:/http:/')"
# http://sourceware.org/ml/gdb-cvs/2099-99/msg99999.html
if [ "$arg" != "${arg#http://sources.redhat.com/}" ];then
arg="http://sourceware.org/${arg#http://sources.redhat.com/}"
echo >&2 -n '+'
echo "$arg"
echo
- changelogget -q $changelog $(wget -q -O - "$arg" | sed -n -e 's/&/\&/g' -e 's#^<a \+href="\(.*\)">\1</a>$#\1#p')
+ changelogget -q $changelog $(wget -q -O - "$arg" | sed -n -e 's/&/\&/g' -e 's#^<a \+\(rel="nofollow"\)\? *href="\(.*\)">\2</a>$#\2#p')
elif [ "$arg" != "${arg#http://gcc.gnu.org/viewcvs[?]view=revision&revision=}" ];then
echo >&2 -n '+'
echo "$arg"
echo >&2 "Invalid URL: $arg"
exit 1
fi
-done
+done;fi
if $v;then
echo >&2 OK
fi