@@ -1194,6 +1194,13 @@ requirements of the license of GCC.
<listitem><para>Change constructors to constrained templates.
</para></listitem></varlistentry>
+ <varlistentry xml:id="manual.bugs.dr3096"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#3096">3096</link>:
+ <emphasis><code>path::lexically_relative</code> is confused by trailing slashes
+ </emphasis>
+ </term>
+ <listitem><para>Implement the fix for trailing slashes.
+ </para></listitem></varlistentry>
+
</variablelist>
</section>
@@ -529,10 +529,12 @@ path::lexically_relative(const path& base) const
const path& p = *b;
if (is_dotdot(p))
--n;
- else if (!is_dot(p))
+ else if (!p.empty() && !is_dot(p))
++n;
}
- if (n >= 0)
+ if (n == 0 && (a == end() || a->empty()))
+ ret = ".";
+ else if (n >= 0)
{
const path dotdot("..");
while (n--)
@@ -45,6 +45,25 @@ test02()
compare_paths( p.lexically_relative(p), "." );
compare_paths( p.lexically_relative("a/../a/b/../b/c/../c/."), "../../b/c" );
compare_paths( p.lexically_relative("../../../"), "" );
+
+ compare_paths( path("a/./.").lexically_relative("a"), "./." );
+}
+
+void
+test03()
+{
+ // LWG 3096
+ compare_paths( path("/dir").lexically_relative("/dir"), "." );
+ compare_paths( path("/dir").lexically_relative("/dir/"), "." );
+ compare_paths( path("/dir").lexically_relative("/dir/."), "." );
+
+ compare_paths( path("/dir/").lexically_relative("/dir"), "." );
+ compare_paths( path("/dir/").lexically_relative("/dir/"), "." );
+ compare_paths( path("/dir/").lexically_relative("/dir/."), "." );
+
+ compare_paths( path("/dir/.").lexically_relative("/dir"), "." );
+ compare_paths( path("/dir/.").lexically_relative("/dir/"), "." );
+ compare_paths( path("/dir/.").lexically_relative("/dir/."), "." );
}
int
@@ -52,4 +71,5 @@ main()
{
test01();
test02();
+ test03();
}