shithub: mc

Download patch

ref: b8739b70c8fbb2f8930c7cb2b1d1a6544aa7024f
parent: 32d45b637cc4faa4d3510c9f53c20c377c660723
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Apr 12 15:38:05 EDT 2015

Now actually fix it.

--- a/libstd/pathjoin.myr
+++ b/libstd/pathjoin.myr
@@ -1,7 +1,9 @@
 use "alloc.use"
+use "extremum.use"
 use "strjoin.use"
 use "strsplit.use"
 use "sleq.use"
+use "sljoin.use"
 use "sldup.use"
 use "slcp.use"
 use "die.use"
@@ -18,11 +20,14 @@
 }
 
 const pathjoin = {l
-	var p, q
+	var p, i, q
 
-	if l.len > 0
-		p = strjoin(l, "/")
+	for i = 0; i < l.len; i++
+		if l[i].len != 0
+			break
+		;;
 	;;
+	p = strjoin(l[i:], "/")
 	q = pathnorm(p)
 	slfree(p)
 	-> q
--- a/test/data/stdpathnorm-expected
+++ b/test/data/stdpathnorm-expected
@@ -22,3 +22,7 @@
 .
 /
 ..
+a/b
+a/b/c
+foo
+foo/bar
--- a/test/stdpathnorm.myr
+++ b/test/stdpathnorm.myr
@@ -36,4 +36,11 @@
 	std.put("%s\n", std.pathnorm("foo/bar/.././.."))
 	std.put("%s\n", std.pathnorm("//foo/../bar/../.."))
 	std.put("%s\n", std.pathnorm("foo/../bar/../.."))
+
+	/* vanilla pathjoin */
+	std.put("%s\n", std.pathcat("a", "b"))
+	std.put("%s\n", std.pathjoin(["a", "b", "c"][:]))
+	/* pathjoin with empty dirs */
+	std.put("%s\n", std.pathcat("", "foo"))
+	std.put("%s\n", std.pathjoin(["", "foo", "bar"][:]))
 }