r267814 - in /branches/gcc-8-branch/libstdc++-v...

redi@gcc.gnu.org redi@gcc.gnu.org
Thu Jan 10 16:02:00 GMT 2019


Author: redi
Date: Thu Jan 10 16:02:02 2019
New Revision: 267814

URL: https://gcc.gnu.org/viewcvs?rev=267814&root=gcc&view=rev
Log:
Fix handling of an empty filename at end of a path

The C++17 std::filesystem::path grammar allows an empty filename as the
last component (to signify a trailing slash). The existing code does not
handle this consistently, sometimes an empty filename has type _Multi
and sometimes it has type _Filename. This can result in a non-empty
iterator range for an empty filename component.

This change ensures that empty paths always have type _Filename and will
yield an empty iterator range.

Backport from mainline
2018-05-23  Jonathan Wakely  <jwakely@redhat.com>

	* include/bits/fs_path.h (path::_M_type): Change default member
	initializer to _Filename.
	(path::begin): Create past-the-end iterator for empty path.
	(path::has_relative_path()): Return false for empty filenames.
	(path::_M_split_cmpts): Set _M_type to _Filename for empty paths.
	Fix offset of empty final component.
	* testsuite/27_io/filesystem/path/itr/components.cc: New.
	* testsuite/27_io/filesystem/path/itr/traversal.cc: Add new inputs.

Added:
    branches/gcc-8-branch/libstdc++-v3/testsuite/27_io/filesystem/path/itr/components.cc
Modified:
    branches/gcc-8-branch/libstdc++-v3/ChangeLog
    branches/gcc-8-branch/libstdc++-v3/include/bits/fs_path.h
    branches/gcc-8-branch/libstdc++-v3/src/filesystem/std-path.cc
    branches/gcc-8-branch/libstdc++-v3/testsuite/27_io/filesystem/path/itr/traversal.cc



More information about the Libstdc++-cvs mailing list