Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site crystal.ARPA Path: utzoo!linus!philabs!seismo!uwvax!solomon From: solomon@uwvax.UUCP Newsgroups: net.news Subject: Re: A gripe about 2.10 readnews - (nf) Message-ID: <222@crystal.ARPA> Date: Sat, 18-Jun-83 15:17:22 EDT Article-I.D.: crystal.222 Posted: Sat Jun 18 15:17:22 1983 Date-Received: Sun, 19-Jun-83 17:57:30 EDT References: <2248@uiucdcs.UUCP> Organization: U of Wisconsin CS Dept Lines: 72 Yep, if PAGER is /usr/ucb/more, having it read its input from the news article itself rather than a pipe is a real win. It's even better if you exec() it rather than popen() or system() it, since that's much faster. I hacked it into version 2.9 b news a long time ago and it works just fine. I haven't gotten around to putting it into 2.10 news yet, but it should be just about the same. The changes to news version 2.9 follow. As you can see, it's really quite simple. (Sorry about the long lines. This looks much better if you set tabstops every 4 positions rather than every 8.) Marvin Solomon Computer Sciences Department University of Wisconsin, Madison WI solomon@uwisc ...!seismo!uwvax!solomon *** orig/readr.c Sun Oct 3 09:53:15 1982 --- ./readr.c Fri Apr 22 10:02:47 1983 *** 84,89 FILE *pfp, *popen(); int cnt; pfp = popen(PAGER, "w"); if (pfp == NULL) pfp = ofp; --- 85,121 ----- FILE *pfp, *popen(); int cnt; + /* solomon@uwisc, 10/3/82: + * special hack if PAGER=PAGE (/usr/ucb/more) + * treat it as if it were "PAGE %", but without + * the overhead of forking a shell. + * The advantage of this over using popen() is + * that "more" has a file to work with, so it + * can do good things like tell how much remains. + */ + if (strcmp(PAGER,PAGE)==0) { + char offset[20]; + int pos, nlines, child; + + /* find the current line number in the file */ + pos = ftell(fp); + fseek(fp,0L,0); + nlines = 0; + while (pos--) + if(getc(fp)=='\n') + nlines++; + sprintf(offset,"+%d",nlines); + + if ((child=fork())==0) { + execl(PAGER,PAGER,offset,filename,0); + } + else + (void) fwait(child); + fclose(fp); + fp = NULL; + sigtrap = FALSE; + goto nextart; + } pfp = popen(PAGER, "w"); if (pfp == NULL) pfp = ofp; *************** -- Marvin Solomon Computer Sciences Department University of Wisconsin, Madison WI solomon@uwisc ...!seismo!uwvax!solomon