| t@@ -16,7 +16,9 @@
* keyletters and options.
*/
#define TARGBEGIN {\
- (argv0 || (argv0 = *argv)), argv++, argc--;\
+ if (argv0 == nil)\
+ argv0 = *argv;\
+ argv++, argc--;\
if (argv[0]) {\
char *_args, *_argt;\
Rune _argc;\
t@@ -69,28 +71,25 @@ enum {
#define isreallink(lf) ((lf) == LF_LINK)
#define issymlink(lf) ((lf) == LF_SYMLINK1 || (lf) == LF_SYMLINK2)
-typedef union {
- uchar data[Tblock];
- struct {
- char name[Namsiz];
- char mode[8];
- char uid[8];
- char gid[8];
- char size[12];
- char mtime[12];
- char chksum[8];
- char linkflag;
- char linkname[Namsiz];
-
- /* rest are defined by POSIX's ustar format; see p1003.2b */
- char magic[6]; /* "ustar" */
- char version[2];
- char uname[32];
- char gname[32];
- char devmajor[8];
- char devminor[8];
- char prefix[Maxpfx]; /* if non-null, path= prefix "/" name */
- };
+typedef struct {
+ char name[Namsiz];
+ char mode[8];
+ char uid[8];
+ char gid[8];
+ char size[12];
+ char mtime[12];
+ char chksum[8];
+ char linkflag;
+ char linkname[Namsiz];
+
+ /* rest are defined by POSIX's ustar format; see p1003.2b */
+ char magic[6]; /* "ustar" */
+ char version[2];
+ char uname[32];
+ char gname[32];
+ char devmajor[8];
+ char devminor[8];
+ char prefix[Maxpfx]; /* if non-null, path= prefix "/" name */
} Hdr;
typedef struct {
t@@ -318,7 +317,7 @@ getblkz(int ar)
Hdr *hp = getblke(ar);
if (hp != nil)
- memset(hp->data, 0, Tblock);
+ memset(hp, 0, Tblock);
return hp;
}
t@@ -391,7 +390,7 @@ chksum(Hdr *hp)
{
int n = Tblock;
long i = 0;
- uchar *cp = hp->data;
+ uchar *cp = (uchar*)hp;
char oldsum[sizeof hp->chksum];
memmove(oldsum, hp->chksum, sizeof oldsum);
t@@ -664,7 +663,7 @@ addtoar(int ar, char *file, char *shortf)
hbp = getblke(ar);
blksread = gothowmany(blksleft);
bytes = blksread * Tblock;
- n = readn(fd, hbp->data, bytes);
+ n = readn(fd, hbp, bytes);
if (n < 0)
sysfatal("error reading %s: %r", file);
/*
t@@ -672,7 +671,7 @@ addtoar(int ar, char *file, char *shortf)
* compression and emergency recovery of data.
*/
if (n < Tblock)
- memset(hbp->data + n, 0, bytes - n);
+ memset((uchar*)hbp + n, 0, bytes - n);
putblkmany(ar, blksread);
}
close(fd);
t@@ -883,7 +882,7 @@ extract1(int ar, Hdr *hp, char *fname)
wrbytes = Tblock*blksread;
if(wrbytes > bytes)
wrbytes = bytes;
- if (fd >= 0 && write(fd, hbp->data, wrbytes) != wrbytes)
+ if (fd >= 0 && write(fd, hbp, wrbytes) != wrbytes)
sysfatal("write error on %s: %r", fname);
putreadblks(ar, blksread);
bytes -= wrbytes; |