summaryrefslogtreecommitdiff
path: root/libgo/go/regexp/syntax/regexp.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-09-24 21:46:21 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-09-24 21:46:21 +0000
commitdd931d9b48647e898dc80927c532ae93cc09e192 (patch)
tree71be2295cd79b8a182f6130611658db8628772d5 /libgo/go/regexp/syntax/regexp.go
parent779d8a5ad09b01428726ea5a0e6c87bd9ac3c0e4 (diff)
libgo: update to Go 1.11
Reviewed-on: https://go-review.googlesource.com/136435 gotools/: * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to make sure it is writable. (check-go-tools): Likewise. (check-vet): Copy internal/objabi to check-vet-dir. * Makefile.in: Rebuild. From-SVN: r264546
Diffstat (limited to 'libgo/go/regexp/syntax/regexp.go')
-rw-r--r--libgo/go/regexp/syntax/regexp.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/libgo/go/regexp/syntax/regexp.go b/libgo/go/regexp/syntax/regexp.go
index 0fe9269f255..a3f56f8c902 100644
--- a/libgo/go/regexp/syntax/regexp.go
+++ b/libgo/go/regexp/syntax/regexp.go
@@ -8,7 +8,6 @@ package syntax
// In this package, re is always a *Regexp and r is always a rune.
import (
- "bytes"
"strconv"
"strings"
"unicode"
@@ -27,6 +26,8 @@ type Regexp struct {
Name string // capturing name, for OpCapture
}
+//go:generate stringer -type Op -trimprefix Op
+
// An Op is a single regular expression operator.
type Op uint8
@@ -112,7 +113,7 @@ func (x *Regexp) Equal(y *Regexp) bool {
}
// writeRegexp writes the Perl syntax for the regular expression re to b.
-func writeRegexp(b *bytes.Buffer, re *Regexp) {
+func writeRegexp(b *strings.Builder, re *Regexp) {
switch re.Op {
default:
b.WriteString("<invalid op" + strconv.Itoa(int(re.Op)) + ">")
@@ -243,14 +244,14 @@ func writeRegexp(b *bytes.Buffer, re *Regexp) {
}
func (re *Regexp) String() string {
- var b bytes.Buffer
+ var b strings.Builder
writeRegexp(&b, re)
return b.String()
}
const meta = `\.+*?()|[]{}^$`
-func escape(b *bytes.Buffer, r rune, force bool) {
+func escape(b *strings.Builder, r rune, force bool) {
if unicode.IsPrint(r) {
if strings.ContainsRune(meta, r) || force {
b.WriteRune('\\')