takagi@sdl990.sdl.hitachi.co.jp (Shigeyuki Takagi) (01/30/91)
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 <stdio.h> #include <ctype.h> + #include <string.h> #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"); } ======================================================================
Dan_Jacobson@ATT.COM (01/31/91)
>>>>> On 30 Jan 91 01:10:13 GMT, takagi@sdl990.sdl.hitachi.co.jp (Shigeyuki Takagi) said:
S> ! system("sort -f -u tmp.newsrc -o tmp.newsrc");
I think you'll find that this traditional UNIX tool (sort) usually
doesn't deal with "long lines" correctly. I made a .newsrc sorter
based on egrep, sort, etc. long lines disappeared quietly sometimes.
I was too lazy to get the GNU "no arbitrary limits" versions of these
traditional tools though.
[Today, however, I am a successful and relaxed GNUS newsreader, and use
Ashwin Ram's sorting stuff, soon to be in the next GNUS release, I
think. [GNUS address:
info-gnus-english-request@tut.cis.ohio-state.edu, newsgroup:
gnu.emacs.gnus]]
S> char Entry[1024];
I didn't look at your code, but this looks frighteningly hardwiredly
limited ("1024").
--
Dan_Jacobson@ATT.COM Naperville IL USA +1 708-979-6364
jacobson@delta.eecs.nwu.edu (Dan Jacobson) (01/31/91)
In article <DANJ1.91Jan30181159@cbnewse.ATT.COM> Dan_Jacobson@ATT.COM writes:
:>>>>> On 30 Jan 91 01:10:13 GMT, takagi@sdl990.sdl.hitachi.co.jp (Shigeyuki Takagi) said:
:
:S> ! system("sort -f -u tmp.newsrc -o tmp.newsrc");
:
:I think you'll find that this traditional UNIX tool (sort) usually
:doesn't deal with "long lines" correctly. I made a .newsrc sorter
:based on egrep, sort, etc. long lines disappeared quietly sometimes.
:I was too lazy to get the GNU "no arbitrary limits" versions of these
:traditional tools though.
:
:[Today, however, I am a successful and relaxed GNUS newsreader, and use
:Ashwin Ram's sorting stuff, soon to be in the next GNUS release, I
:think. [GNUS address:
:info-gnus-english-request@tut.cis.ohio-state.edu, newsgroup:
:gnu.emacs.gnus]]
:
:S> char Entry[1024];
:
:I didn't look at your code, but this looks frighteningly hardwiredly
:limited ("1024").
[And I forgot to add:] Uh, What...?: You are just sorting the number
ranges and not the order of the newsgroups themselves? Oops, that's
what I get for opening my mouth without looking at the code or
anything.
Dan_Jacobson@ATT.COM