Subject: catman
To: None <chopps@emunix.emich.edu, amiga-dev@sun-lamp.cs.berkeley.edu>
From: Markus Landgraf <landgraf@crunch.ikp.physik.th-darmstadt.de>
List: amiga-dev
Date: 04/11/1994 17:31:46
As I tried to compile catman from src/usr.bin/man, I discovered some
bugs in the code. The first bug was, there was a segmentation fault
when the user didn't specify arguments to the program, secondly the
programm tried to reformat _all_ entries in a man subdir, so it
produced errors when trying to reformat _subdirs_. Here are my
pathes, you may use in on catman.c, if you like.

*** catman.c.orig	Sat Apr  9 10:37:41 1994
--- catman.c	Sat Apr  9 12:46:00 1994
*************** static char rcsid[] = "$Id: catman.c,v 1
*** 42,47 ****
--- 42,48 ----
  #include <limits.h>
  #include <errno.h>
  #include <err.h>
+ #include <regex.h>
  
  int             no_whatis = 0;
  int             just_print = 0;
*************** main(argc, argv)
*** 90,96 ****
  
  	if (argc > 1) 
  		usage ();
! 	if (argc == 0)
  		sp = *argv;
  
  	catman(mp, sp);
--- 91,97 ----
  
  	if (argc > 1) 
  		usage ();
! 	if (argc == 1)
  		sp = *argv;
  
  	catman(mp, sp);
*************** catman(path, section)
*** 115,120 ****
--- 116,123 ----
  	char            sysbuf[1024];
  	char           *s;
  	int             formatted = 0;
+ 	char           manpat[6];
+ 	regex_t         manre;
  
  	if (!just_whatis) {
  		for (s = section; *s; s++) {
*************** catman(path, section)
*** 144,150 ****
  			while ((dp = readdir(dirp)) != NULL) {
  				if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
  					continue;
! 
  				sprintf(manpage, "%s/%s", mandir, dp->d_name);
  				sprintf(catpage, "%s/%s", catdir, dp->d_name);
  				if ((s = strrchr(catpage, '.')) != NULL)
--- 147,162 ----
  			while ((dp = readdir(dirp)) != NULL) {
  				if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
  					continue;
! 				sprintf(manpat,".*\\.%c",*s);
! 				if(regcomp(&manre,manpat,0)==0)
! 				  {
! 				    if(regexec(&manre,dp->d_name,0,0,0))
! 				      {
! 					regfree(&manre);
! 					continue;
! 				      }
! 				    regfree(&manre);
! 				  }
  				sprintf(manpage, "%s/%s", mandir, dp->d_name);
  				sprintf(catpage, "%s/%s", catdir, dp->d_name);
  				if ((s = strrchr(catpage, '.')) != NULL)



------------------------------------------------------------------------------