]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR libstdc++/89117 fix path::replace_extension("") case
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Jan 2019 23:18:22 +0000 (23:18 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Jan 2019 23:18:22 +0000 (23:18 +0000)
commite7b22e58a849477c3b70c3082a48e4e8c3682d36
treeadddb8ab176cad6dcdff325584717707152c33ed
parente87c2412f4154018b078048692968a00211f4ae1
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268406 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/src/c++17/fs_path.cc
libstdc++-v3/testsuite/27_io/filesystem/path/modifiers/replace_extension.cc