Neat little .newsrc fixer-upper.

The Beach Bum jfh at killer.UUCP
Tue Apr 26 15:56:22 AEST 1988


Not only is this an inappropriate posting, it is an intentional posting.
But hey, this turned out to be a real handy three minute hack.

This little toy takes your (possibly uneditable) .newsrc and removes
all the garbage between 1 and the last article you read.  i wrote it
because my .newsrc on killer was in bad shape and couldn't be edited
because some of the lines were too long.  this could be written much
better, with a man page and all, but then it might get posted to a
source group!

just copy the source between my name below and my .sig into fixrc.c
and compile.  then run with stdin as your newsrc and stdout as where
you want the new one to go.  just make sure the two aren't the same
file!

- john.
--
#include <stdio.h>

main ()
{
	int	c;
	int	i;
	char	low[8];
	char	high[8];

	while ((c = getchar ()) != EOF) {
		do {
			putchar (c);
		} while ((c = getchar ()) != ' ' && c != EOF);

		if (! getnum (low)) {
			while ((c = getchar ()) != '\n' && c != EOF)
				putchar (c);
			putchar ('\n');
			continue;
		}
		while ((c = getchar ()) != '\n' && c != EOF)
			getnum (high);

		printf (" %s-%s\n", low, high);
	}
}

getnum (s)
char	*s;
{
	int	c;
	int	i = 0;

	while ((c = getchar ()) != EOF && c >= '0' && c <= '9')
		s[i++] = c;

	if (c != EOF)
		ungetc (c, stdin);

	if (i == 0)
		return (0);

	s[i++] = 0;

	return (i);
}
-- 
John F. Haugh II                  SNAIL:  HECI Exploration Co. Inc.
UUCP: ...!ihnp4!killer!jfh                11910 Greenville Ave, Suite 600
"You can't threaten us, we're             Dallas, TX. 75243
  the Oil Company!"                       (214) 231-0993 Ext 260



More information about the Comp.unix.questions mailing list