[racket] Bug in path-replace-suffix?
Hello,
during the development of the PLaneT package for protocol buffers [1] a
likely bug in Racket's standard library function path-replace-suffix has
shown up [2].
When you apply path-replace-suffix to a path that is not native to the
platform on which Racket is running, the procedure strips all leading
directories from the path. For example on Linux:
$ racket
Welcome to Racket v5.3.6.
> (path-replace-suffix
(string->some-system-path "foo/bar.x" 'unix)
".y")
#<path:foo/bar.y>
> (path-replace-suffix
(string->some-system-path "foo/bar.x" 'windows)
".y")
#<windows-path:bar.y>
> (path-replace-suffix
(string->some-system-path "foo\\bar.x" 'windows)
".y")
#<windows-path:bar.y>
Or on Windows:
Microsoft Windows [Version 6.1.7601]
[...]>racket
Welcome to Racket v5.3.6.
> (path-replace-suffix
(string->some-system-path "foo/bar.x" 'unix)
".y")
#<unix-path:bar.y>
> (path-replace-suffix
(string->some-system-path "foo/bar.x" 'windows)
".y")
#<path:foo/bar.y>
> (path-replace-suffix
(string->some-system-path "foo\\bar.x" 'windows)
".y")
#<path:foo\bar.y>
I think this behaviour contradicts the documentation which states that
place-replace-suffix should only touch the filename suffix, should leave
the rest of the path as is and should also work with paths for other
systems.
Ciao,
Thomas
--
[1] The package in question is
http://planet.racket-lang.org/display.ss?package=protobuf.plt&owner=murphy
[2] The relevant bug tracker entry for the package is
http://planet.racket-lang.org/trac/ticket/1519
--
When C++ is your hammer, every problem looks like your thumb.