PR libstdc++/87116 fix path::lexically_normal() handling of dot-dot
commit79ec46f461e9699a8fbb65718287c23d80efeeb2
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Aug 2018 15:33:53 +0000 (28 15:33 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Aug 2018 15:33:53 +0000 (28 15:33 +0000)
tree4a236cb188b846308f29b7524e0686eb729df251
parent70775f2c97d4eb1ea12a6cda8b702803cfda3bbf
PR libstdc++/87116 fix path::lexically_normal() handling of dot-dot

Previously the logic that turned "a/b/c/../.." into "a/" failed to
preserve an empty path at the end of the iteration sequence, as required
by the trailing slash. That meant the result didn't meet the class
invariants, and that "a/b/c/d/../../.." would remove four components
instead of the three that "../../.." should remove.

PR libstdc++/87116
* src/filesystem/std-path.cc (path::lexically_normal): When handling
a dot-dot filename, preserve an empty final component in the iteration
sequence.
[_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Use preferred-separator for
root-directory.
* testsuite/27_io/filesystem/path/generation/normal.cc: Add new tests
for more than two adjacent dot-dot filenames.
[_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Replace slashes with
preferred-separator in expected normalized strings.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263922 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/src/filesystem/std-path.cc
libstdc++-v3/testsuite/27_io/filesystem/path/generation/normal.cc