PR libstdc++/89117 fix path::replace_extension("") case
authorJonathan Wakely <jwakely@redhat.com>
Wed, 30 Jan 2019 23:18:22 +0000 (23:18 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 30 Jan 2019 23:18:22 +0000 (23:18 +0000)
commit9c5365902aaee9033ed781bfc5e8147060e5b130
treeadddb8ab176cad6dcdff325584717707152c33ed
parentd1ac2471e7325d3e47d7b1c028c36be998f5747e
PR libstdc++/89117 fix path::replace_extension("") case

Previously the operator+=(extension) call would have re-parsed the path
and recreated the components with the right extension. Since optimising
it to not re-parse the whole string, we need to actually remove the
extension from the final filename before appending anything to it, and
append the dot to that final component too.

PR libstdc++/89117
* src/c++17/fs_path.cc (path::replace_extension): Erase extension from
final component as well as from _M_pathname. Append the dot using
operator+= instead of only to _M_pathname.
(path::_M_find_extension): Reformat slightly.
* testsuite/27_io/filesystem/path/modifiers/replace_extension.cc:
Add more test cases.

From-SVN: r268406
libstdc++-v3/ChangeLog
libstdc++-v3/src/c++17/fs_path.cc
libstdc++-v3/testsuite/27_io/filesystem/path/modifiers/replace_extension.cc