Boost C++ Libraries: Ticket #698: The case insensitive modifier doesn't work when followed by a character class https://svn.boost.org/trac10/ticket/698 <pre class="wiki">My name is Florin Trofin (ftrofin at _adobe_ dot com) and I work for Adobe Systems. We are using boost/regex 1.33.1 in one of our projects and we've encountered the following bug: The case insensitive modifier is supposed to make the string comparison case insensitive from the place at which it is encountered first till the end. In view of this, if we have "ABC abc aCb" as the text in which we will be doing search and if we have find string as "(?i)[bc]" then the expectation is that b/B/c/C will be found. But only b/c is found. If we have "(?i)a[bc]" as find string then ab/ac/AB/Ab/AC/Ac are found as expected. The only place which is having problem is when we specify character class[] immediately after case insensitive modifier "(?i)". We also have issues regarding character equivalence on Mac. Japanese character equivalence in general is not working i.e. if we have [[=x=]] where x is a Japanese character in hiragana or katakana then the equivalence is not matching correctly. Please let me know if you want me to open a separate bug on this issue. If you need more info please let me know. Thx! </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/698 Trac 1.4.3 John Maddock Tue, 01 Aug 2006 09:37:52 GMT <link>https://svn.boost.org/trac10/ticket/698#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/698#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=14804 I can't reproduce this, the test program I'm using is below, can you check and see if this reproduces the issue for you? BTW I'm testing with the latest Boost-cvs, but the only patches I'm aware of making are to non-greedy repeats which shouldn't have any effect here. Re equivalence classes: there is no portable way to make this work unfortunately, it requires that the regex engine is able to decode the collation string produced by the locale to extract the primary equivalence class. The "kind" of sort key used by the platform is determined in a fairly heuristic way in find_sort_syntax() in boost/regex/v4/primary_transform.hpp, and the actually sort key is produced in cpp_regex_traits::primary_transform(). You may - with a bit of debugging - be able to find out what's going wrong (I don't have access to a mac BTW). The most important thing would be to find out what kind of sort keys are returned by std::collate&lt;&gt;::transform. Test program follows, John Maddock. #include &lt;boost/regex.hpp&gt; #include &lt;iostream&gt; int main(int,char**) { boost::regex e("(?i)[bc]"); std::string s("ABC abc aCb"); boost::sregex_iterator i(s.begin(), s.end(), e), j; while(i != j) { std::cout &lt;&lt; *i &lt;&lt; std::endl; ++i; } } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>sf-robot</dc:creator> <pubDate>Wed, 16 Aug 2006 02:20:23 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/698#comment:2 https://svn.boost.org/trac10/ticket/698#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=1312539 This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker). </pre> Ticket Stephen Wassell <stephen.wassell@…> Thu, 25 Aug 2011 10:37:47 GMT severity set https://svn.boost.org/trac10/ticket/698#comment:3 https://svn.boost.org/trac10/ticket/698#comment:3 <ul> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> <p> This bug still exists as described in the original post. I've tested with Boost 1.45 but I believe it's still there in 1.47. </p> <p> The regular expression "(?i)[dh]og" should match on both "HOG" and "dog" but in fact only matches on "dog". Please see the attached sample code boostbug698.cpp. </p> <p> I've fixed the bug as follows: at boost/regex/v4/basic_regex_creator.hpp line 1216 change m_icase to l_icase. </p> <pre class="wiki">&lt; if(&amp;c != re_is_set_member(&amp;c, &amp;c + 1, static_cast&lt;re_set_long&lt;mask_type&gt;*&gt;(state), *m_pdata, m_icase)) &gt; if(&amp;c != re_is_set_member(&amp;c, &amp;c + 1, static_cast&lt;re_set_long&lt;mask_type&gt;*&gt;(state), *m_pdata, l_icase)) </pre> Ticket Stephen Wassell <stephen.wassell@…> Thu, 25 Aug 2011 10:39:06 GMT attachment set https://svn.boost.org/trac10/ticket/698 https://svn.boost.org/trac10/ticket/698 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boostbug698.cpp</span> </li> </ul> <p> Sample code demonstrating this bug (compiles with MSVC9) </p> Ticket Stephen Wassell <stephen.wassell@…> Thu, 25 Aug 2011 10:40:47 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/698#comment:4 https://svn.boost.org/trac10/ticket/698#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">None</span> </li> </ul> Ticket Stephen Wassell <stephen.wassell@…> Thu, 25 Aug 2011 10:41:54 GMT version, summary changed https://svn.boost.org/trac10/ticket/698#comment:5 https://svn.boost.org/trac10/ticket/698#comment:5 <ul> <li><strong>version</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">Boost 1.45.0</span> </li> <li><strong>summary</strong> <span class="trac-field-old">The case insensitive modifier doesn't work</span> → <span class="trac-field-new">The case insensitive modifier doesn't work when followed by a character class</span> </li> </ul> Ticket John Maddock Mon, 10 Oct 2011 16:42:41 GMT description changed https://svn.boost.org/trac10/ticket/698#comment:6 https://svn.boost.org/trac10/ticket/698#comment:6 <ul> <li><strong>description</strong> modified (<a href="/trac10/ticket/698?action=diff&amp;version=6">diff</a>) </li> </ul> <p> Confirmed. </p> Ticket John Maddock Mon, 10 Oct 2011 16:55:29 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/698#comment:7 https://svn.boost.org/trac10/ticket/698#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/74898" title="Fix case change bug. Fixes #698.">[74898]</a>) Fix case change bug. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/698" title="#698: Bugs: The case insensitive modifier doesn't work when followed by a ... (closed: fixed)">#698</a>. </p> Ticket