Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!mintaka!think.com!sdd.hp.com!elroy.jpl.nasa.gov!ames!sun-barr!ccut!s.u-tokyo!rkna50!nttlab!icot32!hitgw!sdl990!takagi From: takagi@sdl990.sdl.hitachi.co.jp (Shigeyuki Takagi) Newsgroups: comp.sources.d Subject: newsclean - tool to cleanup .newsrc, Part01/01 unofficial patch Message-ID: <2737@sdl990.sdl.hitachi.co.jp> Date: 30 Jan 91 01:10:13 GMT References: <1991Jan17.224730.28459@sparky.IMD.Sterling.COM> <2645@sdl990.sdl.hitachi.co.jp> Organization: Systems Development Lab., Hitachi Ltd., JAPAN Lines: 160 In article <2645@sdl990.sdl.hitachi.co.jp> takagi@sdl990.sdl.hitachi.co.jp (Shigeyuki Takagi) writes: >In article <1991Jan17.224730.28459@sparky.IMD.Sterling.COM> kluge@informatik.tu-muenchen.dbp.de (Oliver Kluge) writes: ::Submitted-by: kluge@informatik.tu-muenchen.dbp.de (Oliver Kluge) ::Posting-number: Volume 16, Issue 81 ::Archive-name: newsclean/part01 ::This program compacts the .newsrc file of the rrn news reader. It >1. "options" line does not handled correctly. >2. comp.lang.c++ and com.std.c++ lines are removed. > I unsubscribed these groups, and they are cleared away. These problems are fixed. context diff follows. S. Takagi, takagi@sdl990.sdl.hitachi.co.jp ====================================================================== *** newsclean.c Mon Jan 21 10:39:40 1991 --- newsclean2.c Wed Jan 30 10:02:01 1991 *************** *** 26,34 **** --- 26,39 ---- | as the copyright is not removed. | | | |=============================================| */ + /* 2 problems are fixed by S. Takagi, 1991-jan-21 */ + /* 1: options line is now being handled correctly. */ + /* 2: -d option for sort is removed + to handle comp.lang.c++ and comp.std.c++. */ #include #include + #include #define FALSE 0 #define TRUE !FALSE *************** *** 42,47 **** --- 47,53 ---- int i, Mark; int EndOfInput; char Entry[1024]; + char c; Newsrc = fopen(".newsrc", "r"); Cleaned = fopen("rec.newsrc", "w"); *************** *** 49,55 **** do { EndOfInput = fscanf(Newsrc, "%s", Entry); if (EndOfInput!=EOF) { ! if (!isdigit(Entry[0])) { /* Newsgroup name */ /* Start search after subscription mark! */ --- 55,67 ---- do { EndOfInput = fscanf(Newsrc, "%s", Entry); if (EndOfInput!=EOF) { ! if (strcmp(Entry, "options") == 0) { ! fprintf(Cleaned, "%s", Entry); ! do { ! fputc(c = getc(Newsrc), Cleaned); ! } while (c != '\n'); ! } ! else if (!isdigit(Entry[0])) { /* Newsgroup name */ /* Start search after subscription mark! */ *************** *** 113,119 **** main() { FILE *fopen(), *Newsrc, *Cleaned, *Temp; ! char Entry[1024]; int Subscribed, EndOfInput, NoArticle; printf ("NewsClean - Version 1.20 (c) 17.1.1991 Oliver Kluge\n"); --- 125,131 ---- main() { FILE *fopen(), *Newsrc, *Cleaned, *Temp; ! char Entry[1024], c; int Subscribed, EndOfInput, NoArticle; printf ("NewsClean - Version 1.20 (c) 17.1.1991 Oliver Kluge\n"); *************** *** 133,139 **** do { EndOfInput = fscanf(Newsrc, "%s", Entry); if (EndOfInput!=EOF) { ! if (!isdigit(Entry[0])) { /* Got a newsgroup name! */ if (Entry[strlen(Entry)-1]==':') { /* It is subscribed-to */ --- 145,157 ---- do { EndOfInput = fscanf(Newsrc, "%s", Entry); if (EndOfInput!=EOF) { ! if (strcmp(Entry, "options") == 0) { ! fprintf(Cleaned, "%s", Entry); ! do { ! fputc(c = getc(Newsrc), Cleaned); ! } while (c != '\n'); ! } ! else if (!isdigit(Entry[0])) { /* Got a newsgroup name! */ if (Entry[strlen(Entry)-1]==':') { /* It is subscribed-to */ *************** *** 165,171 **** /* Now let UNIX's sort do the alphabetical sorting of the unsubscribed newsgroups. */ ! system("sort -d -f -u tmp.newsrc -o tmp.newsrc"); /* And reunite the subscribed and the unsubscribed to form the new .newsrc */ --- 183,190 ---- /* Now let UNIX's sort do the alphabetical sorting of the unsubscribed newsgroups. */ ! /* -d option in the original is removed. S. Takagi 1991-Jan-21 */ ! system("sort -f -u tmp.newsrc -o tmp.newsrc"); /* And reunite the subscribed and the unsubscribed to form the new .newsrc */ *************** *** 178,184 **** /* Newsgroup names first */ EndOfInput = fscanf(Newsrc, "%s", Entry); if (EndOfInput!=EOF) { ! if (!isdigit(Entry[0])) { /* Newsgroup name */ if (NoArticle==TRUE) fprintf(Cleaned, "\n"); fprintf(Cleaned, "%s", Entry); --- 197,209 ---- /* Newsgroup names first */ EndOfInput = fscanf(Newsrc, "%s", Entry); if (EndOfInput!=EOF) { ! if (strcmp(Entry, "options") == 0) { ! fprintf(Cleaned, "%s", Entry); ! do { ! fputc(c = getc(Newsrc), Cleaned); ! } while (c != '\n'); ! } ! else if (!isdigit(Entry[0])) { /* Newsgroup name */ if (NoArticle==TRUE) fprintf(Cleaned, "\n"); fprintf(Cleaned, "%s", Entry); *************** *** 206,211 **** --- 231,237 ---- fclose(Cleaned); /* Now trash the temporary files */ + unlink("rec.newsrc"); unlink("new.newsrc"); unlink("tmp.newsrc"); } ======================================================================