You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Danny Trebbien <dt...@gmail.com> on 2010/12/20 00:22:35 UTC
Re: [PATCH] extend svn_subst_translate_string() to record whether
re-encoding and/or line ending translation were performed (v. 5.2)
Branko Čibej <brane <at> xbc.nu> writes:
> > 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))
>
Ack! I didn't see your message until now. Yes, you are right.
Attached is version 5.2 of the patch.
Re: [PATCH] extend svn_subst_translate_string() to record whether
re-encoding and/or line ending translation were performed (v. 5.2)
Posted by Julian Foad <ju...@wandisco.com>.
Danny Trebbien wrote:
> >> Hi Danny. Please could you enhance your tests so that they can detect
> >> this error (so that they will fail if this error is present).
> >
> > Sometimes I should use more words.
> >
> > What I meant to say is: I'm trying to devote as much of my time as
> > possible to other things (WC-NG specifically) so if you could help me
> > out as much as possible with reducing the review effort needed, I'd
> > really appreciate it. I assume your test didn't pick up this error
> > already, and I can't see at a glance whether you have extended the test
> > so that it does. If you do that, then that'll save me (and anyone now
> > and forever) from having to scrutinize the code to see whether it
> > handles this properly. That precisely what a regression test is for.
> >
> > So if you already extended it, apologies as I haven't tried it or
> > examined it, as I wanted to ask you first.
> >
> > Also please include the log message each time you attach a patch.
> > Please could you re-post the patch and log message together even if no
> > further changes are needed.
> >
> > Thanks,
> > - Julian
>
> Hi Julian,
>
> I have already looked into adding a regression test for this, but it
> is not possible even after applying the patch. The only way that the
> problem would manifest is if one of the other svn_subst_translate*
> functions that allow EOL_STR to be specified were also extended to
> accept a TRANSLATED_LINE_ENDINGS parameter. For example, if
> svn_subst_translate_cstring2() were extended in this manner, "\r" was
> used as the EOL string, and the value to be translated included only
> Windows-style line endings, then the problem would occur. With this
> patch, only svn_subst_translate_string() is extended, and
> svn_subst_translate_string() always uses "\n" for EOL_STR.
Oh, OK. Thanks for explaining.
> Attached is the patch and log message.
I'll get to this soon - hopefully today or tomorrow.
- Julian
Re: [PATCH] extend svn_subst_translate_string() to record whether
re-encoding and/or line ending translation were performed (v. 5.2)
Posted by Julian Foad <ju...@wandisco.com>.
Danny Trebbien wrote:
> That's much better than mine, and I have verified that the tests are
> the same. Please commit.
Thanks very much. Committed revision 1051864.
- Julian
Re: [PATCH] extend svn_subst_translate_string() to record whether
re-encoding and/or line ending translation were performed (v. 5.2)
Posted by Danny Trebbien <dt...@gmail.com>.
On Mon, Dec 20, 2010 at 4:11 PM, Julian Foad <ju...@wandisco.com> wrote:
> On Mon, 2010-12-20, Danny Trebbien wrote:
>> [[[
>> Add a public API function, svn_subst_translate_string2(), an extension of
>> svn_subst_translate_string(), that has two additional output parameters for
>> determining whether re-encoding and/or line ending translation were performed.
> [...]
>
> Thanks, Danny.
>
> Committed revision 1051322.
:)
> The main patch looks great. In the test file, I made the minimum
> changes necessary to comply with the C'89 language (no // comments, no
> declarations after code), and committed it. However I suggest many
> further changes to the test code, mainly making it data-driven (use a
> table of inputs and expected outputs) and use helpers such as
> SVN_TEST_STRING_ASSERT() to maximize readability. To this end, I
> suggest the version attached here. Do you want to check this for me, to
> see if it still does what you wanted it to, and let me know if I should
> commit it.
Hi Julian,
That's much better than mine, and I have verified that the tests are
the same. Please commit.
Re: [PATCH] extend svn_subst_translate_string() to record whether
re-encoding and/or line ending translation were performed (v. 5.2)
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Julian Foad wrote on Tue, Dec 21, 2010 at 00:11:01 +0000:
> Committed revision 1051322.
Nice :-).
Re: [PATCH] extend svn_subst_translate_string() to record whether
re-encoding and/or line ending translation were performed (v. 5.2)
Posted by Julian Foad <ju...@wandisco.com>.
On Mon, 2010-12-20, Danny Trebbien wrote:
> [[[
> Add a public API function, svn_subst_translate_string2(), an extension of
> svn_subst_translate_string(), that has two additional output parameters for
> determining whether re-encoding and/or line ending translation were performed.
[...]
Thanks, Danny.
Committed revision 1051322.
The main patch looks great. In the test file, I made the minimum
changes necessary to comply with the C'89 language (no // comments, no
declarations after code), and committed it. However I suggest many
further changes to the test code, mainly making it data-driven (use a
table of inputs and expected outputs) and use helpers such as
SVN_TEST_STRING_ASSERT() to maximize readability. To this end, I
suggest the version attached here. Do you want to check this for me, to
see if it still does what you wanted it to, and let me know if I should
commit it.
Thanks again.
- Julian
Re: [PATCH] extend svn_subst_translate_string() to record whether
re-encoding and/or line ending translation were performed (v. 5.2)
Posted by Danny Trebbien <dt...@gmail.com>.
>> Hi Danny. Please could you enhance your tests so that they can detect
>> this error (so that they will fail if this error is present).
>
> Sometimes I should use more words.
>
> What I meant to say is: I'm trying to devote as much of my time as
> possible to other things (WC-NG specifically) so if you could help me
> out as much as possible with reducing the review effort needed, I'd
> really appreciate it. I assume your test didn't pick up this error
> already, and I can't see at a glance whether you have extended the test
> so that it does. If you do that, then that'll save me (and anyone now
> and forever) from having to scrutinize the code to see whether it
> handles this properly. That precisely what a regression test is for.
>
> So if you already extended it, apologies as I haven't tried it or
> examined it, as I wanted to ask you first.
>
> Also please include the log message each time you attach a patch.
> Please could you re-post the patch and log message together even if no
> further changes are needed.
>
> Thanks,
> - Julian
Hi Julian,
I have already looked into adding a regression test for this, but it
is not possible even after applying the patch. The only way that the
problem would manifest is if one of the other svn_subst_translate*
functions that allow EOL_STR to be specified were also extended to
accept a TRANSLATED_LINE_ENDINGS parameter. For example, if
svn_subst_translate_cstring2() were extended in this manner, "\r" was
used as the EOL string, and the value to be translated included only
Windows-style line endings, then the problem would occur. With this
patch, only svn_subst_translate_string() is extended, and
svn_subst_translate_string() always uses "\n" for EOL_STR.
Attached is the patch and log message.
Re: [PATCH] extend svn_subst_translate_string() to record whether
re-encoding and/or line ending translation were performed (v. 5.2)
Posted by Julian Foad <ju...@wandisco.com>.
On Mon, 2010-12-20 at 10:11 +0000, Julian Foad wrote:
> On Sun, 2010-12-19 at 16:22 -0800, Danny Trebbien wrote:
> > Branko Čibej <brane <at> xbc.nu> writes:
> > > > 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))
> > >
> >
> > Ack! I didn't see your message until now. Yes, you are right.
>
> Hi Danny. Please could you enhance your tests so that they can detect
> this error (so that they will fail if this error is present).
Sometimes I should use more words.
What I meant to say is: I'm trying to devote as much of my time as
possible to other things (WC-NG specifically) so if you could help me
out as much as possible with reducing the review effort needed, I'd
really appreciate it. I assume your test didn't pick up this error
already, and I can't see at a glance whether you have extended the test
so that it does. If you do that, then that'll save me (and anyone now
and forever) from having to scrutinize the code to see whether it
handles this properly. That precisely what a regression test is for.
So if you already extended it, apologies as I haven't tried it or
examined it, as I wanted to ask you first.
Also please include the log message each time you attach a patch.
Please could you re-post the patch and log message together even if no
further changes are needed.
Thanks,
- Julian
Re: [PATCH] extend svn_subst_translate_string() to record whether
re-encoding and/or line ending translation were performed (v. 5.2)
Posted by Julian Foad <ju...@wandisco.com>.
On Sun, 2010-12-19 at 16:22 -0800, Danny Trebbien wrote:
> Branko Čibej <brane <at> xbc.nu> writes:
> > > 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))
> >
>
> Ack! I didn't see your message until now. Yes, you are right.
Hi Danny. Please could you enhance your tests so that they can detect
this error (so that they will fail if this error is present).
Thanks.
- Julian
> Attached is version 5.2 of the patch.