https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71500
--- Comment #7 from Michael Duggan <mwd at md5i dot com> --- "timshen at gcc dot gnu.org" <gcc-bugzi...@gcc.gnu.org> writes: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71500 > > --- Comment #6 from Tim Shen <timshen at gcc dot gnu.org> --- > (In reply to mwd from comment #5) >> All of the ECMAScript engines I have found work with this , and the >> ECMAScript specs seem to imply that this should work as well. > > I think you are right. > > According to ECMAScript 262 6th edition [21.2.2.8.1]: > 5. If invert is false, then > a. If there does not exist a member a of set A such that Canonicalize(a) > is > cc, return failure. > > , when creating the CharSet A, ignorecase is not taken into consideration at > all; rather, when matching a character against a range, both the character and > the candidate from the range is "Canonialized" and compared. > > Ideally I would implement this as (which is similar to your suggestion): > auto toggle_case(auto c) { > if (isupper(c)) return tolower(c); > if (islower(c)) return toupper(c); > return c; > } > > if (range.first <= c && c < range.second) { ... } > else if (icase && (range.first <= toggle_case(c) && toggle_case(c) < > range.second)) { ... } > > The problem is I'm not sure how to implement this, since: > When collate is off, locale related function like tolower and toupper should > not be called; when collate is on, everything should go through > regex_traits::transform, which doesn't care about icase. Hmm... Okay. For the sake of argument, I am going to make the following claims: a) Ignoring case _requires_ a locale. Without a locale, how do you determine the case of a character anyway? Especially if the character is not a char? Even std::toupper and std::towuppwer are bound to the "C" locale. As such, you can't say you're not to use the locale when collate is off. Otherwise icase wouldn't work ever unless collate was specified. b) You can still use regex_traits::transform in an icase scenario. The rule for [A-B], matching X should be: transform(a) <= transform(x) <= transform(b) In the icase scenario, I would posit that the result of this _or_ transform(a) <= transform(toggle_case(x)) <= transform(b) is correct. I don't mind if these claims are refuted, but I think I'd need the refutation explained to me.