diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-06-25 16:20:03 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-06-25 16:20:03 +0000 |
commit | 4b786d35e0af0c254988199551709abef06b925e (patch) | |
tree | 5dfe28c3f573ae57b971ed4d9a1c99a76f0a70c4 /libgo/go/regexp | |
parent | 2e6c5d723ff7407704f2cbd343383991b498fb5b (diff) | |
download | gcc-4b786d35e0af0c254988199551709abef06b925e.tar.gz |
libgo: Update to Go 1.0.2 release.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188943 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/regexp')
-rw-r--r-- | libgo/go/regexp/regexp.go | 4 | ||||
-rw-r--r-- | libgo/go/regexp/syntax/parse.go | 7 | ||||
-rw-r--r-- | libgo/go/regexp/syntax/parse_test.go | 8 |
3 files changed, 15 insertions, 4 deletions
diff --git a/libgo/go/regexp/regexp.go b/libgo/go/regexp/regexp.go index 54c53776cf7..87e6b1c61e4 100644 --- a/libgo/go/regexp/regexp.go +++ b/libgo/go/regexp/regexp.go @@ -512,7 +512,7 @@ func (re *Regexp) replaceAll(bsrc []byte, src string, nmatch int, repl func(dst } // ReplaceAll returns a copy of src, replacing matches of the Regexp -// with the replacement string repl. Inside repl, $ signs are interpreted as +// with the replacement text repl. Inside repl, $ signs are interpreted as // in Expand, so for instance $1 represents the text of the first submatch. func (re *Regexp) ReplaceAll(src, repl []byte) []byte { n := 2 @@ -726,7 +726,7 @@ func (re *Regexp) FindSubmatch(b []byte) [][]byte { // the submatch with the corresponding index; other names refer to // capturing parentheses named with the (?P<name>...) syntax. A // reference to an out of range or unmatched index or a name that is not -// present in the regular expression is replaced with an empty string. +// present in the regular expression is replaced with an empty slice. // // In the $name form, name is taken to be as long as possible: $1x is // equivalent to ${1x}, not ${1}x, and, $10 is equivalent to ${10}, not ${1}0. diff --git a/libgo/go/regexp/syntax/parse.go b/libgo/go/regexp/syntax/parse.go index 71b07b99307..4c61cb3a064 100644 --- a/libgo/go/regexp/syntax/parse.go +++ b/libgo/go/regexp/syntax/parse.go @@ -48,6 +48,9 @@ const ( ErrTrailingBackslash ErrorCode = "trailing backslash at end of expression" ) +// TODO: Export for Go 1.1. +const errUnexpectedParen ErrorCode = "unexpected )" + func (e ErrorCode) String() string { return string(e) } @@ -1168,13 +1171,13 @@ func (p *parser) parseRightParen() error { n := len(p.stack) if n < 2 { - return &Error{ErrInternalError, ""} + return &Error{errUnexpectedParen, p.wholeRegexp} } re1 := p.stack[n-1] re2 := p.stack[n-2] p.stack = p.stack[:n-2] if re2.Op != opLeftParen { - return &Error{ErrMissingParen, p.wholeRegexp} + return &Error{errUnexpectedParen, p.wholeRegexp} } // Restore flags at time of paren. p.flags = re2.Flags diff --git a/libgo/go/regexp/syntax/parse_test.go b/libgo/go/regexp/syntax/parse_test.go index 88f65ecfc9b..e247cf203ac 100644 --- a/libgo/go/regexp/syntax/parse_test.go +++ b/libgo/go/regexp/syntax/parse_test.go @@ -442,10 +442,18 @@ var invalidRegexps = []string{ `(`, `)`, `(a`, + `a)`, + `(a))`, `(a|b|`, + `a|b|)`, + `(a|b|))`, `(a|b`, + `a|b)`, + `(a|b))`, `[a-z`, `([a-z)`, + `[a-z)`, + `([a-z]))`, `x{1001}`, `x{9876543210}`, `x{2,1}`, |