Re: [PATCH] t4062: stop using repetition in regex
- From
René Scharfe <l.s.r@web.de>
- Date
- Aug 10, 2017, 06:08 UTC
- Message-ID
- <faa74d6d-90b5-2de1-6478-854d3d52d30e@web.de>
- In-Reply-To
- <xmqqwp6c63bm.fsf@gitster.mtv.corp.google.com>
Am 09.08.2017 um 19:47 schrieb Junio C Hamano:
Show 21 quoted lines
> René Scharfe <l.s.r@web.de> writes:
>
>> There could be any characters except NUL and LF between the 4096 zeros
>> and "0$" for the latter to match wrongly, no? So there are 4095
>> opportunities for the misleading pattern in a page, with probabilities
>> like this:
>>
>> 0$ 1/256 * 2/256
>> .0$ 254/256 * 1/256 * 2/256
>> ..0$ (254/256)^2 * 1/256 * 2/256
>> .{3}0$ (254/256)^3 * 1/256 * 2/256
>>
>> .{4094}0$ (254/256)^4094 * 1/256 * 2/256
>>
>> That sums up to ca. 1/256 (did that numerically). Does that make
>> sense?
>
> Yes, thanks. I think the number would be different for "^0*$" (the
> above is for "0$") and moves it down to ~1/30000, but as I said,
> allowing additional false success rate is unnecessary (even if it is
> miniscule enough to be acceptable), so let's take the 64*64 patch.Ah, right, now I get your calculation in the email I replied to above. "^0*$" has a probability of 2/255 to produce false positives.
Thanks, René