Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into hotfix/underflow-h2…
Browse files Browse the repository at this point in the history
…-push
  • Loading branch information
mauri870 committed Oct 26, 2023
2 parents ae50fec + 555af99 commit 587ffa3
Show file tree
Hide file tree
Showing 859 changed files with 4,453 additions and 5,984 deletions.
15 changes: 8 additions & 7 deletions doc/go_spec.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of Sep 13, 2023",
"Subtitle": "Version of Oct 16, 2023",
"Path": "/ref/spec"
}-->

Expand Down Expand Up @@ -4826,12 +4826,13 @@ <h4 id="Operator_precedence">Operator precedence</h4>
</p>

<pre>
+x
23 + 3*x[i]
x &lt;= f()
^a &gt;&gt; b
f() || g()
x == y+1 &amp;&amp; &lt;-chanInt &gt; 0
+x // x
42 + a - b // (42 + a) - b
23 + 3*x[i] // 23 + (3 * x[i])
x &lt;= f() // x &lt;= f()
^a &gt;&gt; b // (^a) >> b
f() || g() // f() || g()
x == y+1 &amp;&amp; &lt;-chanInt &gt; 0 // (x == (y+1)) && ((<-chanInt) > 0)
</pre>


Expand Down
2 changes: 1 addition & 1 deletion doc/godebug.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ and the [go command documentation](/cmd/go#hdr-Build_and_test_caching).
### Go 1.22

Go 1.22 adds a configurable limit to control the maximum acceptable RSA key size
that can be used in TLS handshakes, controlled by the [`tlsmaxrsasize`setting](/pkg/crypto/tls#Conn.Handshake).
that can be used in TLS handshakes, controlled by the [`tlsmaxrsasize` setting](/pkg/crypto/tls#Conn.Handshake).
The default is tlsmaxrsasize=8192, limiting RSA to 8192-bit keys. To avoid
denial of service attacks, this setting and default was backported to Go
1.19.13, Go 1.20.8, and Go 1.21.1.
Expand Down
1 change: 0 additions & 1 deletion misc/ios/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build ignore
// +build ignore

// detect attempts to autodetect the correct
// values of the environment variables
Expand Down
34 changes: 34 additions & 0 deletions src/bufio/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package bufio_test

import (
"bufio"
"bytes"
"fmt"
"os"
"strconv"
Expand Down Expand Up @@ -137,3 +138,36 @@ func ExampleScanner_emptyFinalToken() {
}
// Output: "1" "2" "3" "4" ""
}

// Use a Scanner with a custom split function to parse a comma-separated
// list with an empty final value but stops at the token "STOP".
func ExampleScanner_earlyStop() {
onComma := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
i := bytes.IndexByte(data, ',')
if i == -1 {
if !atEOF {
return 0, nil, nil
}
// If we have reached the end, return the last token.
return 0, data, bufio.ErrFinalToken
}
// If the token is "STOP", stop the scanning and ignore the rest.
if string(data[:i]) == "STOP" {
return i + 1, nil, bufio.ErrFinalToken
}
// Otherwise, return the token before the comma.
return i + 1, data[:i], nil
}
const input = "1,2,STOP,4,"
scanner := bufio.NewScanner(strings.NewReader(input))
scanner.Split(onComma)
for scanner.Scan() {
fmt.Printf("Got a token %q\n", scanner.Text())
}
if err := scanner.Err(); err != nil {
fmt.Fprintln(os.Stderr, "reading input:", err)
}
// Output:
// Got a token "1"
// Got a token "2"
}
25 changes: 16 additions & 9 deletions src/bufio/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ type Scanner struct {
//
// Scanning stops if the function returns an error, in which case some of
// the input may be discarded. If that error is [ErrFinalToken], scanning
// stops with no error.
// stops with no error. A non-nil token delivered with [ErrFinalToken]
// will be the last token, and a nil token with [ErrFinalToken]
// immediately stops the scanning.
//
// Otherwise, the [Scanner] advances the input. If the token is not nil,
// the [Scanner] returns it to the user. If the token is nil, the
Expand Down Expand Up @@ -114,18 +116,20 @@ func (s *Scanner) Text() string {
}

// ErrFinalToken is a special sentinel error value. It is intended to be
// returned by a Split function to indicate that the token being delivered
// with the error is the last token and scanning should stop after this one.
// After ErrFinalToken is received by Scan, scanning stops with no error.
// returned by a Split function to indicate that the scanning should stop
// with no error. If the token being delivered with this error is not nil,
// the token is the last token.
//
// The value is useful to stop processing early or when it is necessary to
// deliver a final empty token. One could achieve the same behavior
// with a custom error value but providing one here is tidier.
// deliver a final empty token (which is different from a nil token).
// One could achieve the same behavior with a custom error value but
// providing one here is tidier.
// See the emptyFinalToken example for a use of this value.
var ErrFinalToken = errors.New("final token")

// Scan advances the [Scanner] to the next token, which will then be
// available through the [Scanner.Bytes] or [Scanner.Text] method. It returns false when the
// scan stops, either by reaching the end of the input or an error.
// available through the [Scanner.Bytes] or [Scanner.Text] method. It returns false when
// there are no more tokens, either by reaching the end of the input or an error.
// After Scan returns false, the [Scanner.Err] method will return any error that
// occurred during scanning, except that if it was [io.EOF], [Scanner.Err]
// will return nil.
Expand All @@ -148,7 +152,10 @@ func (s *Scanner) Scan() bool {
if err == ErrFinalToken {
s.token = token
s.done = true
return true
// When token is not nil, it means the scanning stops
// with a trailing token, and thus the return value
// should be true to indicate the existence of the token.
return token != nil
}
s.setErr(err)
return false
Expand Down
3 changes: 3 additions & 0 deletions src/cmd/asm/internal/asm/testdata/ppc64.s
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
EXTSHCC R3, R4 // 7c640735
EXTSW R3, R4 // 7c6407b4
EXTSWCC R3, R4 // 7c6407b5
RLWMI $7, R3, $4026531855, R6 // 50663f06
RLWMI $7, R3, $1, R6 // 50663ffe
RLWMI $7, R3, $2147483648, R6 // 50663800
RLWMI $7, R3, $65535, R6 // 50663c3e
RLWMI $7, R3, $16, $31, R6 // 50663c3e
RLWMICC $7, R3, $65535, R6 // 50663c3f
Expand Down
16 changes: 11 additions & 5 deletions src/cmd/cgo/internal/testfortran/fortran_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package fortran

import (
"fmt"
"internal/testenv"
"os"
"os/exec"
Expand Down Expand Up @@ -75,11 +74,18 @@ func TestFortran(t *testing.T) {

// Finally, run the actual test.
t.Log("go", "run", "./testdata/testprog")
out, err := exec.Command("go", "run", "./testdata/testprog").CombinedOutput()
if err == nil && string(out) != "ok\n" {
err = fmt.Errorf("expected ok")
var stdout, stderr strings.Builder
cmd := exec.Command("go", "run", "./testdata/testprog")
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
t.Logf("%v", cmd)
if stderr.Len() != 0 {
t.Logf("stderr:\n%s", stderr.String())
}
if err != nil {
t.Errorf("%s\nOutput:\n%s", err, string(out))
t.Errorf("%v\n%s", err, stdout.String())
} else if stdout.String() != "ok\n" {
t.Errorf("stdout:\n%s\nwant \"ok\"", stdout.String())
}
}
9 changes: 6 additions & 3 deletions src/cmd/cgo/internal/testfortran/testdata/testprog/fortran.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ package main

// int the_answer();
import "C"
import "os"
import (
"fmt"
"os"
)

func TheAnswer() int {
return int(C.the_answer())
}

func main() {
if a := TheAnswer(); a != 42 {
println("Unexpected result for The Answer. Got:", a, " Want: 42")
fmt.Fprintln(os.Stderr, "Unexpected result for The Answer. Got:", a, " Want: 42")
os.Exit(1)
}
println("ok")
fmt.Fprintln(os.Stdout, "ok")
}
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/ir/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (n *BinaryExpr) SetOp(op Op) {
}
}

// A CallExpr is a function call X(Args).
// A CallExpr is a function call Fun(Args).
type CallExpr struct {
miniExpr
Fun Node
Expand Down
Loading

0 comments on commit 587ffa3

Please sign in to comment.