Re: [PATCH] wildmatch: properly fold case everywhere
On Thu, May 30, 2013 at 3:45 PM, Anthony Ramine n.ox...@gmail.com wrote: Case folding is not done correctly when matching against the [:upper:] character class and uppercased character ranges (e.g. A-Z). Specifically, an uppercase letter fails to match against any of them when case folding is requested because plain characters in the pattern and the whole string and preemptively lowercased to handle the base case fast. That optimization is kept and ISLOWER() is used in the [:upper:] case when case folding is requested, while matching against a character range is retried with toupper() if the character was lowercase, as the bounds of the range itself cannot be modified (in a case-insensitive context, [A-_] is not equivalent to [a-_]). Signed-off-by: Anthony Ramine n.ox...@gmail.com Reviewed-by: Duy Nguyen pclo...@gmail.com If you have time, you may want to send a similar patch to rsync, which contains original wildmatch implementation. It does not look much different from this one, except that (flags WM_CASEFOLD) is replaced with force_lower_case. Thanks. -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] wildmatch: properly fold case everywhere
On Thu, May 30, 2013 at 5:29 AM, Anthony Ramine n.ox...@gmail.com wrote: Yes indeed. Will amend. Should I add your name in Reviewed-by as well? No. I merely spotted a minor typographical error. -- Anthony Ramine Le 30 mai 2013 à 11:07, Eric Sunshine a écrit : On Thu, May 30, 2013 at 4:45 AM, Anthony Ramine n.ox...@gmail.com wrote: Case folding is not done correctly when matching against the [:upper:] character class and uppercased character ranges (e.g. A-Z). Specifically, an uppercase letter fails to match against any of them when case folding is requested because plain characters in the pattern and the whole string and preemptively lowercased to handle the base case Did you mean s/and preemptively/are preemptively/ ? fast. That optimization is kept and ISLOWER() is used in the [:upper:] case when case folding is requested, while matching against a character range is retried with toupper() if the character was lowercase, as the bounds of the range itself cannot be modified (in a case-insensitive context, [A-_] is not equivalent to [a-_]). Signed-off-by: Anthony Ramine n.ox...@gmail.com -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] wildmatch: properly fold case everywhere
You're right, I will amend my patch. How do I make git-send-email reply to that thread? -- Anthony Ramine Le 28 mai 2013 à 14:53, Duy Nguyen a écrit : On Tue, May 28, 2013 at 7:32 PM, Anthony Ramine n.ox...@gmail.com wrote: @@ -196,6 +196,11 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags) } if (t_ch = p_ch t_ch = prev_ch) matched = 1; + else if ((flags WM_CASEFOLD) ISLOWER(t_ch)) { + t_ch = toupper(t_ch); This happens in a while loop where t_ch may be used again. Should we make a local copy of toupper(t_ch) and leave t_ch untouched? + if (t_ch = p_ch t_ch = prev_ch) + matched = 1; + } p_ch = 0; /* This makes prev_ch get set to 0. */ } else if (p_ch == '[' p[1] == ':') { const uchar *s; -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html