diff options
author | Robert Griesemer <gri@golang.org> | 2010-02-11 13:59:10 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2010-02-11 13:59:10 -0800 |
commit | 60354a59580fc6e5a5af013363ce03949bac04f4 (patch) | |
tree | 03d7708983588239f74e4e1f8a8d4953effd178a | |
parent | 60cf6d9f236e366e206901a2a902c1f014d21858 (diff) | |
download | golang-60354a59580fc6e5a5af013363ce03949bac04f4.tar.gz |
correct meaning of "absolute" and "relative"
(implementation was swapped)
R=adg
CC=golang-dev, rsc
http://codereview.appspot.com/207069
-rw-r--r-- | src/cmd/godoc/mapping.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/cmd/godoc/mapping.go b/src/cmd/godoc/mapping.go index 62f85a074..1143a4bdc 100644 --- a/src/cmd/godoc/mapping.go +++ b/src/cmd/godoc/mapping.go @@ -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 +} |