mirror of
https://github.com/golang/go
synced 2024-11-21 13:34:39 -07:00
... changes
R=golang-dev, gri CC=golang-dev https://golang.org/cl/2273042
This commit is contained in:
parent
75dd8fdb34
commit
2ee420fa5e
@ -67,7 +67,7 @@ func run(stdin []byte, argv []string) (stdout, stderr []byte, ok bool) {
|
||||
|
||||
// Die with an error message.
|
||||
func fatal(msg string, args ...interface{}) {
|
||||
fmt.Fprintf(os.Stderr, msg+"\n", args)
|
||||
fmt.Fprintf(os.Stderr, msg+"\n", args...)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ func error(pos token.Position, msg string, args ...interface{}) {
|
||||
if pos.IsValid() {
|
||||
fmt.Fprintf(os.Stderr, "%s: ", pos)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, msg, args)
|
||||
fmt.Fprintf(os.Stderr, msg, args...)
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
}
|
||||
|
||||
|
@ -3052,7 +3052,7 @@ func create(s string, m uint32) *bufio.Writer {
|
||||
//
|
||||
func error(s string, v ...interface{}) {
|
||||
nerrors++
|
||||
fmt.Fprintf(stderr, s, v)
|
||||
fmt.Fprintf(stderr, s, v...)
|
||||
fmt.Fprintf(stderr, ": %v:%v\n", infile, lineno)
|
||||
if fatfl != 0 {
|
||||
summary()
|
||||
|
@ -34,7 +34,7 @@ var bigtest = pairs[len(pairs)-1]
|
||||
|
||||
func testEqual(t *testing.T, msg string, args ...interface{}) bool {
|
||||
if args[len(args)-2] != args[len(args)-1] {
|
||||
t.Errorf(msg, args)
|
||||
t.Errorf(msg, args...)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -48,7 +48,7 @@ var bigtest = testpair{
|
||||
|
||||
func testEqual(t *testing.T, msg string, args ...interface{}) bool {
|
||||
if args[len(args)-2] != args[len(args)-1] {
|
||||
t.Errorf(msg, args)
|
||||
t.Errorf(msg, args...)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -17,7 +17,7 @@ type testpair struct {
|
||||
|
||||
func testEqual(t *testing.T, msg string, args ...interface{}) bool {
|
||||
if args[len(args)-2] != args[len(args)-1] {
|
||||
t.Errorf(msg, args)
|
||||
t.Errorf(msg, args...)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
@ -697,7 +697,7 @@ func (f Format) Eval(env Environment, args ...interface{}) ([]byte, os.Error) {
|
||||
// written and an os.Error, if any.
|
||||
//
|
||||
func (f Format) Fprint(w io.Writer, env Environment, args ...interface{}) (int, os.Error) {
|
||||
data, err := f.Eval(env, args)
|
||||
data, err := f.Eval(env, args...)
|
||||
if err != nil {
|
||||
// TODO should we print partial result in case of error?
|
||||
return 0, err
|
||||
@ -711,7 +711,7 @@ func (f Format) Fprint(w io.Writer, env Environment, args ...interface{}) (int,
|
||||
// number of bytes written and an os.Error, if any.
|
||||
//
|
||||
func (f Format) Print(args ...interface{}) (int, os.Error) {
|
||||
return f.Fprint(os.Stdout, nil, args)
|
||||
return f.Fprint(os.Stdout, nil, args...)
|
||||
}
|
||||
|
||||
|
||||
@ -722,7 +722,7 @@ func (f Format) Print(args ...interface{}) (int, os.Error) {
|
||||
//
|
||||
func (f Format) Sprint(args ...interface{}) string {
|
||||
var buf bytes.Buffer
|
||||
_, err := f.Fprint(&buf, nil, args)
|
||||
_, err := f.Fprint(&buf, nil, args...)
|
||||
if err != nil {
|
||||
var i interface{} = args
|
||||
fmt.Fprintf(&buf, "--- Sprint(%s) failed: %v", fmt.Sprint(i), err)
|
||||
|
@ -24,7 +24,7 @@ func verify(t *testing.T, f Format, expected string, args ...interface{}) {
|
||||
if f == nil {
|
||||
return // allow other tests to run
|
||||
}
|
||||
result := f.Sprint(args)
|
||||
result := f.Sprint(args...)
|
||||
if result != expected {
|
||||
t.Errorf(
|
||||
"result : `%s`\nexpected: `%s`\n\n",
|
||||
@ -97,7 +97,7 @@ func check(t *testing.T, form, expected string, args ...interface{}) {
|
||||
if f == nil {
|
||||
return // allow other tests to run
|
||||
}
|
||||
result := f.Sprint(args)
|
||||
result := f.Sprint(args...)
|
||||
if result != expected {
|
||||
t.Errorf(
|
||||
"format : %s\nresult : `%s`\nexpected: `%s`\n\n",
|
||||
|
@ -28,7 +28,7 @@ type compiler struct {
|
||||
}
|
||||
|
||||
func (a *compiler) diagAt(pos positioned, format string, args ...interface{}) {
|
||||
a.errors.Error(pos.Pos(), fmt.Sprintf(format, args))
|
||||
a.errors.Error(pos.Pos(), fmt.Sprintf(format, args...))
|
||||
a.numErrors++
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func (a *exprInfo) newExpr(t Type, desc string) *expr {
|
||||
}
|
||||
|
||||
func (a *exprInfo) diag(format string, args ...interface{}) {
|
||||
a.diagAt(&a.pos, format, args)
|
||||
a.diagAt(&a.pos, format, args...)
|
||||
}
|
||||
|
||||
func (a *exprInfo) diagOpType(op token.Token, vt Type) {
|
||||
|
@ -28,7 +28,7 @@ type stmtCompiler struct {
|
||||
}
|
||||
|
||||
func (a *stmtCompiler) diag(format string, args ...interface{}) {
|
||||
a.diagAt(&a.pos, format, args)
|
||||
a.diagAt(&a.pos, format, args...)
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -146,7 +146,7 @@ func Fprintf(w io.Writer, format string, a ...interface{}) (n int, error os.Erro
|
||||
// Printf formats according to a format specifier and writes to standard output.
|
||||
// It returns the number of bytes written and any write error encountered.
|
||||
func Printf(format string, a ...interface{}) (n int, errno os.Error) {
|
||||
n, errno = Fprintf(os.Stdout, format, a)
|
||||
n, errno = Fprintf(os.Stdout, format, a...)
|
||||
return n, errno
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ func Fprint(w io.Writer, a ...interface{}) (n int, error os.Error) {
|
||||
// Spaces are added between operands when neither is a string.
|
||||
// It returns the number of bytes written and any write error encountered.
|
||||
func Print(a ...interface{}) (n int, errno os.Error) {
|
||||
n, errno = Fprint(os.Stdout, a)
|
||||
n, errno = Fprint(os.Stdout, a...)
|
||||
return n, errno
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ func Fprintln(w io.Writer, a ...interface{}) (n int, error os.Error) {
|
||||
// Spaces are always added between operands and a newline is appended.
|
||||
// It returns the number of bytes written and any write error encountered.
|
||||
func Println(a ...interface{}) (n int, errno os.Error) {
|
||||
n, errno = Fprintln(os.Stdout, a)
|
||||
n, errno = Fprintln(os.Stdout, a...)
|
||||
return n, errno
|
||||
}
|
||||
|
||||
|
@ -60,20 +60,20 @@ type Scanner interface {
|
||||
// as space. It returns the number of items successfully scanned.
|
||||
// If that is less than the number of arguments, err will report why.
|
||||
func Scan(a ...interface{}) (n int, err os.Error) {
|
||||
return Fscan(os.Stdin, a)
|
||||
return Fscan(os.Stdin, a...)
|
||||
}
|
||||
|
||||
// Scanln is similar to Scan, but stops scanning at a newline and
|
||||
// after the final item there must be a newline or EOF.
|
||||
func Scanln(a ...interface{}) (n int, err os.Error) {
|
||||
return Fscanln(os.Stdin, a)
|
||||
return Fscanln(os.Stdin, a...)
|
||||
}
|
||||
|
||||
// Scanf scans text read from standard input, storing successive
|
||||
// space-separated values into successive arguments as determined by
|
||||
// the format. It returns the number of items successfully scanned.
|
||||
func Scanf(format string, a ...interface{}) (n int, err os.Error) {
|
||||
return Fscanf(os.Stdin, format, a)
|
||||
return Fscanf(os.Stdin, format, a...)
|
||||
}
|
||||
|
||||
// Sscan scans the argument string, storing successive space-separated
|
||||
@ -81,20 +81,20 @@ func Scanf(format string, a ...interface{}) (n int, err os.Error) {
|
||||
// returns the number of items successfully scanned. If that is less
|
||||
// than the number of arguments, err will report why.
|
||||
func Sscan(str string, a ...interface{}) (n int, err os.Error) {
|
||||
return Fscan(strings.NewReader(str), a)
|
||||
return Fscan(strings.NewReader(str), a...)
|
||||
}
|
||||
|
||||
// Sscanln is similar to Sscan, but stops scanning at a newline and
|
||||
// after the final item there must be a newline or EOF.
|
||||
func Sscanln(str string, a ...interface{}) (n int, err os.Error) {
|
||||
return Fscanln(strings.NewReader(str), a)
|
||||
return Fscanln(strings.NewReader(str), a...)
|
||||
}
|
||||
|
||||
// Sscanf scans the argument string, storing successive space-separated
|
||||
// values into successive arguments as determined by the format. It
|
||||
// returns the number of items successfully parsed.
|
||||
func Sscanf(str string, format string, a ...interface{}) (n int, err os.Error) {
|
||||
return Fscanf(strings.NewReader(str), format, a)
|
||||
return Fscanf(strings.NewReader(str), format, a...)
|
||||
}
|
||||
|
||||
// Fscan scans text read from r, storing successive space-separated
|
||||
|
@ -124,7 +124,7 @@ type localError struct {
|
||||
|
||||
// printf is a convenience wrapper that takes care of print errors.
|
||||
func (p *printer) printf(format string, args ...interface{}) {
|
||||
n, err := fmt.Fprintf(p, format, args)
|
||||
n, err := fmt.Fprintf(p, format, args...)
|
||||
p.written += n
|
||||
if err != nil {
|
||||
panic(localError{err})
|
||||
|
@ -90,7 +90,7 @@ func (p *parser) printTrace(a ...interface{}) {
|
||||
fmt.Print(dots)
|
||||
}
|
||||
fmt.Print(dots[0:i])
|
||||
fmt.Println(a)
|
||||
fmt.Println(a...)
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,7 +105,7 @@ func (p *printer) init(output io.Writer, cfg *Config) {
|
||||
func (p *printer) internalError(msg ...interface{}) {
|
||||
if debug {
|
||||
fmt.Print(p.pos.String() + ": ")
|
||||
fmt.Println(msg)
|
||||
fmt.Println(msg...)
|
||||
panic("go/printer")
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ type typechecker struct {
|
||||
|
||||
|
||||
func (tc *typechecker) Errorf(pos token.Position, format string, args ...interface{}) {
|
||||
tc.Error(pos, fmt.Sprintf(format, args))
|
||||
tc.Error(pos, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,32 +150,32 @@ func (l *Logger) Output(calldepth int, s string) os.Error {
|
||||
|
||||
// Logf is analogous to Printf() for a Logger.
|
||||
func (l *Logger) Logf(format string, v ...interface{}) {
|
||||
l.Output(2, fmt.Sprintf(format, v))
|
||||
l.Output(2, fmt.Sprintf(format, v...))
|
||||
}
|
||||
|
||||
// Log is analogous to Print() for a Logger.
|
||||
func (l *Logger) Log(v ...interface{}) { l.Output(2, fmt.Sprintln(v)) }
|
||||
func (l *Logger) Log(v ...interface{}) { l.Output(2, fmt.Sprintln(v...)) }
|
||||
|
||||
// Stdout is a helper function for easy logging to stdout. It is analogous to Print().
|
||||
func Stdout(v ...interface{}) { stdout.Output(2, fmt.Sprint(v)) }
|
||||
func Stdout(v ...interface{}) { stdout.Output(2, fmt.Sprint(v...)) }
|
||||
|
||||
// Stderr is a helper function for easy logging to stderr. It is analogous to Fprint(os.Stderr).
|
||||
func Stderr(v ...interface{}) { stderr.Output(2, fmt.Sprintln(v)) }
|
||||
func Stderr(v ...interface{}) { stderr.Output(2, fmt.Sprintln(v...)) }
|
||||
|
||||
// Stdoutf is a helper functions for easy formatted logging to stdout. It is analogous to Printf().
|
||||
func Stdoutf(format string, v ...interface{}) { stdout.Output(2, fmt.Sprintf(format, v)) }
|
||||
func Stdoutf(format string, v ...interface{}) { stdout.Output(2, fmt.Sprintf(format, v...)) }
|
||||
|
||||
// Stderrf is a helper function for easy formatted logging to stderr. It is analogous to Fprintf(os.Stderr).
|
||||
func Stderrf(format string, v ...interface{}) { stderr.Output(2, fmt.Sprintf(format, v)) }
|
||||
func Stderrf(format string, v ...interface{}) { stderr.Output(2, fmt.Sprintf(format, v...)) }
|
||||
|
||||
// Exit is equivalent to Stderr() followed by a call to os.Exit(1).
|
||||
func Exit(v ...interface{}) { exit.Output(2, fmt.Sprintln(v)) }
|
||||
func Exit(v ...interface{}) { exit.Output(2, fmt.Sprintln(v...)) }
|
||||
|
||||
// Exitf is equivalent to Stderrf() followed by a call to os.Exit(1).
|
||||
func Exitf(format string, v ...interface{}) { exit.Output(2, fmt.Sprintf(format, v)) }
|
||||
func Exitf(format string, v ...interface{}) { exit.Output(2, fmt.Sprintf(format, v...)) }
|
||||
|
||||
// Crash is equivalent to Stderr() followed by a call to panic().
|
||||
func Crash(v ...interface{}) { crash.Output(2, fmt.Sprintln(v)) }
|
||||
func Crash(v ...interface{}) { crash.Output(2, fmt.Sprintln(v...)) }
|
||||
|
||||
// Crashf is equivalent to Stderrf() followed by a call to panic().
|
||||
func Crashf(format string, v ...interface{}) { crash.Output(2, fmt.Sprintf(format, v)) }
|
||||
func Crashf(format string, v ...interface{}) { crash.Output(2, fmt.Sprintf(format, v...)) }
|
||||
|
@ -113,7 +113,7 @@ func Dial(network, addr string) (*Conn, os.Error) {
|
||||
func (c *Conn) Cmd(format string, args ...interface{}) (id uint, err os.Error) {
|
||||
id = c.Next()
|
||||
c.StartRequest(id)
|
||||
err = c.PrintfLine(format, args)
|
||||
err = c.PrintfLine(format, args...)
|
||||
c.EndRequest(id)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
@ -29,7 +29,7 @@ var dotcrnl = []byte{'.', '\r', '\n'}
|
||||
// PrintfLine writes the formatted output followed by \r\n.
|
||||
func (w *Writer) PrintfLine(format string, args ...interface{}) os.Error {
|
||||
w.closeDot()
|
||||
fmt.Fprintf(w.W, format, args)
|
||||
fmt.Fprintf(w.W, format, args...)
|
||||
w.W.Write(crnl)
|
||||
return w.W.Flush()
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import (
|
||||
// expLog is a logging convenience function. The first argument must be a string.
|
||||
func expLog(args ...interface{}) {
|
||||
args[0] = "netchan export: " + args[0].(string)
|
||||
log.Stderr(args)
|
||||
log.Stderr(args...)
|
||||
}
|
||||
|
||||
// An Exporter allows a set of channels to be published on a single
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
// impLog is a logging convenience function. The first argument must be a string.
|
||||
func impLog(args ...interface{}) {
|
||||
args[0] = "netchan import: " + args[0].(string)
|
||||
log.Stderr(args)
|
||||
log.Stderr(args...)
|
||||
}
|
||||
|
||||
// An Importer allows a set of channels to be imported from a single
|
||||
|
@ -270,7 +270,7 @@ func (c *Conn) cmd(expectCode uint, format string, args ...interface{}) (code ui
|
||||
}
|
||||
c.br = nil
|
||||
}
|
||||
if _, err := fmt.Fprintf(c.conn, format+"\r\n", args); err != nil {
|
||||
if _, err := fmt.Fprintf(c.conn, format+"\r\n", args...); err != nil {
|
||||
return 0, "", err
|
||||
}
|
||||
line, err = c.r.ReadString('\n')
|
||||
|
@ -118,7 +118,7 @@ var jointests = []JoinTest{
|
||||
// join takes a []string and passes it to Join.
|
||||
func join(elem []string, args ...string) string {
|
||||
args = elem
|
||||
return Join(args)
|
||||
return Join(args...)
|
||||
}
|
||||
|
||||
func TestJoin(t *testing.T) {
|
||||
|
@ -185,13 +185,13 @@ func New(fmap FormatterMap) *Template {
|
||||
|
||||
// Report error and stop executing. The line number must be provided explicitly.
|
||||
func (t *Template) execError(st *state, line int, err string, args ...interface{}) {
|
||||
panic(&Error{line, fmt.Sprintf(err, args)})
|
||||
panic(&Error{line, fmt.Sprintf(err, args...)})
|
||||
}
|
||||
|
||||
// Report error, panic to terminate parsing.
|
||||
// The line number comes from the template state.
|
||||
func (t *Template) parseError(err string, args ...interface{}) {
|
||||
panic(&Error{t.linenum, fmt.Sprintf(err, args)})
|
||||
panic(&Error{t.linenum, fmt.Sprintf(err, args...)})
|
||||
}
|
||||
|
||||
// -- Lexical analysis
|
||||
|
@ -89,35 +89,35 @@ func (t *T) FailNow() {
|
||||
|
||||
// Log formats its arguments using default formatting, analogous to Print(),
|
||||
// and records the text in the error log.
|
||||
func (t *T) Log(args ...interface{}) { t.errors += "\t" + tabify(fmt.Sprintln(args)) }
|
||||
func (t *T) Log(args ...interface{}) { t.errors += "\t" + tabify(fmt.Sprintln(args...)) }
|
||||
|
||||
// Log formats its arguments according to the format, analogous to Printf(),
|
||||
// and records the text in the error log.
|
||||
func (t *T) Logf(format string, args ...interface{}) {
|
||||
t.errors += "\t" + tabify(fmt.Sprintf(format, args))
|
||||
t.errors += "\t" + tabify(fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
// Error is equivalent to Log() followed by Fail().
|
||||
func (t *T) Error(args ...interface{}) {
|
||||
t.Log(args)
|
||||
t.Log(args...)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
// Errorf is equivalent to Logf() followed by Fail().
|
||||
func (t *T) Errorf(format string, args ...interface{}) {
|
||||
t.Logf(format, args)
|
||||
t.Logf(format, args...)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
// Fatal is equivalent to Log() followed by FailNow().
|
||||
func (t *T) Fatal(args ...interface{}) {
|
||||
t.Log(args)
|
||||
t.Log(args...)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
// Fatalf is equivalent to Logf() followed by FailNow().
|
||||
func (t *T) Fatalf(format string, args ...interface{}) {
|
||||
t.Logf(format, args)
|
||||
t.Logf(format, args...)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ func eliminate_digit(d int64) {
|
||||
|
||||
func printf(s string, arg ...interface{}) {
|
||||
if !*silent {
|
||||
fmt.Printf(s, arg)
|
||||
fmt.Printf(s, arg...)
|
||||
}
|
||||
}
|
||||
|
||||
|
14
test/ddd.go
14
test/ddd.go
@ -14,13 +14,13 @@ func sum(args ...int) int {
|
||||
return s
|
||||
}
|
||||
|
||||
func sumC(args ...int) int { return func() int { return sum(args) }() }
|
||||
func sumC(args ...int) int { return func() int { return sum(args...) }() }
|
||||
|
||||
var sumD = func(args ...int) int { return sum(args) }
|
||||
var sumD = func(args ...int) int { return sum(args...) }
|
||||
|
||||
var sumE = func() func(...int) int { return func(args ...int) int { return sum(args) } }()
|
||||
var sumE = func() func(...int) int { return func(args ...int) int { return sum(args...) } }()
|
||||
|
||||
var sumF = func(args ...int) func() int { return func() int { return sum(args) } }
|
||||
var sumF = func(args ...int) func() int { return func() int { return sum(args...) } }
|
||||
|
||||
func sumA(args []int) int {
|
||||
s := 0
|
||||
@ -30,7 +30,7 @@ func sumA(args []int) int {
|
||||
return s
|
||||
}
|
||||
|
||||
func sum2(args ...int) int { return 2 * sum(args) }
|
||||
func sum2(args ...int) int { return 2 * sum(args...) }
|
||||
|
||||
func sum3(args ...int) int { return 3 * sumA(args) }
|
||||
|
||||
@ -46,9 +46,9 @@ type T []T
|
||||
|
||||
func ln(args ...T) int { return len(args) }
|
||||
|
||||
func ln2(args ...T) int { return 2 * ln(args) }
|
||||
func ln2(args ...T) int { return 2 * ln(args...) }
|
||||
|
||||
func (*T) Sum(args ...int) int { return sum(args) }
|
||||
func (*T) Sum(args ...int) int { return sum(args...) }
|
||||
|
||||
type U struct {
|
||||
*T
|
||||
|
@ -26,7 +26,7 @@ func test1() {
|
||||
}
|
||||
}
|
||||
|
||||
func addDotDotDot(v ...interface{}) { result += fmt.Sprint(v) }
|
||||
func addDotDotDot(v ...interface{}) { result += fmt.Sprint(v...) }
|
||||
|
||||
func test2helper() {
|
||||
for i := 0; i < 10; i++ {
|
||||
|
@ -7,9 +7,9 @@
|
||||
package main
|
||||
|
||||
func f(args ...int) {
|
||||
g(args) // ERROR "[.][.][.] mismatch"
|
||||
g(args) // ERROR "[.][.][.]"
|
||||
}
|
||||
|
||||
func g(args ...interface{}) {
|
||||
f(args) // ERROR "[.][.][.] mismatch"
|
||||
f(args) // ERROR "[.][.][.]"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user