diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/dist/build.c | 13 | ||||
-rw-r--r-- | src/cmd/gc/esc.c | 70 | ||||
-rw-r--r-- | src/cmd/go/doc.go | 14 | ||||
-rw-r--r-- | src/cmd/go/get.go | 78 | ||||
-rw-r--r-- | src/cmd/go/tag_test.go | 71 | ||||
-rw-r--r-- | src/cmd/go/vcs.go | 8 | ||||
-rw-r--r-- | src/cmd/godoc/README.godoc-app | 29 | ||||
-rw-r--r-- | src/cmd/godoc/main.go | 2 | ||||
-rw-r--r-- | src/cmd/godoc/setup-godoc-app.bash | 10 |
9 files changed, 133 insertions, 162 deletions
diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c index 567c9f336..3ef65f85d 100644 --- a/src/cmd/dist/build.c +++ b/src/cmd/dist/build.c @@ -19,7 +19,7 @@ char *goos; char *goroot = GOROOT_FINAL; char *goroot_final = GOROOT_FINAL; char *workdir; -char *tooldir; +char *tooldir; char *gochar; char *goversion; char *slash; // / for unix, \ for windows @@ -1462,7 +1462,7 @@ void cmdbanner(int argc, char **argv) { char *pathsep; - Buf b, b1, search; + Buf b, b1, search, path; ARGBEGIN{ case 'v': @@ -1478,6 +1478,7 @@ cmdbanner(int argc, char **argv) binit(&b); binit(&b1); binit(&search); + binit(&path); xprintf("\n"); xprintf("---\n"); @@ -1495,9 +1496,10 @@ cmdbanner(int argc, char **argv) xprintf("*** You need to add %s to your PATH.\n", gobin); if(streq(gohostos, "darwin")) { - xprintf("\n" - "On OS X the debuggers must be installed setgid procmod.\n" - "Read and run ./sudo.bash to install the debuggers.\n"); + if(isfile(bpathf(&path, "%s/cov", tooldir))) + xprintf("\n" + "On OS X the debuggers must be installed setgid procmod.\n" + "Read and run ./sudo.bash to install the debuggers.\n"); } if(!streq(goroot_final, goroot)) { @@ -1509,6 +1511,7 @@ cmdbanner(int argc, char **argv) bfree(&b); bfree(&b1); bfree(&search); + bfree(&path); } // Version prints the Go version. diff --git a/src/cmd/gc/esc.c b/src/cmd/gc/esc.c index 2614b5f35..8a265ce59 100644 --- a/src/cmd/gc/esc.c +++ b/src/cmd/gc/esc.c @@ -131,7 +131,12 @@ escfunc(Node *func) } // walk will take the address of cvar->closure later and assign it to cvar. - // handle that here by linking a fake oaddr node directly to the closure. + // linking a fake oaddr node directly to the closure handles the case + // of the closure itself leaking. Following the flow of the value to th + // paramref is done in escflow, because if we did that here, it would look + // like the original is assigned out of its loop depth, whereas it's just + // assigned to something in an inner function. A paramref itself is never + // moved to the heap, only its original. for(ll=curfn->cvars; ll; ll=ll->next) { if(ll->n->op == OXXX) // see dcl.c:398 continue; @@ -221,16 +226,19 @@ esc(Node *n) if(n->op == OFOR || n->op == ORANGE) loopdepth++; - esc(n->left); - esc(n->right); - esc(n->ntest); - esc(n->nincr); - esclist(n->ninit); - esclist(n->nbody); - esclist(n->nelse); - esclist(n->list); - esclist(n->rlist); - + if(n->op == OCLOSURE) { + escfunc(n); + } else { + esc(n->left); + esc(n->right); + esc(n->ntest); + esc(n->nincr); + esclist(n->ninit); + esclist(n->nbody); + esclist(n->nelse); + esclist(n->list); + esclist(n->rlist); + } if(n->op == OFOR || n->op == ORANGE) loopdepth--; @@ -379,8 +387,8 @@ esc(Node *n) } break; - case OADDR: case OCLOSURE: + case OADDR: case OMAKECHAN: case OMAKEMAP: case OMAKESLICE: @@ -407,8 +415,8 @@ escassign(Node *dst, Node *src) return; if(debug['m'] > 1) - print("%L:[%d] %S escassign: %hN = %hN\n", lineno, loopdepth, - (curfn && curfn->nname) ? curfn->nname->sym : S, dst, src); + print("%L:[%d] %S escassign: %hN(%hJ) = %hN(%hJ)\n", lineno, loopdepth, + (curfn && curfn->nname) ? curfn->nname->sym : S, dst, dst, src, src); setlineno(dst); @@ -467,7 +475,11 @@ escassign(Node *dst, Node *src) case OARRAYLIT: case OMAPLIT: case OSTRUCTLIT: - // loopdepth was set in the defining statement or function header + case OMAKECHAN: + case OMAKEMAP: + case OMAKESLICE: + case ONEW: + case OCLOSURE: escflows(dst, src); break; @@ -500,18 +512,6 @@ escassign(Node *dst, Node *src) escassign(dst, src->left); break; - case OMAKECHAN: - case OMAKEMAP: - case OMAKESLICE: - case ONEW: - escflows(dst, src); - break; - - case OCLOSURE: - escflows(dst, src); - escfunc(src); - break; - case OADD: case OSUB: case OOR: @@ -543,7 +543,7 @@ escassign(Node *dst, Node *src) // This is a bit messier than fortunate, pulled out of escassign's big // switch for clarity. We either have the paramnodes, which may be // connected to other things throug flows or we have the parameter type -// nodes, which may be marked 'n(ofloworescape)'. Navigating the ast is slightly +// nodes, which may be marked "noescape". Navigating the ast is slightly // different for methods vs plain functions and for imported vs // this-package static void @@ -711,8 +711,8 @@ escwalk(int level, Node *dst, Node *src) src->walkgen = walkgen; if(debug['m']>1) - print("escwalk: level:%d depth:%d %.*s %hN scope:%S[%d]\n", - level, pdepth, pdepth, "\t\t\t\t\t\t\t\t\t\t", src, + print("escwalk: level:%d depth:%d %.*s %hN(%hJ) scope:%S[%d]\n", + level, pdepth, pdepth, "\t\t\t\t\t\t\t\t\t\t", src, src, (src->curfn && src->curfn->nname) ? src->curfn->nname->sym : S, src->escloopdepth); pdepth++; @@ -726,6 +726,16 @@ escwalk(int level, Node *dst, Node *src) if(debug['m']) warnl(src->lineno, "leaking param: %hN", src); } + // handle the missing flow ref <- orig + // a paramref is automagically dereferenced, and taking its + // address produces the address of the original, so all we have to do here + // is keep track of the value flow, so level is unchanged. + // alternatively, we could have substituted PPARAMREFs with their ->closure in esc/escassign/flow, + if(src->class == PPARAMREF) { + if(leaks && debug['m']) + warnl(src->lineno, "leaking closure reference %hN", src); + escwalk(level, dst, src->closure); + } break; case OPTRLIT: diff --git a/src/cmd/go/doc.go b/src/cmd/go/doc.go index 4bfd5236d..32ede3964 100644 --- a/src/cmd/go/doc.go +++ b/src/cmd/go/doc.go @@ -227,15 +227,11 @@ The -u flag instructs get to use the network to update the named packages and their dependencies. By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages. -When checking out or updating a package, get looks for a branch or -tag that matches the locally installed version of Go. If the local -version "is release.rNN", it searches for "go.rNN". (For an -installation using Go version "weekly.YYYY-MM-DD", it searches for a -package version labeled "go.YYYY-MM-DD".) If the desired version -cannot be found but others exist with labels in the correct format, -get retrieves the most recent version before the desired label. -Finally, if all else fails it retrieves the most recent version of -the package. +When checking out or updating a package, get looks for a branch or tag +that matches the locally installed version of Go. The most important +rule is that if the local installation is running version "go1", get +searches for a branch or tag named "go1". If no such version exists it +retrieves the most recent version of the package. For more about specifying packages, see 'go help packages'. diff --git a/src/cmd/go/get.go b/src/cmd/go/get.go index f70b6761d..fe45697e2 100644 --- a/src/cmd/go/get.go +++ b/src/cmd/go/get.go @@ -37,15 +37,11 @@ The -u flag instructs get to use the network to update the named packages and their dependencies. By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages. -When checking out or updating a package, get looks for a branch or -tag that matches the locally installed version of Go. If the local -version "is release.rNN", it searches for "go.rNN". (For an -installation using Go version "weekly.YYYY-MM-DD", it searches for a -package version labeled "go.YYYY-MM-DD".) If the desired version -cannot be found but others exist with labels in the correct format, -get retrieves the most recent version before the desired label. -Finally, if all else fails it retrieves the most recent version of -the package. +When checking out or updating a package, get looks for a branch or tag +that matches the locally installed version of Go. The most important +rule is that if the local installation is running version "go1", get +searches for a branch or tag named "go1". If no such version exists it +retrieves the most recent version of the package. For more about specifying packages, see 'go help packages'. @@ -339,56 +335,32 @@ var goTag = regexp.MustCompile( // Version "goX" (or "goX.Y" or "goX.Y.Z") matches tags of the same form. // Version "release.rN" matches tags of the form "go.rN" (N being a floating-point number). // Version "weekly.YYYY-MM-DD" matches tags like "go.weekly.YYYY-MM-DD". +// +// NOTE(rsc): Eventually we will need to decide on some logic here. +// For now, there is only "go1". This matches the docs in go help get. func selectTag(goVersion string, tags []string) (match string) { - const rPrefix = "release.r" - if strings.HasPrefix(goVersion, rPrefix) { - p := "go.r" - v, err := strconv.ParseFloat(goVersion[len(rPrefix):], 64) - if err != nil { - return "" - } - var matchf float64 - for _, t := range tags { - if !strings.HasPrefix(t, p) { - continue - } - tf, err := strconv.ParseFloat(t[len(p):], 64) - if err != nil { - continue - } - if matchf < tf && tf <= v { - match, matchf = t, tf - } + for _, t := range tags { + if t == "go1" { + return "go1" } } - - const wPrefix = "weekly." - if strings.HasPrefix(goVersion, wPrefix) { - p := "go.weekly." - v := goVersion[len(wPrefix):] - for _, t := range tags { - if !strings.HasPrefix(t, p) { - continue - } - if match < t && t[len(p):] <= v { - match = t - } - } - } - - if goTag.MatchString(goVersion) { - v := goVersion - for _, t := range tags { - if !goTag.MatchString(t) { - continue - } - if cmpGoVersion(match, t) < 0 && cmpGoVersion(t, v) <= 0 { - match = t + return "" + + /* + if goTag.MatchString(goVersion) { + v := goVersion + for _, t := range tags { + if !goTag.MatchString(t) { + continue + } + if cmpGoVersion(match, t) < 0 && cmpGoVersion(t, v) <= 0 { + match = t + } } } - } - return match + return match + */ } // cmpGoVersion returns -1, 0, +1 reporting whether diff --git a/src/cmd/go/tag_test.go b/src/cmd/go/tag_test.go index 556a84a8e..ffe218c7b 100644 --- a/src/cmd/go/tag_test.go +++ b/src/cmd/go/tag_test.go @@ -50,41 +50,44 @@ var selectTagTests = []struct { version string selected string }{ - {"release.r57", ""}, - {"release.r58.2", "go.r58.1"}, - {"release.r59", "go.r59"}, - {"release.r59.1", "go.r59.1"}, - {"release.r60", "go.r59.1"}, - {"release.r60.1", "go.r59.1"}, - {"release.r61", "go.r61"}, - {"release.r66", "go.r61.1"}, - {"weekly.2010-01-01", ""}, - {"weekly.2010-01-02", "go.weekly.2010-01-02"}, - {"weekly.2010-01-02.1", "go.weekly.2010-01-02"}, - {"weekly.2010-01-03", "go.weekly.2010-01-02"}, - {"weekly.2011-10-12", "go.weekly.2011-10-12"}, - {"weekly.2011-10-12.1", "go.weekly.2011-10-12.1"}, - {"weekly.2011-10-13", "go.weekly.2011-10-12.1"}, - {"weekly.2011-10-14", "go.weekly.2011-10-14"}, - {"weekly.2011-10-14.1", "go.weekly.2011-10-14"}, - {"weekly.2011-11-01", "go.weekly.2011-11-01"}, - {"weekly.2014-01-01", "go.weekly.2011-11-01"}, - {"weekly.3000-01-01", "go.weekly.2011-11-01"}, - {"go1", "go1"}, - {"go1.1", "go1.0.1"}, - {"go1.998", "go1.9.2"}, - {"go1.1000", "go1.999"}, - {"go6", "go5"}, + /* + {"release.r57", ""}, + {"release.r58.2", "go.r58.1"}, + {"release.r59", "go.r59"}, + {"release.r59.1", "go.r59.1"}, + {"release.r60", "go.r59.1"}, + {"release.r60.1", "go.r59.1"}, + {"release.r61", "go.r61"}, + {"release.r66", "go.r61.1"}, + {"weekly.2010-01-01", ""}, + {"weekly.2010-01-02", "go.weekly.2010-01-02"}, + {"weekly.2010-01-02.1", "go.weekly.2010-01-02"}, + {"weekly.2010-01-03", "go.weekly.2010-01-02"}, + {"weekly.2011-10-12", "go.weekly.2011-10-12"}, + {"weekly.2011-10-12.1", "go.weekly.2011-10-12.1"}, + {"weekly.2011-10-13", "go.weekly.2011-10-12.1"}, + {"weekly.2011-10-14", "go.weekly.2011-10-14"}, + {"weekly.2011-10-14.1", "go.weekly.2011-10-14"}, + {"weekly.2011-11-01", "go.weekly.2011-11-01"}, + {"weekly.2014-01-01", "go.weekly.2011-11-01"}, + {"weekly.3000-01-01", "go.weekly.2011-11-01"}, + {"go1", "go1"}, + {"go1.1", "go1.0.1"}, + {"go1.998", "go1.9.2"}, + {"go1.1000", "go1.999"}, + {"go6", "go5"}, - // faulty versions: - {"release.f00", ""}, - {"weekly.1999-01-01", ""}, - {"junk", ""}, - {"", ""}, - {"go2x", ""}, - {"go200000000000", ""}, - {"go2.", ""}, - {"go2.0", ""}, + // faulty versions: + {"release.f00", ""}, + {"weekly.1999-01-01", ""}, + {"junk", ""}, + {"", ""}, + {"go2x", ""}, + {"go200000000000", ""}, + {"go2.", ""}, + {"go2.0", ""}, + */ + {"anything", "go1"}, } func TestSelectTag(t *testing.T) { diff --git a/src/cmd/go/vcs.go b/src/cmd/go/vcs.go index 5f63f8b56..1c121672f 100644 --- a/src/cmd/go/vcs.go +++ b/src/cmd/go/vcs.go @@ -422,11 +422,15 @@ func repoRootForImportPathStatic(importPath, scheme string) (*repoRoot, error) { func repoRootForImportDynamic(importPath string) (*repoRoot, error) { slash := strings.Index(importPath, "/") if slash < 0 { - return nil, fmt.Errorf("missing / in import %q", importPath) + return nil, errors.New("import path doesn't contain a slash") + } + host := importPath[:slash] + if !strings.Contains(host, ".") { + return nil, errors.New("import path doesn't contain a hostname") } urlStr, body, err := httpsOrHTTP(importPath) if err != nil { - return nil, fmt.Errorf("http/https fetch for import %q: %v", importPath, err) + return nil, fmt.Errorf("http/https fetch: %v", err) } defer body.Close() metaImport, err := matchGoImport(parseMetaGoImports(body), importPath) diff --git a/src/cmd/godoc/README.godoc-app b/src/cmd/godoc/README.godoc-app index 88cfee41e..cff7d387c 100644 --- a/src/cmd/godoc/README.godoc-app +++ b/src/cmd/godoc/README.godoc-app @@ -8,8 +8,8 @@ godoc on appengine Prerequisites ------------- -* Go appengine SDK 1.5.5 - 2011-10-11 - http://code.google.com/appengine/downloads.html#Google_App_Engine_SDK_for_Go +* Go appengine SDK + https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go * Go sources at tip under $GOROOT @@ -23,10 +23,6 @@ Directory structure * $APPDIR contains the following entries (this may change depending on app-engine release and version of godoc): - alt/ - encoding/binary/ - go/* - index/suffixarray/ app.yaml godoc.zip godoc/ @@ -36,31 +32,16 @@ Directory structure For instance: application: godoc-app - version: 1-5-5 + version: 1 runtime: go - api_version: 3 + api_version: go1 handlers: - url: /.* script: _go_app * The godoc/ directory contains a copy of the files under $GOROOT/src/cmd/godoc - with modifications: - - - doc.go is excluded (it belongs to pseudo-package ÒdocumentationÓ) - - main.go is excluded (appinit.go is taking its place) - - Additional manual modifications are required to refer to the alt/ packages - where the app-engine library is not up-to-date with the godoc version. - -* The alt/ directory contains up-to-date copies of Go packages that a tip-based - godoc is dependent on but which do not yet exist in the current app-engine SDK. - At the time of this writing (10/14/2011) this is the entire go directory tree - (for the missing FileSet serialization code in go/token) as well as the - index/suffixarray package (for the missing suffix array serialization code). - The latest (alt/)index/suffixarray package internally requires the latest - version of encoding/binary, which is why it also needs to be present under - alt/. + with doc.go excluded (it belongs to pseudo-package "documentation") Configuring and running godoc diff --git a/src/cmd/godoc/main.go b/src/cmd/godoc/main.go index da4fc63b5..2e2889ed3 100644 --- a/src/cmd/godoc/main.go +++ b/src/cmd/godoc/main.go @@ -23,6 +23,8 @@ // godoc crypto/block Cipher NewCMAC // - prints doc for Cipher and NewCMAC in package crypto/block +// +build !appengine + package main import ( diff --git a/src/cmd/godoc/setup-godoc-app.bash b/src/cmd/godoc/setup-godoc-app.bash index 755d965d5..b8dc4dcf9 100644 --- a/src/cmd/godoc/setup-godoc-app.bash +++ b/src/cmd/godoc/setup-godoc-app.bash @@ -44,8 +44,8 @@ getArgs() { if [ ! -d $GOROOT ]; then error "$GOROOT is not a directory" fi - if [ ! -x $GOROOT/src/cmd/godoc/godoc ]; then - error "$GOROOT/src/cmd/godoc/godoc does not exist or is not executable" + if [ ! -x $GOROOT/bin/godoc ]; then + error "$GOROOT/bin/godoc does not exist or is not executable" fi if [ ! -d $APPDIR ]; then error "$APPDIR is not a directory" @@ -72,15 +72,15 @@ cleanup() { makeZipfile() { echo "*** make $APPDIR/$ZIPFILE" - zip -q -r $APPDIR/$ZIPFILE $GOROOT -i \*.go -i \*.html -i \*.css -i \*.js -i \*.txt -i \*.c -i \*.h -i \*.s -i \*.png -i \*.jpg -i \*.sh -i \*.ico + zip -q -r $APPDIR/$ZIPFILE $GOROOT -i \*.go -i \*.html -i \*.xml -i \*.css -i \*.js -i \*.txt -i \*.c -i \*.h -i \*.s -i \*.png -i \*.jpg -i \*.sh -i \*.ico } makeIndexfile() { echo "*** make $APPDIR/$INDEXFILE" OUT=/tmp/godoc.out - $GOROOT/src/cmd/godoc/godoc -write_index -index_files=$APPDIR/$INDEXFILE -zip=$APPDIR/$ZIPFILE 2> $OUT + $GOROOT/bin/godoc -write_index -index_files=$APPDIR/$INDEXFILE -zip=$APPDIR/$ZIPFILE 2> $OUT if [ $? != 0 ]; then - error "$GOROOT/src/cmd/godoc/godoc failed - see $OUT for details" + error "$GOROOT/bin/godoc failed - see $OUT for details" fi } |