[net.sources.bugs] patch for new shar

ken@rochester.ARPA (SKY) (03/07/87)

Rogue Monster's shar works very fast but I edited it to use getopt
instead of getarg. The world doesn't need yet another getopt
lookalike.  Getopt is standard in many Unix distributions now. If you
don't have it, rumage through old source postings.

The -o option doesn't seem to work. How about a man page too?

	Ken

*** Orig/shar.c	Sat Mar  7 00:53:31 1987
--- shar.c	Sat Mar  7 01:06:38 1987
***************
*** 17,23 ****
  extern int strlen();
  extern char *strcpy();
  extern int strcmp();
! extern int getarg();
  extern stat();
  extern char strcat();
  extern long atol();
--- 17,23 ----
  extern int strlen();
  extern char *strcpy();
  extern int strcmp();
! extern int getopt();
  extern stat();
  extern char strcat();
  extern long atol();
***************
*** 529,535 ****
     *	-p			=	use original permissions
     *	-q			=	generate quite code
     */
!   while ((c = getarg(argc,argv,"cf:im:opq")) != EOF)
      switch (c){
        case 'c':
          Check = 1;
--- 529,535 ----
     *	-p			=	use original permissions
     *	-q			=	generate quite code
     */
!   while ((c = getopt(argc,argv,"cf:im:opq")) != EOF)
      switch (c){
        case 'c':
          Check = 1;
***************
*** 553,567 ****
        case 'q':
          Quiet = 1;
          break;
!       case '?':
          fprintf(stderr,"Unknown switch: -%c\n",c);
          break;
!       default:
          /*
           *	File names can be absolute or relative, decide which
           *	tree the filename goes in.
           */
!         SourceName = optarg;
          if (*optarg == '/')
            tre = ParseFileName(&Abs,++optarg);
          else
--- 553,568 ----
        case 'q':
          Quiet = 1;
          break;
!       default:
          fprintf(stderr,"Unknown switch: -%c\n",c);
          break;
!     }
!   while (optind < argc){
          /*
           *	File names can be absolute or relative, decide which
           *	tree the filename goes in.
           */
!         SourceName = optarg = argv[optind++];
          if (*optarg == '/')
            tre = ParseFileName(&Abs,++optarg);
          else
***************
*** 571,577 ****
           */
          if (tre && (tre->Flags & F_DIR))
            ExpandTree(tre);
!     }
    /*
     *	Do tests, additional tree building if required.
     */
--- 572,578 ----
           */
          if (tre && (tre->Flags & F_DIR))
            ExpandTree(tre);
!   }
    /*
     *	Do tests, additional tree building if required.
     */