[Bug libstdc++/87116] Incorrect result of std::filesystem::path::lexically_normal() for more than 3 dot-dot elements

2018-08-28 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87116

Jonathan Wakely  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Jonathan Wakely  ---
Fixed for gcc 8.3

[Bug libstdc++/87116] Incorrect result of std::filesystem::path::lexically_normal() for more than 3 dot-dot elements

2018-08-28 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87116

--- Comment #3 from Jonathan Wakely  ---
Author: redi
Date: Tue Aug 28 15:52:18 2018
New Revision: 263923

URL: https://gcc.gnu.org/viewcvs?rev=263923=gcc=rev
Log:
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.

Modified:
branches/gcc-8-branch/libstdc++-v3/ChangeLog
branches/gcc-8-branch/libstdc++-v3/src/filesystem/std-path.cc
   
branches/gcc-8-branch/libstdc++-v3/testsuite/27_io/filesystem/path/generation/normal.cc

[Bug libstdc++/87116] Incorrect result of std::filesystem::path::lexically_normal() for more than 3 dot-dot elements

2018-08-28 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87116

--- Comment #2 from Jonathan Wakely  ---
Author: redi
Date: Tue Aug 28 15:33:53 2018
New Revision: 263922

URL: https://gcc.gnu.org/viewcvs?rev=263922=gcc=rev
Log:
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.

Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/src/filesystem/std-path.cc
trunk/libstdc++-v3/testsuite/27_io/filesystem/path/generation/normal.cc

[Bug libstdc++/87116] Incorrect result of std::filesystem::path::lexically_normal() for more than 3 dot-dot elements

2018-08-27 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87116

--- Comment #1 from Jonathan Wakely  ---
The problem is in this step of the normalisation algorithm:

  - As long as any appear, remove a non-dot-dot filename immediately followed
by a directory-separator and a dot-dot filename, along with any immediately
following directory-separator.

The second time I do that, I leave a trailing slash in the native format
string, but not in the vector of path components. The third time then removes
two components not one.

Shouldn't be too hard to fix.

[Bug libstdc++/87116] Incorrect result of std::filesystem::path::lexically_normal() for more than 3 dot-dot elements

2018-08-27 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87116

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2018-08-27
   Assignee|unassigned at gcc dot gnu.org  |redi at gcc dot gnu.org
   Target Milestone|--- |8.3
 Ever confirmed|0   |1