home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume4 / portar2 < prev    next >
Text File  |  1986-11-30  |  2KB  |  79 lines

  1. Subject: unpar compatability with Sys V (patch)
  2. Reply-To: jimb@amdcad.UUCP (Jim Budler)
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 4, Issue 115
  7. Submitted by: talcott!ima!amdcad!jimb (Jim Budler)
  8.  
  9. >    These programs pack and unpack files in the portable archive format.
  10. >    This format is compatible with the ar command on 4BSD and System V
  11. >    release 2.  These programs are available for use by anyone without
  12. >    fee or license.
  13.  
  14. After testing the program with a SysV arfile produced on a UTS IBM mainframe
  15. I found that the Sys V 'ar' appends a '/' to the end of the filename. This
  16. caused both BSD 'ar' and 'unpar' to coredump. SysV 'ar' can read a BSD 'ar'
  17. or 'par' created arfile.
  18. This patch strips the trailing '/'. It uses rindex() so on other systems (SysV)
  19. you may need to replace the define and call with 'strrchr()'.
  20.  
  21. -----------------<not a shar, edit here>-------------------------
  22. *** /tmp/,RCSt1001661    Wed May  7 23:33:45 1986
  23. --- unpar.c    Wed May  7 23:29:52 1986
  24. ***************
  25. *** 1,7
  26.   /* unpack portable archives - written by Bill Welch */
  27.   #include <stdio.h>
  28.   #include <sys/types.h>
  29.   char buf[512];
  30.   main()
  31.   {
  32.  
  33. --- 1,7 -----
  34.   /* unpack portable archives - written by Bill Welch */
  35.   #include <stdio.h>
  36.   #include <sys/types.h>
  37. ! extern char * rindex(); /* use strrchr() if on Sys V */
  38.   char buf[512];
  39.   main()
  40.   {
  41. ***************
  42. *** 5,11
  43.   char buf[512];
  44.   main()
  45.   {
  46. !     char name[80];
  47.       struct utimbuf {
  48.           time_t actime;
  49.           time_t modtime;
  50.  
  51. --- 5,11 -----
  52.   char buf[512];
  53.   main()
  54.   {
  55. !     char name[80], *p;
  56.       struct utimbuf {
  57.           time_t actime;
  58.           time_t modtime;
  59. ***************
  60. *** 20,25
  61.               printf("%s\n", buf);
  62.               sscanf(buf, "%s %ld %d %d %o %ld", name,&mtime,&uid,&gid,
  63.                       &mode, &len);
  64.               printf("%s %ld\n", name, len);
  65.               fp = fopen(name, "w");
  66.               for (i=0; i<len; i++) putc(getchar(), fp);
  67.  
  68. --- 20,27 -----
  69.               printf("%s\n", buf);
  70.               sscanf(buf, "%s %ld %d %d %o %ld", name,&mtime,&uid,&gid,
  71.                       &mode, &len);
  72. +             if ((p = rindex(name, '/')) != NULL)
  73. +                 *p = '\0';
  74.               printf("%s %ld\n", name, len);
  75.               fp = fopen(name, "w");
  76.               for (i=0; i<len; i++) putc(getchar(), fp);
  77.  
  78.