tar: rename sstrnlen to avoid OpenBSD compile error

R=, rsc
CC=
http://codereview.appspot.com/1810041
This commit is contained in:
Russ Cox 2010-07-11 09:48:51 -07:00
parent c006e98419
commit d67dc856d1

View file

@ -423,7 +423,7 @@ isustar(Hdr *hp)
* be NUL. * be NUL.
*/ */
static int static int
sstrnlen(char *s, int n) tar_sstrnlen(char *s, int n)
{ {
return s[n - 1] != '\0'? n: strlen(s); return s[n - 1] != '\0'? n: strlen(s);
} }
@ -437,7 +437,7 @@ name(Hdr *hp)
char *fullname; char *fullname;
fullname = fullnamebuf+2; fullname = fullnamebuf+2;
namlen = sstrnlen(hp->name, sizeof hp->name); namlen = tar_sstrnlen(hp->name, sizeof hp->name);
if (hp->prefix[0] == '\0' || !isustar(hp)) { /* old-style name? */ if (hp->prefix[0] == '\0' || !isustar(hp)) { /* old-style name? */
memmove(fullname, hp->name, namlen); memmove(fullname, hp->name, namlen);
fullname[namlen] = '\0'; fullname[namlen] = '\0';
@ -445,7 +445,7 @@ name(Hdr *hp)
} }
/* name is in two pieces */ /* name is in two pieces */
pfxlen = sstrnlen(hp->prefix, sizeof hp->prefix); pfxlen = tar_sstrnlen(hp->prefix, sizeof hp->prefix);
memmove(fullname, hp->prefix, pfxlen); memmove(fullname, hp->prefix, pfxlen);
fullname[pfxlen] = '/'; fullname[pfxlen] = '/';
memmove(fullname + pfxlen + 1, hp->name, namlen); memmove(fullname + pfxlen + 1, hp->name, namlen);
@ -539,8 +539,8 @@ readhdr(int ar)
return nil; return nil;
hdrcksum = strtoul(hp->chksum, nil, 8); hdrcksum = strtoul(hp->chksum, nil, 8);
if (chksum(hp) != hdrcksum) if (chksum(hp) != hdrcksum)
sysfatal("bad archive header checksum: name %.64s...", sysfatal("bad archive header checksum: name %.64s... %ld %ld",
hp->name); hp->name, chksum(hp), hdrcksum);
nexthdr += Tblock*(1 + BYTES2TBLKS(arsize(hp))); nexthdr += Tblock*(1 + BYTES2TBLKS(arsize(hp)));
return hp; return hp;
} }