Fix handling of POSIX paths containing a root-name

Programming / Compilers / GCC - redi [138bc75d-0d04-0410-961f-82ee72b054a4] - 13 December 2018 20:34 EST

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)) [SLASHSLASH_IS_ROOT_NAME]: Likewise. (path::operator/=(const path&)) [SLASHSLASH_IS_ROOT_NAME]: Likewise. (path::_M_concat(basic_string_view)) [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.

b15b89d09ec Fix handling of POSIX paths containing a root-name
libstdc++-v3/ChangeLog | 14 ++++
libstdc++-v3/src/filesystem/std-path.cc | 84 +++++++++++++++++++---
.../filesystem/path/decompose/root_directory.cc | 4 ++
3 files changed, 91 insertions(+), 11 deletions(-)

Upstream: gcc.gnu.org


  • Share