shithub: mc

Download patch

ref: 32d45b637cc4faa4d3510c9f53c20c377c660723
parent: 8a6221f985e1a493a163d0dde1c025231e1adafb
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Apr 12 15:22:56 EDT 2015

Fix std.pathnorm for empty strings.

    The normalized version of "" should be ".", not "/". Make
    it so.

--- a/libstd/pathjoin.myr
+++ b/libstd/pathjoin.myr
@@ -20,7 +20,9 @@
 const pathjoin = {l
 	var p, q
 
-	p = strjoin(l, "/")
+	if l.len > 0
+		p = strjoin(l, "/")
+	;;
 	q = pathnorm(p)
 	slfree(p)
 	-> q
--- a/test/data/stdpathnorm-expected
+++ b/test/data/stdpathnorm-expected
@@ -1,3 +1,4 @@
+.
 foo
 foo/bar
 /foo/bar
--- a/test/stdpathnorm.myr
+++ b/test/stdpathnorm.myr
@@ -2,6 +2,7 @@
 
 const main = {
 	/* untouched */
+	std.put("%s\n", std.pathnorm(""))
 	std.put("%s\n", std.pathnorm("foo"))
 	std.put("%s\n", std.pathnorm("foo/bar"))
 	std.put("%s\n", std.pathnorm("/foo/bar"))