]> Cypherpunks repositories - gostls13.git/commitdiff
correct meaning of "absolute" and "relative"
authorRobert Griesemer <gri@golang.org>
Thu, 11 Feb 2010 21:59:10 +0000 (13:59 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 11 Feb 2010 21:59:10 +0000 (13:59 -0800)
(implementation was swapped)

R=adg
CC=golang-dev, rsc
https://golang.org/cl/207069

src/cmd/godoc/mapping.go

index 62f85a0747a843cdf0374dcff3f139a070d3338b..1143a4bdc005924fb07a58fa504cf32f206e7756 100644 (file)
@@ -141,21 +141,6 @@ func split(path string) (head, tail string) {
 // string is returned.
 //
 func (m *Mapping) ToAbsolute(path string) string {
-       for _, e := range m.list {
-               if strings.HasPrefix(path, e.path) {
-                       // /absolute/prefix/foo -> prefix/foo
-                       return pathutil.Join(e.prefix, path[len(e.path):]) // Join will remove a trailing '/'
-               }
-       }
-       return "" // no match
-}
-
-
-// ToRelative maps an absolute path to a relative path using the Mapping
-// specified by the receiver. If the path cannot be mapped, the empty
-// string is returned.
-//
-func (m *Mapping) ToRelative(path string) string {
        prefix, tail := split(path)
        for _, e := range m.list {
                switch {
@@ -174,3 +159,18 @@ func (m *Mapping) ToRelative(path string) string {
 
        return "" // no match
 }
+
+
+// ToRelative maps an absolute path to a relative path using the Mapping
+// specified by the receiver. If the path cannot be mapped, the empty
+// string is returned.
+//
+func (m *Mapping) ToRelative(path string) string {
+       for _, e := range m.list {
+               if strings.HasPrefix(path, e.path) {
+                       // /absolute/prefix/foo -> prefix/foo
+                       return pathutil.Join(e.prefix, path[len(e.path):]) // Join will remove a trailing '/'
+               }
+       }
+       return "" // no match
+}