mirror of git://gcc.gnu.org/git/gcc.git
Fix concatenation bug in filesystem::path
When erasing a trailing empty filename component, the output iterator was not decremented, causing the next component to be created at the wrong position. * src/filesystem/std-path.cc (path::operator+=(const path&)): Fix incorrect treatment of empty filename after trailing slash. * testsuite/27_io/filesystem/path/concat/path.cc: Test problem case. From-SVN: r267574
This commit is contained in:
parent
5db78cac10
commit
b30802179a
|
|
@ -1,5 +1,9 @@
|
||||||
2019-01-04 Jonathan Wakely <jwakely@redhat.com>
|
2019-01-04 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
* src/filesystem/std-path.cc (path::operator+=(const path&)): Fix
|
||||||
|
incorrect treatment of empty filename after trailing slash.
|
||||||
|
* testsuite/27_io/filesystem/path/concat/path.cc: Test problem case.
|
||||||
|
|
||||||
* testsuite/21_strings/basic_string/modifiers/assign/char/
|
* testsuite/21_strings/basic_string/modifiers/assign/char/
|
||||||
move_assign_optim.cc: Avoid spurious failure when -fno-inline added
|
move_assign_optim.cc: Avoid spurious failure when -fno-inline added
|
||||||
to test flags.
|
to test flags.
|
||||||
|
|
|
||||||
|
|
@ -945,7 +945,7 @@ path::operator+=(const path& p)
|
||||||
else if (orig_filenamelen == 0 && it != last)
|
else if (orig_filenamelen == 0 && it != last)
|
||||||
{
|
{
|
||||||
// Remove empty filename at end of original path.
|
// Remove empty filename at end of original path.
|
||||||
_M_cmpts.erase(std::prev(output));
|
_M_cmpts.erase(--output);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it != last && it->_M_type() == _Type::_Root_name)
|
if (it != last && it->_M_type() == _Type::_Root_name)
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,18 @@ test02()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test03()
|
||||||
|
{
|
||||||
|
path p = "a/";
|
||||||
|
p += path("/b");
|
||||||
|
compare_paths(p, "a//b");
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
test02();
|
test02();
|
||||||
|
test03();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue