Subject: [Boost-bugs] [Boost C++ Libraries] #10131: [string_algo] trim_all_*() functions leaves a single asterisk in the string.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-06-18 09:44:49
#10131: [string_algo] trim_all_*() functions leaves a single asterisk in the
string.
------------------------------+-------------------------
Reporter: wburkhardt@⦠| Owner: marshall
Type: Bugs | Status: new
Milestone: To Be Determined | Component: string_algo
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
------------------------------+-------------------------
I came along this problem while I wanted to reformat a string, to form a
proper filename/path. Using string_algo's boost::trim_all* variants, I
came across the problem when the originating string contained asterisk
characters. The trim function would *always* leave at least one asterisk
in the resulting string.
Example source string:
{{{"TEST_**???***_TEST"}}}
Desired result is:
{{{"TEST__TEST"}}}
Using trim_all_*()
{{{
result = trim_all_copy_if(source_string, is_any_of("\\/:*?\"<>|"));
}}}
result:
{{{
"TEST_*_TEST"
}}}
escaping the asterisk in the predicate did not help:
{{{
result = trim_all_copy_if(source_string, is_any_of("\\/:\\*?\"<>|"));
}}}
same result:
{{{
"TEST_*_TEST"
}}}
However when using a trim_fill_*() variant with an empty replacement
string:
{{{
result = trim_fill_copy_if(test_sequence, "", is_any_of("\\/:*?\"<>|"));
}}}
It did deliver the desired result:
{{{
"TEST__TEST"
}}}
This unexpected behavior of trim_all_*() is IMHO a bug. If not, it should
probably be added to the documentation.
example code attached.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10131> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC