]> Cypherpunks repositories - gostls13.git/commitdiff
gopack: change archive file name length back to 16
authorRuss Cox <rsc@golang.org>
Tue, 1 Nov 2011 04:29:16 +0000 (00:29 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 1 Nov 2011 04:29:16 +0000 (00:29 -0400)
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

include/ar.h
src/cmd/ld/lib.c
src/pkg/exp/types/exportdata.go

index b565ac90bf20bb4c9f9a5d62533edbc91840322e..d5636b3623c9a22c766b8e4552b61938fef27978 100644 (file)
@@ -32,7 +32,7 @@
 #define        SARMAG  8
 
 #define        ARFMAG  "`\n"
-#define SARNAME        64
+#define        SARNAME 16
 
 struct ar_hdr
 {
index 8f95665b335c5b2f7abe53f064bf28dac6e56c5a..33fa0d154623939a2e0d3bc4aca69537584a3b04 100644 (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);
index 383520320f41417bfaec5f3f4493be9e5bf655bb..784ffff01a37785d813578a0cd43f96799ca2bc0 100644 (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
 }