[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] extend svn_subst_translate_string() to record whether re-encoding and/or line ending translation were performed (v. 5)

From: Branko ─îibej <brane_at_xbc.nu>
Date: Mon, 13 Dec 2010 15:12:00 +0100

On 13.12.2010 12:38, Julian Foad wrote:
> On Fri, 2010-12-10, Danny Trebbien wrote:
> Hi Daniel.
>
> I haven't looked at your patch v5 yet, because this Git diff doesn't
> look quite right. How will this memcmp expression work properly if the
> two strings being compared are different lengths?
>> - if (translated_eol != NULL && DIFFERENT_EOL_STRINGS(eol_str, eol_str_len,
>> - newline_buf, newline_len))
>> + if (translated_eol != NULL &&
>> + memcmp(eol_str,
>> + newline_buf,
>> + eol_str_len < newline_len ? eol_str_len : newline_len) != 0)

Not very well, because it's prefix matching that doesn't actually take
different string lengths into account and you can get false matches.
e.g., if eol_str == '\r' (ancient mac mode) and newline_bug == '\r\n'
... what you want is more like:

    if (translated_eol != NULL &&
        (eol_str_len != newline_len ||
         memcmp(eol_str, newline_buff, eol_str_len) != 0))

-- Brane
Received on 2010-12-13 15:12:45 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.