[net.bugs] bug fix to soelim

puder (11/11/82)

There is a bug in soelim in that it doesn't notice whether the .so is at the
beginning of the line.  This means that you can't soelim a file that talks
about net.sources, for example.  A fix follows.  If you find a bug in this
fix, please let me or the net know about it.


*** /usr/src/cmd/soelim.c.old	Wed Oct  1 20:59:43 1980
--- /usr/src/cmd/soelim.c	Wed Nov 10 18:30:59 1982
***************
*** 15,20
   *
   * This program is more generally useful, it turns out, because
   * the program tbl doesn't understand ".so" directives.
   */
  
  main(argc, argv)

--- 15,23 -----
   *
   * This program is more generally useful, it turns out, because
   * the program tbl doesn't understand ".so" directives.
+  *
+  * Beginning of line flag added
+  * by Karl Puder, November 10, 1982
   */
  
  main(argc, argv)
***************
*** 43,48
  	register int c;
  	char fname[BUFSIZ];
  	FILE *soee;
  
  	soee = fopen(file, "r");
  	if (soee == NULL) {

--- 46,52 -----
  	register int c;
  	char fname[BUFSIZ];
  	FILE *soee;
+ 	int begOfLine;	/* beginning of line flag */
  
  	soee = fopen(file, "r");
  	if (soee == NULL) {
***************
*** 49,54
  		perror(file);
  		return;
  	}
  	for (;;) {
  		c = getc(soee);
  		if (c < 0)

--- 53,59 -----
  		perror(file);
  		return;
  	}
+ 	begOfLine = 1;
  	for (;;) {
  		c = getc(soee);
  		if (c < 0)
***************
*** 53,58
  		c = getc(soee);
  		if (c < 0)
  			break;
  		if (c != '.')
  			goto simple;
  		c = getc(soee);

--- 58,67 -----
  		c = getc(soee);
  		if (c < 0)
  			break;
+ 		if (! begOfLine)	/* note that the begOfLine flag is
+ 					 * left on during the grabbing of the
+ 					 * .so command and file name * kop */
+ 			goto simple;
  		if (c != '.')
  			goto simple;
  		c = getc(soee);
***************
*** 96,101
  		if (c == EOF)
  			break;
  		putchar(c);
  	}
  	fclose(soee);
  }

--- 105,114 -----
  		if (c == EOF)
  			break;
  		putchar(c);
+ 		if (c == '\n')
+ 			begOfLine = 1;
+ 		else
+ 			begOfLine = 0;
  	}
  	fclose(soee);
  }