#!/bin/sh
## Copyright 1989, Jeff Beadles.  Permission is granted to freely distribute.
## Submittor:	Jeff Beadles   jeff@quark.WV.TEK.COM
## Name:	fixnewsrc
## Date:	Sun Oct  1 09:25:33 PDT 1989
## Machine:	BSD Unix
## OS:		unix
## Version:	1.0
## Synopsis:	Fix long lines in .newsrc
##
## Description:
##
##	This program will take the long lines created by rn in a .newsrc
##	file, and shorten with them.  (mark all articles as read)
##	It takes lines that look like this:
##
##  talk.politics.misc! 1-1234,1235-19210,19212,19245-20322
##
##	and changes it to:
##
##  talk.politics.misc! 1-20322
##
##	This helps, as if you try to use 'vi', it chokes on lines longer
##	than 1024 characters or so.  Also, it probably speeds up the
##	start-up time of rn.
##
##	When done, a backup copy of .newsrc is saved in .newsrc.old
##

## Change directory to the user's home directory
cd

## Check for a .newsrc file.
if [ ! -f .newsrc ] ; then
	echo "$0: .newsrc not found."
	exit 1
fi

## Check for a .newsrc.old file, and remove if needed.
if [ -f .newsrc.old ] ; then
	rm -f .newsrc.old
fi

## Make that backup first...
cp .newsrc .newsrc.old

## There is a space and a tab in the first two []'s below.
sed '/!/s/^\([^ 	][^ 	]*\).*[,-][,-]*\([0-9][0-9]*\)$/\1 1-\2/' \
	< .newsrc.old > .newsrc
exit 0
