home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume5 / portar3 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  5.4 KB

  1. Subject: more patches to par/unpar
  2. Reply-To: jimb@amdcad.UUCP (Jim Budler)
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 5, Issue 11
  7. Submitted by: talcott!ima!amdcad!jimb (Jim Budler)
  8.  
  9. After I posted my patch to unpar for System V compatability
  10. I recieved a nice letter telling me that this patch wouldn't work
  11. if the filename was a full pathname, i.e. "tmp/foo/file".
  12.  
  13. Absolutely, right, but ar uses basenames, so the filename should
  14. only be a filename. So I got out my patching kit and patched arwrite.c
  15. so that:
  16.     1. Only the basename is uplaced in the header.
  17.     2. The filename is truncated to the proper length.
  18.  
  19. I also repatched unpar.c so only the last '/' on a filename is removed,
  20. to preserve some measure of sanity relative to the original par.
  21.  
  22. Below is the patch to arwrite.c, my old patch to the original unpar.c
  23. and an upgrade patch to the latest unpar.c. Hopefully, this way people
  24. who installed the original, can deinstall it and install the new patch.
  25.  
  26. #! /bin/sh
  27. # This is a shell archive, meaning:
  28. # 1. Remove everything above the #! /bin/sh line.
  29. # 2. Save the resulting text in a file.
  30. # 3. Execute the file with /bin/sh (not csh) to create:
  31. #    arwritediff
  32. #    unpar_rev1
  33. #    unpar_rev2
  34. # This archive created: Mon May 19 14:19:55 1986
  35. export PATH; PATH=/bin:/usr/bin:$PATH
  36. if test -f 'arwritediff'
  37. then
  38.     echo shar: "will not over-write existing file 'arwritediff'"
  39. else
  40. cat << \SHAR_EOF > 'arwritediff'
  41. *** /tmp/,RCSt1016031    Mon May 19 13:39:32 1986
  42. --- arwrite.c    Mon May 19 13:39:17 1986
  43. ***************
  44. *** 34,39
  45.       struct stat statbuf;
  46.       FILE *instream;
  47.       long i;
  48.   
  49.       /* stat() the file to get the stuff for the header */
  50.       if( stat(filename,&statbuf) < 0 )
  51.  
  52. --- 34,44 -----
  53.       struct stat statbuf;
  54.       FILE *instream;
  55.       long i;
  56. +     char *name;
  57. + #ifdef SYSIII
  58. + #define rindex() strrchr()
  59. + #endif
  60. +     extern char *rindex();
  61.   
  62.       /* stat() the file to get the stuff for the header */
  63.       if( stat(filename,&statbuf) < 0 )
  64. ***************
  65. *** 48,54
  66.           /* error! */
  67.           return(-1);
  68.       }
  69.       /* Now write the header */
  70.       /* This information gleaned from ar(4) in V.2 */
  71.       fprintf(stream,
  72.  
  73. --- 53,69 -----
  74.           /* error! */
  75.           return(-1);
  76.       }
  77. ! /* extract basename */
  78. !     if (( name = rindex(filename, '/')) != NULL)
  79. !         name++;
  80. !     else 
  81. !         name = filename;
  82. ! /* Truncate filename */
  83. !     if (strlen(name) > 14) {
  84. !         fprintf(stderr, "par: filename %s ", name);
  85. !         name[15] = '\0';
  86. !         fprintf(stderr, "truncated to %s\n", name);
  87. !     }
  88.       /* Now write the header */
  89.       /* This information gleaned from ar(4) in V.2 */
  90.       fprintf(stream,
  91. ***************
  92. *** 53,59
  93.       /* This information gleaned from ar(4) in V.2 */
  94.       fprintf(stream,
  95.           "%-16s%-12ld%-6d%-6d%-8o%-10ld%2s",
  96. !         filename,
  97.           statbuf.st_mtime,
  98.           statbuf.st_uid,
  99.           statbuf.st_gid,
  100.  
  101. --- 68,74 -----
  102.       /* This information gleaned from ar(4) in V.2 */
  103.       fprintf(stream,
  104.           "%-16s%-12ld%-6d%-6d%-8o%-10ld%2s",
  105. !         name,
  106.           statbuf.st_mtime,
  107.           statbuf.st_uid,
  108.           statbuf.st_gid,
  109. SHAR_EOF
  110. fi
  111. if test -f 'unpar_rev1'
  112. then
  113.     echo shar: "will not over-write existing file 'unpar_rev1'"
  114. else
  115. cat << \SHAR_EOF > 'unpar_rev1'
  116. *** /tmp/,RCSt1016150    Mon May 19 14:03:09 1986
  117. --- unpar.c    Mon May 19 14:02:34 1986
  118. ***************
  119. *** 1,7
  120.   /* unpack portable archives - written by Bill Welch */
  121.   #include <stdio.h>
  122.   #include <sys/types.h>
  123.   char buf[512];
  124.   main()
  125.   {
  126.  
  127. --- 1,7 -----
  128.   /* unpack portable archives - written by Bill Welch */
  129.   #include <stdio.h>
  130.   #include <sys/types.h>
  131. ! extern char * rindex(); /* use strrchr() if on Sys V */
  132.   char buf[512];
  133.   main()
  134.   {
  135. ***************
  136. *** 5,11
  137.   char buf[512];
  138.   main()
  139.   {
  140. !     char name[80];
  141.       struct utimbuf {
  142.           time_t actime;
  143.           time_t modtime;
  144.  
  145. --- 5,11 -----
  146.   char buf[512];
  147.   main()
  148.   {
  149. !     char name[80], *p;
  150.       struct utimbuf {
  151.           time_t actime;
  152.           time_t modtime;
  153. ***************
  154. *** 20,25
  155.               printf("%s\n", buf);
  156.               sscanf(buf, "%s %ld %d %d %o %ld", name,&mtime,&uid,&gid,
  157.                       &mode, &len);
  158.               printf("%s %ld\n", name, len);
  159.               fp = fopen(name, "w");
  160.               for (i=0; i<len; i++) putc(getchar(), fp);
  161.  
  162. --- 20,27 -----
  163.               printf("%s\n", buf);
  164.               sscanf(buf, "%s %ld %d %d %o %ld", name,&mtime,&uid,&gid,
  165.                       &mode, &len);
  166. +             if ((p = rindex(name, '/')) != NULL)
  167. +                 *p = '\0';
  168.               printf("%s %ld\n", name, len);
  169.               fp = fopen(name, "w");
  170.               for (i=0; i<len; i++) putc(getchar(), fp);
  171. SHAR_EOF
  172. fi
  173. if test -f 'unpar_rev2'
  174. then
  175.     echo shar: "will not over-write existing file 'unpar_rev2'"
  176. else
  177. cat << \SHAR_EOF > 'unpar_rev2'
  178. *** /tmp/,RCSt1016089    Mon May 19 13:46:56 1986
  179. --- unpar.c    Mon May 19 13:46:49 1986
  180. ***************
  181. *** 5,11
  182.   char buf[512];
  183.   main()
  184.   {
  185. !     char name[80];
  186.       struct utimbuf {
  187.           time_t actime;
  188.           time_t modtime;
  189.  
  190. --- 5,11 -----
  191.   char buf[512];
  192.   main()
  193.   {
  194. !     char name[80], *p;
  195.       struct utimbuf {
  196.           time_t actime;
  197.           time_t modtime;
  198. ***************
  199. *** 20,25
  200.               printf("%s\n", buf);
  201.               sscanf(buf, "%s %ld %d %d %o %ld", name,&mtime,&uid,&gid,
  202.                       &mode, &len);
  203.               printf("%s %ld\n", name, len);
  204.               fp = fopen(name, "w");
  205.               for (i=0; i<len; i++) putc(getchar(), fp);
  206.  
  207. --- 20,30 -----
  208.               printf("%s\n", buf);
  209.               sscanf(buf, "%s %ld %d %d %o %ld", name,&mtime,&uid,&gid,
  210.                       &mode, &len);
  211. +             p = name + strlen(name) -1;
  212. +             while ( *p == ' ')
  213. +                 p-- ;
  214. +             if ( *p == '/')
  215. +                 *p = '\0';
  216.               printf("%s %ld\n", name, len);
  217.               fp = fopen(name, "w");
  218.               for (i=0; i<len; i++) putc(getchar(), fp);
  219. SHAR_EOF
  220. fi
  221. exit 0
  222. #    End of shell archive
  223.  
  224.