gotest: multiple +build lines must all be true
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 3 Aug 2016 22:46:06 +0000 (22:46 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 3 Aug 2016 22:46:06 +0000 (22:46 +0000)
    The code that handled +build lines did not correctly require them to all
    be true.  While looking into this I discovered that multiple +build
    lines were mishandled in a different way, because the shell does not
    preseve line breaks in backquoted data.  Look for the +build token to
    tell us when we are switching from one +build line to another.

    Reviewed-on: https://go-review.googlesource.com/25460

From-SVN: r239100

gcc/go/gofrontend/MERGE
libgo/testsuite/gotest

index 1d833281f1dc36d741bbb67d09d742d33aa204e9..58066bd6d318bfea37036e4472a8e40b4c0301f0 100644 (file)
@@ -1,4 +1,4 @@
-0fb416a7bed076bdfef168480789bb2994a58de3
+3096ac81185edacbf800783f0f803d1c419dccdd
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 79e02e2a1ea07f1f5eaebb77bdc4d5e8717121c6..1f19bb5809c61afe1236fca007012f53d56c1809 100755 (executable)
@@ -313,56 +313,60 @@ x)
            esac
 
            if test x$tag1 != xnonmatchingtag -a x$tag2 != xnonmatchingtag; then
-               taglines=`sed '/^package /q' < $f | fgrep '// +build '`
-               if test "$taglines" = ""; then
-                   omatch=true
-               else
-                   omatch=false
-               fi
-               for tags in $taglines; do
-                   match=false
-                   for tag in $tags; do
-                       reverse=false
-                       case $tag in
-                       "!"*)
-                           reverse=true
-                           tag=`echo $tag | sed -e 's/^!//'`
-                           ;;
-                       esac
-
-                       case $tag in
-                       "//" | "+build")
-                           ;;
-                       $goos | $goarch | cgo)
-                           match=true
-                           ;;
-                       *,*)
-                           match=true
-                           for ctag in `echo $tag | sed -e 's/,/ /g'`; do
-                               case $ctag in
-                               $goos | $goarch | cgo)
-                                   ;;
-                               *)
-                                   match=false
-                                   ;;
-                               esac
-                           done
-                           ;;
-                       esac
-
-                       if test "$reverse" = true; then
-                           if test "$match" = true; then
+               tags=`sed '/^package /q' < $f | fgrep '// +build '`
+               omatch=true
+               first=true
+               match=false
+               for tag in $tags; do
+                   reverse=false
+                   case $tag in
+                   "!"*)
+                       reverse=true
+                       tag=`echo $tag | sed -e 's/^!//'`
+                       ;;
+                   esac
+
+                   case $tag in
+                   "//")
+                       ;;
+                   "+build")
+                       if test "$first" = "true"; then
+                           first=false
+                       elif test "$match" = "false"; then
+                           omatch=false
+                       fi
+                       match=false
+                       ;;
+                   $goos | $goarch | cgo)
+                       match=true
+                       ;;
+                   *,*)
+                       match=true
+                       for ctag in `echo $tag | sed -e 's/,/ /g'`; do
+                           case $ctag in
+                           $goos | $goarch | cgo)
+                               ;;
+                           *)
                                match=false
-                           else
-                               match=true
-                           fi
+                               ;;
+                           esac
+                       done
+                       ;;
+                   esac
+
+                   if test "$reverse" = true; then
+                       if test "$match" = true; then
+                           match=false
+                       else
+                           match=true
                        fi
-                   done
-                   if test "$match" = "true"; then
-                       omatch=true
                    fi
                done
 
+               if test "$match" = "false" -a "$first" = "false"; then
+                   omatch=false
+               fi
+
                if test "$omatch" = "true"; then
                    gofiles="$gofiles $f"
                fi