[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bug: long strings with REALLY long delimiters…
- From: dyngeccetor8 <dyngeccetor8@...>
- Date: Fri, 14 Dec 2018 21:38:12 +0300
On 12/14/18 7:32 PM, Roberto Ierusalimschy wrote:
>> Finding longest "=" sequence is arguably simplest and not optimal. I prefer
>> finding shortest long closing quote: min(N): ("]" "=" ^ N "]") not in string.
>>
>> This algorithm have no worst cases.
>>
>> Sample implementation at
>> https://github.com/martin-eden/workshop/blob/master/formats/lua/quote_string/intact.lua#L16
>
> It doesn't seem to work for "]]a]=". (Result is "[=[]]a]=]=]"...)
>
> -- Roberto
Thank you for pointing at this case!
I fixed algorithm by concatenating "]" to source string before determining
variable number of "=" required.
So now "]]a]=" transformed to "]]a]=]" and ("[==[", "]==]") are used as proper
quotes.
Sadly, link now points to current version. Link to original (bugged) version is
https://github.com/martin-eden/workshop/blob/39322444d84e7d93c6f73e563a4e78989a85f195/formats/lua/quote_string/intact.lua
-- Martin