]> Cypherpunks repositories - gostls13.git/commitdiff
go/build: fix match
authorMaxim Pimenov <mpimenov@google.com>
Tue, 13 Mar 2012 14:00:43 +0000 (10:00 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 13 Mar 2012 14:00:43 +0000 (10:00 -0400)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5801043

src/pkg/go/build/build.go
src/pkg/go/build/build_test.go

index dc9dcd1d652e011a1fcc662164d9e37edea21d9f..d2dbb58a1c5e3d558780ee1a33971fc61d21dd5f 100644 (file)
@@ -874,7 +874,7 @@ func splitQuoted(s string) (r []string, err error) {
 //     !cgo (if cgo is disabled)
 //     tag (if tag is listed in ctxt.BuildTags)
 //     !tag (if tag is not listed in ctxt.BuildTags)
-//     a slash-separated list of any of these
+//     a comma-separated list of any of these
 //
 func (ctxt *Context) match(name string) bool {
        if name == "" {
@@ -888,11 +888,11 @@ func (ctxt *Context) match(name string) bool {
                return false
        }
        if strings.HasPrefix(name, "!") { // negation
-               return !ctxt.match(name[1:])
+               return len(name) > 1 && !ctxt.match(name[1:])
        }
 
        // Tags must be letters, digits, underscores.
-       // Unlike in Go identifiers, all digits is fine (e.g., "386").
+       // Unlike in Go identifiers, all digits are fine (e.g., "386").
        for _, c := range name {
                if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' {
                        return false
index 06b8b0e94f86365f6553e7f0f462602998383752..560ebad5c97a9cc0296f461d4f35a95bbe5795e0 100644 (file)
@@ -36,6 +36,7 @@ func TestMatch(t *testing.T) {
        nomatch(runtime.GOOS + "," + runtime.GOARCH + ",!foo")
        match(runtime.GOOS + "," + runtime.GOARCH + ",!bar")
        nomatch(runtime.GOOS + "," + runtime.GOARCH + ",bar")
+       nomatch("!")
 }
 
 func TestDotSlashImport(t *testing.T) {