Fix handling of POSIX paths containing a root-name
authorJonathan Wakely <jwakely@redhat.com>
Thu, 13 Dec 2018 20:34:10 +0000 (20:34 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 13 Dec 2018 20:34:10 +0000 (20:34 +0000)
commit2b462958e2db15dc6f55ed361d47cdbc62d64ea0
tree24649584cde525313a354705adf2b63dcdb786fb
parent4f87bb8d6e8dec21a07f1fba641a78a127281349
Fix handling of POSIX paths containing a root-name

Fix path appending and concatenating to work correctly for a leading
root-name. Check a new macro, SLASHSLASH_IS_ROOT_NAME, instead of making
the behaviour depend directly on __CYGWIN__.

* src/filesystem/std-path.cc (SLASHSLASH_IS_ROOT_NAME): New macro to
control whether interpret paths with two slashes as a root-name.
(path::operator/=(const path&)) [SLASHSLASH_IS_ROOT_NAME]: Add a
root-directory when appending to a root-name.
(path::_M_append(basic_string_view<value_type>))
[SLASHSLASH_IS_ROOT_NAME]: Likewise.
(path::operator/=(const path&)) [SLASHSLASH_IS_ROOT_NAME]: Likewise.
(path::_M_concat(basic_string_view<value_type>))
[SLASHSLASH_IS_ROOT_NAME]: Likewise.
(path::lexically_normal()) [SLASHSLASH_IS_ROOT_NAME]: Use += instead
of /= to add a root-directory to the result.
* testsuite/27_io/filesystem/path/decompose/root_directory.cc: Fix
expected result for Cygwin.

From-SVN: r267107
libstdc++-v3/ChangeLog
libstdc++-v3/src/filesystem/std-path.cc
libstdc++-v3/testsuite/27_io/filesystem/path/decompose/root_directory.cc