svn commit: r225347 - user/gabor/tre-integration/contrib/tre/lib

Gabor Kovesdan gabor at FreeBSD.org
Fri Sep 2 20:34:22 UTC 2011


On 2011.09.02. 20:48, Andrey Chernov wrote:
> On Fri, Sep 02, 2011 at 06:18:24PM +0000, Gabor Kovesdan wrote:
>>           {								\
>>             char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i])	\
>>               : tolower(fg->pattern[i]);					\
>> -          fg->qsBc[(unsigned)c] = fg->len - i;				\
>> +          fg->qsBc[(unsigned char)c] = fg->len - i;			\
>
> It looks like there should be
>
> char c = islower((unsigned char)fg->pattern[i]) ? \
> toupper((unsigned char)fg->pattern[i]) : \
> tolower((unsigned char)fg->pattern[i]); \
>
> I don't see whole code, it depends on what type fg->pattern[i] have.
It's a char.
>
> Due to their bad design ctype macros can't be called directly on signed
> (i.e. default) char type, unless its value is known to be 7bit.
Yes, thanks, a cast is missing here, too.
> BTW, I don't understand the intention of that expression.
> You turn lower to upper and upper to lower. Ignore case mode converts all
> to single case instead.
It's about the quick search algorithm. Instead of converting 
_everything_ to single case I store shift values for both cases in the 
pattern compilation phase, which is executed only once and then the 
match phase, which may be executed several times, needs to perform much 
less operations and only convert a few characters.

Gabor


More information about the svn-src-user mailing list