home *** CD-ROM | disk | FTP | other *** search
- Subject: more patches to par/unpar
- Reply-To: jimb@amdcad.UUCP (Jim Budler)
- Newsgroups: mod.sources
- Approved: jpn@panda.UUCP
-
- Mod.sources: Volume 5, Issue 11
- Submitted by: talcott!ima!amdcad!jimb (Jim Budler)
-
- After I posted my patch to unpar for System V compatability
- I recieved a nice letter telling me that this patch wouldn't work
- if the filename was a full pathname, i.e. "tmp/foo/file".
-
- Absolutely, right, but ar uses basenames, so the filename should
- only be a filename. So I got out my patching kit and patched arwrite.c
- so that:
- 1. Only the basename is uplaced in the header.
- 2. The filename is truncated to the proper length.
-
- I also repatched unpar.c so only the last '/' on a filename is removed,
- to preserve some measure of sanity relative to the original par.
-
- Below is the patch to arwrite.c, my old patch to the original unpar.c
- and an upgrade patch to the latest unpar.c. Hopefully, this way people
- who installed the original, can deinstall it and install the new patch.
-
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create:
- # arwritediff
- # unpar_rev1
- # unpar_rev2
- # This archive created: Mon May 19 14:19:55 1986
- export PATH; PATH=/bin:/usr/bin:$PATH
- if test -f 'arwritediff'
- then
- echo shar: "will not over-write existing file 'arwritediff'"
- else
- cat << \SHAR_EOF > 'arwritediff'
- *** /tmp/,RCSt1016031 Mon May 19 13:39:32 1986
- --- arwrite.c Mon May 19 13:39:17 1986
- ***************
- *** 34,39
- struct stat statbuf;
- FILE *instream;
- long i;
-
- /* stat() the file to get the stuff for the header */
- if( stat(filename,&statbuf) < 0 )
-
- --- 34,44 -----
- struct stat statbuf;
- FILE *instream;
- long i;
- + char *name;
- + #ifdef SYSIII
- + #define rindex() strrchr()
- + #endif
- + extern char *rindex();
-
- /* stat() the file to get the stuff for the header */
- if( stat(filename,&statbuf) < 0 )
- ***************
- *** 48,54
- /* error! */
- return(-1);
- }
- !
- /* Now write the header */
- /* This information gleaned from ar(4) in V.2 */
- fprintf(stream,
-
- --- 53,69 -----
- /* error! */
- return(-1);
- }
- ! /* extract basename */
- ! if (( name = rindex(filename, '/')) != NULL)
- ! name++;
- ! else
- ! name = filename;
- ! /* Truncate filename */
- ! if (strlen(name) > 14) {
- ! fprintf(stderr, "par: filename %s ", name);
- ! name[15] = '\0';
- ! fprintf(stderr, "truncated to %s\n", name);
- ! }
- /* Now write the header */
- /* This information gleaned from ar(4) in V.2 */
- fprintf(stream,
- ***************
- *** 53,59
- /* This information gleaned from ar(4) in V.2 */
- fprintf(stream,
- "%-16s%-12ld%-6d%-6d%-8o%-10ld%2s",
- ! filename,
- statbuf.st_mtime,
- statbuf.st_uid,
- statbuf.st_gid,
-
- --- 68,74 -----
- /* This information gleaned from ar(4) in V.2 */
- fprintf(stream,
- "%-16s%-12ld%-6d%-6d%-8o%-10ld%2s",
- ! name,
- statbuf.st_mtime,
- statbuf.st_uid,
- statbuf.st_gid,
- SHAR_EOF
- fi
- if test -f 'unpar_rev1'
- then
- echo shar: "will not over-write existing file 'unpar_rev1'"
- else
- cat << \SHAR_EOF > 'unpar_rev1'
- *** /tmp/,RCSt1016150 Mon May 19 14:03:09 1986
- --- unpar.c Mon May 19 14:02:34 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);
- SHAR_EOF
- fi
- if test -f 'unpar_rev2'
- then
- echo shar: "will not over-write existing file 'unpar_rev2'"
- else
- cat << \SHAR_EOF > 'unpar_rev2'
- *** /tmp/,RCSt1016089 Mon May 19 13:46:56 1986
- --- unpar.c Mon May 19 13:46:49 1986
- ***************
- *** 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,30 -----
- printf("%s\n", buf);
- sscanf(buf, "%s %ld %d %d %o %ld", name,&mtime,&uid,&gid,
- &mode, &len);
- + p = name + strlen(name) -1;
- + while ( *p == ' ')
- + p-- ;
- + if ( *p == '/')
- + *p = '\0';
- printf("%s %ld\n", name, len);
- fp = fopen(name, "w");
- for (i=0; i<len; i++) putc(getchar(), fp);
- SHAR_EOF
- fi
- exit 0
- # End of shell archive
-
-