gcc/libstdc++-v3/testsuite/27_io
Jonathan Wakely ea182fe636 libstdc++: Handle type-changing path concatenations (PR 94063)
The filesystem::path::operator+= and filesystem::path::concat functions
operate directly on the native format of the path and so can cause a
path to mutate to a completely different type.

For Windows combining a filename "x" with a filename ":" produces a
root-name "x:". Similarly, a Cygwin root-directory "/" combined with a
root-directory and filename "/x" produces a root-name "//x".

Before this patch the implemenation didn't support those kind of
mutations, assuming that concatenating two filenames would always
produce a filename and concatenating with a root-dir would still have a
root-dir.

This patch fixes it simply by checking for the problem cases and
creating a new path by re-parsing the result of the string
concatenation. This is slightly suboptimal because the argument has
already been parsed if it's a path, but more importantly it doesn't
reuse any excess capacity that the path object being modified might
already have allocated. That can be fixed later though.

	PR libstdc++/94063
	* src/c++17/fs_path.cc (path::operator+=(const path&)): Add kluge to
	handle concatenations that change the type of the first component.
	(path::operator+=(basic_string_view<value_type>)): Likewise.
	* testsuite/27_io/filesystem/path/concat/94063.cc: New test.
2020-03-09 23:22:57 +00:00
..
basic_filebuf Update copyright years. 2020-01-01 12:51:42 +01:00
basic_fstream Update copyright years. 2020-01-01 12:51:42 +01:00
basic_ifstream Update copyright years. 2020-01-01 12:51:42 +01:00
basic_ios Update copyright years. 2020-01-01 12:51:42 +01:00
basic_iostream Update copyright years. 2020-01-01 12:51:42 +01:00
basic_istream Update copyright years. 2020-01-01 12:51:42 +01:00
basic_istringstream Update copyright years. 2020-01-01 12:51:42 +01:00
basic_ofstream Update copyright years. 2020-01-01 12:51:42 +01:00
basic_ostream Update copyright years. 2020-01-01 12:51:42 +01:00
basic_ostringstream Update copyright years. 2020-01-01 12:51:42 +01:00
basic_streambuf Update copyright years. 2020-01-01 12:51:42 +01:00
basic_stringbuf Update copyright years. 2020-01-01 12:51:42 +01:00
basic_stringstream Update copyright years. 2020-01-01 12:51:42 +01:00
filesystem libstdc++: Handle type-changing path concatenations (PR 94063) 2020-03-09 23:22:57 +00:00
fpos tolerate padding in mbstate_t 2020-01-23 16:36:34 -03:00
headers Update copyright years. 2020-01-01 12:51:42 +01:00
ios_base Update copyright years. 2020-01-01 12:51:42 +01:00
manipulators Update copyright years. 2020-01-01 12:51:42 +01:00
objects Update copyright years. 2020-01-01 12:51:42 +01:00
types Update copyright years. 2020-01-01 12:51:42 +01:00
rvalue_streams-2.cc Update copyright years. 2020-01-01 12:51:42 +01:00
rvalue_streams.cc Update copyright years. 2020-01-01 12:51:42 +01:00