src/pkg/[n-z]*: gofix -r error -force=error
R=golang-dev, bsiegert, iant
CC=golang-dev
https://golang.org/cl/5294074
diff --git a/src/pkg/regexp/all_test.go b/src/pkg/regexp/all_test.go
index 77f32ca..c707b11 100644
--- a/src/pkg/regexp/all_test.go
+++ b/src/pkg/regexp/all_test.go
@@ -5,7 +5,6 @@
package regexp
import (
- "os"
"strings"
"testing"
)
@@ -53,10 +52,10 @@
}
*/
-func compileTest(t *testing.T, expr string, error os.Error) *Regexp {
+func compileTest(t *testing.T, expr string, error error) *Regexp {
re, err := Compile(expr)
if err != error {
- t.Error("compiling `", expr, "`; unexpected error: ", err.String())
+ t.Error("compiling `", expr, "`; unexpected error: ", err.Error())
}
return re
}
diff --git a/src/pkg/regexp/exec_test.go b/src/pkg/regexp/exec_test.go
index 905fd4e..499d1a5 100644
--- a/src/pkg/regexp/exec_test.go
+++ b/src/pkg/regexp/exec_test.go
@@ -104,7 +104,7 @@
for {
line, err := r.ReadString('\n')
if err != nil {
- if err == os.EOF {
+ if err == io.EOF {
break
}
t.Fatalf("%s:%d: %v", file, lineno, err)
@@ -141,7 +141,7 @@
}
re, err = tryCompile(q)
if err != nil {
- if err.String() == "error parsing regexp: invalid escape sequence: `\\C`" {
+ if err.Error() == "error parsing regexp: invalid escape sequence: `\\C`" {
// We don't and likely never will support \C; keep going.
continue
}
@@ -275,7 +275,7 @@
return true
}
-func tryCompile(s string) (re *Regexp, err os.Error) {
+func tryCompile(s string) (re *Regexp, err error) {
// Protect against panic during Compile.
defer func() {
if r := recover(); r != nil {
@@ -370,7 +370,7 @@
lineno++
line, err := b.ReadString('\n')
if err != nil {
- if err != os.EOF {
+ if err != io.EOF {
t.Errorf("%s:%d: %v", file, lineno, err)
}
break Reading
@@ -629,7 +629,7 @@
return
}
var v = -1
- var err os.Error
+ var err error
if s[:i] != "?" {
v, err = strconv.Atoi(s[:i])
if err != nil {
diff --git a/src/pkg/regexp/regexp.go b/src/pkg/regexp/regexp.go
index a1b7951..9e9fb85 100644
--- a/src/pkg/regexp/regexp.go
+++ b/src/pkg/regexp/regexp.go
@@ -56,7 +56,6 @@
import (
"bytes"
"io"
- "os"
"regexp/syntax"
"strconv"
"strings"
@@ -69,7 +68,7 @@
// Error is the local type for a parsing error.
type Error string
-func (e Error) String() string {
+func (e Error) Error() string {
return string(e)
}
@@ -108,7 +107,7 @@
// that Perl, Python, and other implementations use, although this
// package implements it without the expense of backtracking.
// For POSIX leftmost-longest matching, see CompilePOSIX.
-func Compile(expr string) (*Regexp, os.Error) {
+func Compile(expr string) (*Regexp, error) {
return compile(expr, syntax.Perl, false)
}
@@ -131,11 +130,11 @@
// subexpression, then the second, and so on from left to right.
// The POSIX rule is computationally prohibitive and not even well-defined.
// See http://swtch.com/~rsc/regexp/regexp2.html#posix for details.
-func CompilePOSIX(expr string) (*Regexp, os.Error) {
+func CompilePOSIX(expr string) (*Regexp, error) {
return compile(expr, syntax.POSIX, true)
}
-func compile(expr string, mode syntax.Flags, longest bool) (*Regexp, os.Error) {
+func compile(expr string, mode syntax.Flags, longest bool) (*Regexp, error) {
re, err := syntax.Parse(expr, mode)
if err != nil {
return nil, err
@@ -196,7 +195,7 @@
func MustCompile(str string) *Regexp {
regexp, error := Compile(str)
if error != nil {
- panic(`regexp: Compile(` + quote(str) + `): ` + error.String())
+ panic(`regexp: Compile(` + quote(str) + `): ` + error.Error())
}
return regexp
}
@@ -207,7 +206,7 @@
func MustCompilePOSIX(str string) *Regexp {
regexp, error := CompilePOSIX(str)
if error != nil {
- panic(`regexp: CompilePOSIX(` + quote(str) + `): ` + error.String())
+ panic(`regexp: CompilePOSIX(` + quote(str) + `): ` + error.Error())
}
return regexp
}
@@ -392,7 +391,7 @@
// MatchReader checks whether a textual regular expression matches the text
// read by the RuneReader. More complicated queries need to use Compile and
// the full Regexp interface.
-func MatchReader(pattern string, r io.RuneReader) (matched bool, error os.Error) {
+func MatchReader(pattern string, r io.RuneReader) (matched bool, error error) {
re, err := Compile(pattern)
if err != nil {
return false, err
@@ -403,7 +402,7 @@
// MatchString checks whether a textual regular expression
// matches a string. More complicated queries need
// to use Compile and the full Regexp interface.
-func MatchString(pattern string, s string) (matched bool, error os.Error) {
+func MatchString(pattern string, s string) (matched bool, error error) {
re, err := Compile(pattern)
if err != nil {
return false, err
@@ -414,7 +413,7 @@
// Match checks whether a textual regular expression
// matches a byte slice. More complicated queries need
// to use Compile and the full Regexp interface.
-func Match(pattern string, b []byte) (matched bool, error os.Error) {
+func Match(pattern string, b []byte) (matched bool, error error) {
re, err := Compile(pattern)
if err != nil {
return false, err
diff --git a/src/pkg/regexp/syntax/compile.go b/src/pkg/regexp/syntax/compile.go
index c90de3f..21c6565 100644
--- a/src/pkg/regexp/syntax/compile.go
+++ b/src/pkg/regexp/syntax/compile.go
@@ -1,9 +1,6 @@
package syntax
-import (
- "os"
- "unicode"
-)
+import "unicode"
// A patchList is a list of instruction pointers that need to be filled in (patched).
// Because the pointers haven't been filled in yet, we can reuse their storage
@@ -76,7 +73,7 @@
// Compile compiles the regexp into a program to be executed.
// The regexp should have been simplified already (returned from re.Simplify).
-func Compile(re *Regexp) (*Prog, os.Error) {
+func Compile(re *Regexp) (*Prog, error) {
var c compiler
c.init()
f := c.compile(re)
diff --git a/src/pkg/regexp/syntax/parse.go b/src/pkg/regexp/syntax/parse.go
index f560262..29ad4d2 100644
--- a/src/pkg/regexp/syntax/parse.go
+++ b/src/pkg/regexp/syntax/parse.go
@@ -5,7 +5,6 @@
package syntax
import (
- "os"
"sort"
"strings"
"unicode"
@@ -19,7 +18,7 @@
Expr string
}
-func (e *Error) String() string {
+func (e *Error) Error() string {
return "error parsing regexp: " + e.Code.String() + ": `" + e.Expr + "`"
}
@@ -222,7 +221,7 @@
// before is the regexp suffix starting at the repetition operator.
// after is the regexp suffix following after the repetition operator.
// repeat returns an updated 'after' and an error, if any.
-func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) (string, os.Error) {
+func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) (string, error) {
flags := p.flags
if p.flags&PerlX != 0 {
if len(after) > 0 && after[0] == '?' {
@@ -649,7 +648,7 @@
// Parsing.
-func Parse(s string, flags Flags) (*Regexp, os.Error) {
+func Parse(s string, flags Flags) (*Regexp, error) {
if flags&Literal != 0 {
// Trivial parser for literal string.
if err := checkUTF8(s); err != nil {
@@ -661,7 +660,7 @@
// Otherwise, must do real work.
var (
p parser
- err os.Error
+ err error
c rune
op Op
lastRepeat string
@@ -889,7 +888,7 @@
// parsePerlFlags parses a Perl flag setting or non-capturing group or both,
// like (?i) or (?: or (?i:. It removes the prefix from s and updates the parse state.
// The caller must have ensured that s begins with "(?".
-func (p *parser) parsePerlFlags(s string) (rest string, err os.Error) {
+func (p *parser) parsePerlFlags(s string) (rest string, err error) {
t := s
// Check for named captures, first introduced in Python's regexp library.
@@ -1069,7 +1068,7 @@
}
// parseVerticalBar handles a | in the input.
-func (p *parser) parseVerticalBar() os.Error {
+func (p *parser) parseVerticalBar() error {
p.concat()
// The concatenation we just parsed is on top of the stack.
@@ -1152,7 +1151,7 @@
}
// parseRightParen handles a ) in the input.
-func (p *parser) parseRightParen() os.Error {
+func (p *parser) parseRightParen() error {
p.concat()
if p.swapVerticalBar() {
// pop vertical bar
@@ -1186,7 +1185,7 @@
// parseEscape parses an escape sequence at the beginning of s
// and returns the rune.
-func (p *parser) parseEscape(s string) (r rune, rest string, err os.Error) {
+func (p *parser) parseEscape(s string) (r rune, rest string, err error) {
t := s[1:]
if t == "" {
return 0, "", &Error{ErrTrailingBackslash, ""}
@@ -1302,7 +1301,7 @@
// parseClassChar parses a character class character at the beginning of s
// and returns it.
-func (p *parser) parseClassChar(s, wholeClass string) (r rune, rest string, err os.Error) {
+func (p *parser) parseClassChar(s, wholeClass string) (r rune, rest string, err error) {
if s == "" {
return 0, "", &Error{Code: ErrMissingBracket, Expr: wholeClass}
}
@@ -1338,7 +1337,7 @@
// parseNamedClass parses a leading POSIX named character class like [:alnum:]
// from the beginning of s. If one is present, it appends the characters to r
// and returns the new slice r and the remainder of the string.
-func (p *parser) parseNamedClass(s string, r []rune) (out []rune, rest string, err os.Error) {
+func (p *parser) parseNamedClass(s string, r []rune) (out []rune, rest string, err error) {
if len(s) < 2 || s[0] != '[' || s[1] != ':' {
return
}
@@ -1401,7 +1400,7 @@
// parseUnicodeClass parses a leading Unicode character class like \p{Han}
// from the beginning of s. If one is present, it appends the characters to r
// and returns the new slice r and the remainder of the string.
-func (p *parser) parseUnicodeClass(s string, r []rune) (out []rune, rest string, err os.Error) {
+func (p *parser) parseUnicodeClass(s string, r []rune) (out []rune, rest string, err error) {
if p.flags&UnicodeGroups == 0 || len(s) < 2 || s[0] != '\\' || s[1] != 'p' && s[1] != 'P' {
return
}
@@ -1474,7 +1473,7 @@
// parseClass parses a character class at the beginning of s
// and pushes it onto the parse stack.
-func (p *parser) parseClass(s string) (rest string, err os.Error) {
+func (p *parser) parseClass(s string) (rest string, err error) {
t := s[1:] // chop [
re := p.newRegexp(OpCharClass)
re.Flags = p.flags
@@ -1824,7 +1823,7 @@
p[i], p[i+1], p[j], p[j+1] = p[j], p[j+1], p[i], p[i+1]
}
-func checkUTF8(s string) os.Error {
+func checkUTF8(s string) error {
for s != "" {
rune, size := utf8.DecodeRuneInString(s)
if rune == utf8.RuneError && size == 1 {
@@ -1835,7 +1834,7 @@
return nil
}
-func nextRune(s string) (c rune, t string, err os.Error) {
+func nextRune(s string) (c rune, t string, err error) {
c, size := utf8.DecodeRuneInString(s)
if c == utf8.RuneError && size == 1 {
return 0, "", &Error{Code: ErrInvalidUTF8, Expr: s}