1
0
mirror of https://github.com/golang/go synced 2024-11-21 16:54:46 -07:00

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:
Russ Cox 2011-11-01 00:29:16 -04:00
parent 4853c51770
commit 7b04471dfa
3 changed files with 6 additions and 12 deletions

View File

@ -32,7 +32,7 @@
#define SARMAG 8
#define ARFMAG "`\n"
#define SARNAME 64
#define SARNAME 16
struct ar_hdr
{

View File

@ -313,15 +313,9 @@ nextar(Biobuf *bp, int off, struct ar_hdr *a)
return 0;
return -1;
}
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
if(r != SAR_HDR)
return -1;
}
memmove(a, buf, SAR_HDR);
if(strncmp(a->fmag, ARFMAG, sizeof a->fmag))
return -1;
arsize = strtol(a->size, 0, 0);

View File

@ -17,7 +17,7 @@ import (
func readGopackHeader(buf *bufio.Reader) (name string, size int, err os.Error) {
// 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)
if err != nil {
return
@ -25,13 +25,13 @@ func readGopackHeader(buf *bufio.Reader) (name string, size int, err os.Error) {
if trace {
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)
if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' {
err = os.NewError("invalid archive header")
return
}
name = strings.TrimSpace(string(hdr[:64]))
name = strings.TrimSpace(string(hdr[:16]))
return
}