news 2.10.2 sys file enhancement

Earl Wallace earlw at pesnta.UUCP
Wed Sep 19 15:36:46 AEST 1984


Here is a little mod to funcs2.c in news 2.10.2 that helps make the sys file
more "editable".  Blank lines are allowed and systems with lots of news group
selections can be split across lines using the escaped newline (backslash). 

Sample use:

# me, myself and I
pesnta:net,fa,mod,usa,na,world,pe,ba,ca,to,control::

# PE Tustin, Calif.
petstn:net,mod,world,na,usa,net.announce,net.adm,net.general,net.followup,\
	net.bugs,net.dcom,net.info-terms,net.lan,net.lang,net.sources,\
	net.news,net.unix,net.unix-wizards,net.ai,net.jokes,net.med,\
	net.movies,net.music,net.notes,net.space,fa.telecom,net.test,\
	net.video,net.wanted,net.micro:F:/usr/spool/batch/Bpetstn
petstn:pe,ca,to.petstn::uux - -z petstn!rnews
 
The diffs:

	codes:  + add this line
		- remove this line

---- about line 48 in funcs2.c (function "s_read") ----

	register char *p;
+       register int  c;
+       char     *e;
+       int      chop_spaces;

---- about line 52 in funcs2.c (function "s_read") ----

-       if (fgets(p, LBUFLEN, sysfile) == NULL)
-               return(FALSE);

+       /*
+        * Read  the  SUBFILE  (/usr/lib/news/sys)  from   the   current
+        * position  to  the  first  unescaped newline.  If a newline is
+        * escaped with a backslash (\) continue reading but throw  away
+        * the backslash and newline; read the next line skipping spaces
+        * and tabs until the first non-space/tab character, then  start
+        * looking   for   a   newline   again.   Skipping  the  leading
+        * spaces/tabs after a escaped newline  keeps  the  news  groups
+        * together.  If  a  line  begins  with a newline, just skip it.
+        * [earlw at pesnta.UUCP]
+        */
+       for (e=p+LBUFLEN; p < e && (*p=c=fgetc(sysfile)) != EOF; p++) {
+               if (p == bfr)
+                       continue;
+               if (*p == '\n') {
+                       if (p[-1] == '\\') {
+                               chop_spaces++;
+                               p -= 2;
+                       } else if (p[-1] == '\n')
+                               continue;
+                       else {
+                               p[1] = '\0';
+                               break;
+                       }
+               } else if (chop_spaces) {
+                       if (*p == '\t' || *p == ' ')
+                               p--;
+                       else
+                               chop_spaces = 0;
+               }
+       }
+       if(c == EOF) {
+               return (FALSE);
+       }
+       p = bfr;

-- 
Earl Wallace
UUCP:   ..!{ihnp4, ucbvax!hplabs, ucbvax!twg}!pesnta!earlw
PHONE:	(408) 727-5540 x230
USMAIL:	Perkin-Elmer Corp., Santa Clara, Calif. 95054



More information about the Comp.sources.unix mailing list