Commit d31ee536 authored by Rob Pike's avatar Rob Pike

update the tree to use the new regexp methods

R=rsc
CC=golang-dev
https://golang.org/cl/1983043
parent 4fb58832
......@@ -451,13 +451,13 @@ func addrRegexp(data []byte, lo, hi int, dir byte, pattern string) (int, int, os
// through file, but that seems like overkill.
return 0, 0, os.NewError("reverse search not implemented")
}
m := re.Execute(data[hi:])
m := re.FindIndex(data[hi:])
if len(m) > 0 {
m[0] += hi
m[1] += hi
} else if hi > 0 {
// No match. Wrap to beginning of data.
m = re.Execute(data)
m = re.FindIndex(data)
}
if len(m) == 0 {
return 0, 0, os.NewError("no match for " + pattern)
......
......@@ -943,7 +943,7 @@ var (
func extractString(src []byte, rx *regexp.Regexp) (s string) {
m := rx.Execute(src)
m := rx.Find(src)
if len(m) >= 4 {
s = strings.TrimSpace(string(src[m[2]:m[3]]))
}
......
......@@ -41,13 +41,13 @@ func download(pkg string) (string, os.Error) {
if strings.Index(pkg, "..") >= 0 {
return "", os.ErrorString("invalid path (contains ..)")
}
if m := bitbucket.MatchStrings(pkg); m != nil {
if m := bitbucket.FindStringSubmatch(pkg); m != nil {
if err := vcsCheckout(&hg, root+m[1], "http://"+m[1], m[1]); err != nil {
return "", err
}
return root + pkg, nil
}
if m := googlecode.MatchStrings(pkg); m != nil {
if m := googlecode.FindStringSubmatch(pkg); m != nil {
var v *vcs
switch m[2] {
case "hg":
......@@ -63,7 +63,7 @@ func download(pkg string) (string, os.Error) {
}
return root + pkg, nil
}
if m := github.MatchStrings(pkg); m != nil {
if m := github.FindStringSubmatch(pkg); m != nil {
if strings.HasSuffix(m[1], ".git") {
return "", os.ErrorString("repository " + pkg + " should not have .git suffix")
}
......@@ -72,7 +72,7 @@ func download(pkg string) (string, os.Error) {
}
return root + pkg, nil
}
if m := launchpad.MatchStrings(pkg); m != nil {
if m := launchpad.FindStringSubmatch(pkg); m != nil {
// Either lp.net/<project>[/<series>[/<path>]]
// or lp.net/~<user or team>/<project>/<branch>[/<path>]
if err := vcsCheckout(&bzr, root+m[1], "https://"+m[1], m[1]); err != nil {
......
......@@ -199,8 +199,8 @@ var (
// and '' into &rdquo;).
func emphasize(w io.Writer, line []byte, words map[string]string, nice bool) {
for {
m := matchRx.Execute(line)
if len(m) == 0 {
m := matchRx.Find(line)
if m == nil {
break
}
// m >= 6 (two parenthesized sub-regexps in matchRx, 1st one is identRx)
......
......@@ -309,7 +309,7 @@ func (doc *docReader) addFile(src *ast.File) {
// collect BUG(...) comments
for _, c := range src.Comments {
text := c.List[0].Text
if m := bug_markers.Execute(text); len(m) > 0 {
if m := bug_markers.Find(text); m != nil {
// found a BUG comment; maybe empty
if btxt := text[m[1]:]; bug_content.Match(btxt) {
// non-empty BUG comment; collect comment without BUG prefix
......
......@@ -103,7 +103,7 @@ func (bp *Part) populateHeaders() os.Error {
if line == "\n" || line == "\r\n" {
return nil
}
if matches := headerRegexp.MatchStrings(line); len(matches) == 3 {
if matches := headerRegexp.FindStringSubmatch(line); len(matches) == 3 {
key := matches[1]
value := matches[2]
// TODO: canonicalize headers ala http.Request.Header?
......
......@@ -77,8 +77,8 @@ func countMatches(pat string, bytes []byte) int {
re := regexp.MustCompile(pat)
n := 0
for {
e := re.Execute(bytes)
if len(e) == 0 {
e := re.FindIndex(bytes)
if e == nil {
break
}
n++
......
......@@ -76,7 +76,7 @@ func countMatches(pat string, bytes []byte) int {
re := regexp.MustCompile(pat)
n := 0
for {
e := re.Execute(bytes)
e := re.FindIndex(bytes)
if len(e) == 0 {
break
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment