unpar compatability with Sys V (patch)

sources-request at panda.UUCP sources-request at panda.UUCP
Mon May 12 21:28:35 AEST 1986


Mod.sources:  Volume 4, Issue 115
Submitted by: talcott!ima!amdcad!jimb (Jim Budler)

>	These programs pack and unpack files in the portable archive format.
>	This format is compatible with the ar command on 4BSD and System V
>	release 2.  These programs are available for use by anyone without
>	fee or license.

After testing the program with a SysV arfile produced on a UTS IBM mainframe
I found that the Sys V 'ar' appends a '/' to the end of the filename. This
caused both BSD 'ar' and 'unpar' to coredump. SysV 'ar' can read a BSD 'ar'
or 'par' created arfile.
This patch strips the trailing '/'. It uses rindex() so on other systems (SysV)
you may need to replace the define and call with 'strrchr()'.

-----------------<not a shar, edit here>-------------------------
*** /tmp/,RCSt1001661	Wed May  7 23:33:45 1986
--- unpar.c	Wed May  7 23:29:52 1986
***************
*** 1,7
  /* unpack portable archives - written by Bill Welch */
  #include <stdio.h>
  #include <sys/types.h>
! 
  char buf[512];
  main()
  {

--- 1,7 -----
  /* unpack portable archives - written by Bill Welch */
  #include <stdio.h>
  #include <sys/types.h>
! extern char * rindex(); /* use strrchr() if on Sys V */
  char buf[512];
  main()
  {
***************
*** 5,11
  char buf[512];
  main()
  {
! 	char name[80];
  	struct utimbuf {
  		time_t actime;
  		time_t modtime;

--- 5,11 -----
  char buf[512];
  main()
  {
! 	char name[80], *p;
  	struct utimbuf {
  		time_t actime;
  		time_t modtime;
***************
*** 20,25
  			printf("%s\n", buf);
  			sscanf(buf, "%s %ld %d %d %o %ld", name,&mtime,&uid,&gid,
  					&mode, &len);
  			printf("%s %ld\n", name, len);
  			fp = fopen(name, "w");
  			for (i=0; i<len; i++) putc(getchar(), fp);

--- 20,27 -----
  			printf("%s\n", buf);
  			sscanf(buf, "%s %ld %d %d %o %ld", name,&mtime,&uid,&gid,
  					&mode, &len);
+ 			if ((p = rindex(name, '/')) != NULL)
+ 				*p = '\0';
  			printf("%s %ld\n", name, len);
  			fp = fopen(name, "w");
  			for (i=0; i<len; i++) putc(getchar(), fp);



More information about the Mod.sources mailing list