mirror of https://github.com/golang/go.git
gopack: change archive file name length back to 16
This CL grew the archive file name length from 16 to 64:
changeset: 909:58574851d792
user: Russ Cox <rsc@golang.org>
date: Mon Oct 20 13:53:56 2008 -0700
Back then, every x.go file in a package became an x.6 file
in the archive. It was important to be able to allow the
use of long Go source file names, hence the increase in size.
Today, all Go source files compile into a single _go_.6 file
regardless of their names, so the archive file name length
no longer needs to be long. The longer name causes some
problems on Plan 9, where the native archive format is the
same but with 16-byte names, so revert back to 16.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5333050
This commit is contained in:
parent
4853c51770
commit
7b04471dfa
|
|
@ -32,7 +32,7 @@
|
||||||
#define SARMAG 8
|
#define SARMAG 8
|
||||||
|
|
||||||
#define ARFMAG "`\n"
|
#define ARFMAG "`\n"
|
||||||
#define SARNAME 64
|
#define SARNAME 16
|
||||||
|
|
||||||
struct ar_hdr
|
struct ar_hdr
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -313,15 +313,9 @@ nextar(Biobuf *bp, int off, struct ar_hdr *a)
|
||||||
return 0;
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(r == SAR_HDR) {
|
if(r != SAR_HDR)
|
||||||
memmove(a, buf, SAR_HDR);
|
|
||||||
} else if (r == SAR_HDR-SARNAME+16) { // old Plan 9
|
|
||||||
memset(a->name, ' ', sizeof a->name);
|
|
||||||
memmove(a, buf, 16);
|
|
||||||
memmove((char*)a+SARNAME, buf+16, SAR_HDR-SARNAME);
|
|
||||||
} else { // unexpected
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
memmove(a, buf, SAR_HDR);
|
||||||
if(strncmp(a->fmag, ARFMAG, sizeof a->fmag))
|
if(strncmp(a->fmag, ARFMAG, sizeof a->fmag))
|
||||||
return -1;
|
return -1;
|
||||||
arsize = strtol(a->size, 0, 0);
|
arsize = strtol(a->size, 0, 0);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import (
|
||||||
|
|
||||||
func readGopackHeader(buf *bufio.Reader) (name string, size int, err os.Error) {
|
func readGopackHeader(buf *bufio.Reader) (name string, size int, err os.Error) {
|
||||||
// See $GOROOT/include/ar.h.
|
// See $GOROOT/include/ar.h.
|
||||||
hdr := make([]byte, 64+12+6+6+8+10+2)
|
hdr := make([]byte, 16+12+6+6+8+10+2)
|
||||||
_, err = io.ReadFull(buf, hdr)
|
_, err = io.ReadFull(buf, hdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
@ -25,13 +25,13 @@ func readGopackHeader(buf *bufio.Reader) (name string, size int, err os.Error) {
|
||||||
if trace {
|
if trace {
|
||||||
fmt.Printf("header: %s", hdr)
|
fmt.Printf("header: %s", hdr)
|
||||||
}
|
}
|
||||||
s := strings.TrimSpace(string(hdr[64+12+6+6+8:][:10]))
|
s := strings.TrimSpace(string(hdr[16+12+6+6+8:][:10]))
|
||||||
size, err = strconv.Atoi(s)
|
size, err = strconv.Atoi(s)
|
||||||
if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' {
|
if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' {
|
||||||
err = os.NewError("invalid archive header")
|
err = os.NewError("invalid archive header")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
name = strings.TrimSpace(string(hdr[:64]))
|
name = strings.TrimSpace(string(hdr[:16]))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue