Subject: Re: CVS commit: basesrc/usr.bin/asa
To: Thomas Klausner <wiz@netbsd.org>
From: enami tsugutomo <enami@but-b.or.jp>
List: source-changes
Date: 05/02/2002 23:14:08
> Fix segfaults when last argument does not exist as suggested in bin/16565
> by Ryan Younce.
> 
> To generate a diff of this commit:
> cvs rdiff -r1.12 -r1.13 basesrc/usr.bin/asa/asa.c

This is more clear isn't it? (if there is command line args, proccess
it while there are, otherwise process stdin).

enami.
Index: asa.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/asa/asa.c,v
retrieving revision 1.14
diff -c -r1.14 asa.c
*** asa.c	2002/05/02 13:59:25	1.14
--- asa.c	2002/05/02 14:04:35
***************
*** 50,69 ****
  	/* skip progname */
  	argv++;
  
! 	fp = stdin;
! 	do {
! 		if (*argv) {
! 			if (!(fp = fopen(*argv, "r"))) {
  				warn("%s", *argv);
- 				++argv;
  				continue;
  			}
! 			++argv;
! 		}
! 		asa(fp);
! 		if (fp != stdin)
  			(void)fclose(fp);
! 	} while (*argv);
  
  	exit(0);
  }
--- 50,66 ----
  	/* skip progname */
  	argv++;
  
! 	if (*argv != NULL)
! 		do {
! 			if ((fp = fopen(*argv, "r")) == NULL) {
  				warn("%s", *argv);
  				continue;
  			}
! 			asa(fp);
  			(void)fclose(fp);
! 		} while (*++argv != NULL);
! 	else
! 		asa(stdin);
  
  	exit(0);
  }