[alt.sources.patches] shar 3.43 patch 1

rhg@cpsolv.CPS.COM (Richard H. Gumpertz) (09/09/90)

Submitted-by: rhg@cpsolv.cps.com
Archive-name: shar3.43/patch01

Wouldn't you know it?  After more than a month of silence from beta testers I
finally decided to post shar 3.43 to alt.sources.  Only a few hours later a
bug report showed up!  Moby sigh.  Anyway, here is the fix for a minor bug
and an enhancement.

1) A line containing just "SHAR_EOF" in an input file now gets an 'X' prepended
in the output file even if -F is not specified.

2) The new compile-time definition NO_DIRENT indicates that the SunOS3-style
<sys/dir.h> should be used instead of Gwyn-style (or equivalent) <dirent.h>.

Thanks to Frans Meulenbroeks (meulenbr@cst.philips.nl) for reporting the two
problems.

*** /tmp/,RCSt1a01064	Sat Sep  8 22:04:42 1990
--- shar.c	Sat Sep  8 22:04:51 1990
***************
*** 1,5 ****
! char *revision = "3.43";
! char RCS_ID[] = "$Header: /u/rhg/src/shar/shar.c,v 3.43 90/08/13 07:50:34 rhg Exp $";
  /*
  ** shar.c
  
--- 1,5 ----
! char *revision = "3.44";
! char RCS_ID[] = "$Header: /u/rhg/src/shar/shar.c,v 3.44 90/09/08 22:01:39 rhg Exp $";
  /*
  ** shar.c
  
***************
*** 16,21 ****
--- 16,23 ----
  
  */
  /*+:EDITS:*/
+ /*:09-08-1990-21:20-rhg@cps.com-added NO_DIRENT for SunOS 3 sys/dir.h */
+ /*:09-08-1990-21:04-rhg@cps.com-fixed bug in PREFIX check: strcmp(line,Delim) */
  /*:08-06-1990-00:40-rhg@cps.com-revised Cut message to be more explanatory */
  /*:08-05-1990-14:04-rhg@cps.com-merged Rname into walktree */
  /*:08-05-1990-12:11-rhg@cps.com-added walktree & support for sharing dirs */
***************
*** 584,592 ****
  
  #else /* NO_WALKTREE*/
  
  #include <dirent.h>			/* Doug Gwyn's dirent routines */
  DIR *opendir();
! struct dirent *readdir();
  int closedir();
  
  int
--- 586,605 ----
  
  #else /* NO_WALKTREE*/
  
+ #ifdef NO_DIRENT
+ 
+ #include <sys/dir.h>			/* SunOS 3, etc. */
+ #define DIRENTRY struct direct
+ 
+ #else /* NO_DIRENT */
+ 
  #include <dirent.h>			/* Doug Gwyn's dirent routines */
+ #define DIRENTRY struct dirent
+ 
+ #endif /* NO_DIRENT */
+ 
  DIR *opendir();
! DIRENTRY *readdir();
  int closedir();
  
  int
***************
*** 596,602 ****
  int filelen;
  {
  	DIR *dirp;
! 	struct dirent *dp;
  
  	if(stat(file,&fst))
  	{
--- 609,615 ----
  int filelen;
  {
  	DIR *dirp;
! 	DIRENTRY *dp;
  
  	if(stat(file,&fst))
  	{
***************
*** 1084,1093 ****
  		while(fgets(line,BUFSIZ,fpsource))
  		{ /* output a line and test the length */
  			if(OptPREFIX && isgraph(line[0]) && line[0] != PREFIX
  #ifdef STRNCMP_IS_FAST
! 			   && strncmp(line,"exit 0",6))	/* See "unshar -e" */
  #else /* STRNCMP_IS_FAST */
! 			   && (line[0] != 'e' || strncmp(line,"exit 0",6))) /* unshar -e */
  #endif /* STRNCMP_IS_FAST */
  				fputs(line,fpout);
  			else
--- 1097,1111 ----
  		while(fgets(line,BUFSIZ,fpsource))
  		{ /* output a line and test the length */
  			if(OptPREFIX && isgraph(line[0]) && line[0] != PREFIX
+ #ifdef STRCMP_IS_FAST
+ 			   && strcmp(line,Delim)
+ #else /* STRCMP_IS_FAST */
+ 			   && line[0] != Delim[0]
+ #endif /* STRCMP_IS_FAST */
  #ifdef STRNCMP_IS_FAST
! 			   && strncmp(line,"exit 0",6))	/* See unshar -e: avoid "exit 0" */
  #else /* STRNCMP_IS_FAST */
! 			   && (line[0] != 'e'))			/* See unshar -e: avoid "exit 0" */
  #endif /* STRNCMP_IS_FAST */
  				fputs(line,fpout);
  			else
-- 
  ==========================================================================
  | Richard H. Gumpertz    rhg@CPS.COM    (913) 642-1777 or (816) 891-3561 |
  | Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749 |
  ==========================================================================