Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 02 Sep 2011 22:34:12 +0200
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Andrey Chernov <ache@freebsd.org>, src-committers@FreeBSD.ORG,  svn-src-user@FreeBSD.ORG
Subject:   Re: svn commit: r225347 - user/gabor/tre-integration/contrib/tre/lib
Message-ID:  <4E613DC4.9010809@FreeBSD.org>
In-Reply-To: <20110902184842.GA28351@vniz.net>
References:  <201109021818.p82IIO73010722@svn.freebsd.org> <20110902184842.GA28351@vniz.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E613DC4.9010809>