]> Cypherpunks repositories - gostls13.git/commitdiff
update the tree to use the new regexp methods
authorRob Pike <r@golang.org>
Thu, 12 Aug 2010 06:48:41 +0000 (16:48 +1000)
committerRob Pike <r@golang.org>
Thu, 12 Aug 2010 06:48:41 +0000 (16:48 +1000)
R=rsc
CC=golang-dev
https://golang.org/cl/1983043

src/cmd/godoc/codewalk.go
src/cmd/godoc/godoc.go
src/cmd/goinstall/download.go
src/pkg/go/doc/comment.go
src/pkg/go/doc/doc.go
src/pkg/mime/multipart/multipart.go
test/bench/regex-dna-parallel.go
test/bench/regex-dna.go

index 4e5a9b9da46ada35cc98a857eda2feee3f57b289..02417bfefbbf14d6e958597a2d3bdf46994766d5 100644 (file)
@@ -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)
index d08fb5beba1ebfcba4e7d6bbd92a08d1a9be564a..c8af916736b59ce38e859f8ec0513a66d34621a2 100644 (file)
@@ -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]]))
        }
index 3422e81863cc416f6f503780ff6b341a6b54abbc..b5e74fe69371bcbfea3f316c8d646477c0db75fd 100644 (file)
@@ -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 {
index 55ddf8b7557b06ab9e5481205c6e317716d00ef2..4c792309998929880092d37cfd24a87387f02bf3 100644 (file)
@@ -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)
index b73fd285c1d4964366382fff36d7f542163d6780..a5b9aeb66e6967585ca6b0a6c75c523cbb2121e4 100644 (file)
@@ -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
index e009132515402e84c13253a7c4245544fd60f1e5..1d855c74c9d493c41b348349354ebc46a4c110d4 100644 (file)
@@ -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?
index d33f2466e46fb15060ffc53f083554faa1d84b4d..e8e62b806da62a1633e98430ab83809132eb808c 100644 (file)
@@ -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++
index 22de2c6aae427b76e5f6903aeed4c031949dde64..dc31db7685a4b1d5f1af39911e7895ca97631cde 100644 (file)
@@ -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
                }