Checkout
Julian Foad
committed
on 21 Dec 10
Add a public API function, svn_subst_translate_string2(), an extension of
svn_subst_translate_string(), that has two additional output param… Show more
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.

As discussed at:

 <http://thread.gmane.org/gmane.comp.version-control.subversion.devel/122550>

 <http://thread.gmane.org/gmane.comp.version-control.subversion.devel/123020>

The essential changes are to the translate_newline() function, which now takes

an svn_boolean_t pointer, the value at which is set to TRUE if the pointer is

non-NULL and a different newline is written out. Most other changes are to pass

the svn_boolean_t pointer through to translate_newline().

* build.conf

 Configure subversion/tests/libsvn_subr/subst_translate-test

* subversion/include/svn_subst.h

 (svn_subst_translate_string2): New function.

 (svn_subst_translate_string): Deprecate in favor of

   svn_subst_translate_string2().

* subversion/libsvn_subr/subst.c

 (STRING_IS_EOL): New macro that tests whether a string is an end-of-line

   string ("\n", "\r", "\r\n").

 (DIFFERENT_EOL_STRINGS): New macro that tests whether two end-of-line strings

   are different.

 (translate_newline): Add the TRANSLATED_EOL parameter. If the function

   writes out a different newline, then it sets TRANSLATED_EOL to TRUE.

 (translation_baton): Add the TRANSLATED_EOL field.

 (create_translation_baton): Add a new parameter TRANSLATED_EOL that is

   passed to the resulting translation_baton.

 (translate_chunk): When calling translate_newline(), pass TRANSLATED_EOL from

   the translation_baton.

 (stream_translated): New static function. Its implementation is the old

   implementation of svn_subst_stream_translated(), but accepting another

   parameter, TRANSLATED_EOL, that is passed to the in/out translation batons

   that it creates.

 (svn_subst_stream_translated): Now a wrapper for stream_translated().

 (translate_cstring): New static function. Its implementation is the old

   implementation of svn_subst_translate_cstring2(), but modified to accept

   another parameter, TRANSLATED_EOL, that is passed to stream_translated().

 (svn_subst_translate_cstring2): Now a wrapper for translate_cstring().

 (svn_subst_translate_string): Move to deprecated.c.

 (svn_subst_translate_string2): New function. It takes three additional

   parameters: TRANSLATED_TO_UTF8, TRANSLATED_LINE_ENDINGS, and another pool

   parameter. The task of recording whether it translates a line ending is

   delegated to translate_cstring().

* subversion/libsvn_subr/deprecated.c

 (svn_subst_translate_string): Now a wrapper for svn_subst_translate_string2().

* subversion/tests/libsvn_subr/subst_translate-test.c

 New test suite for the svn_subst_translate_* functions.

Patch by: Danny Trebbien <dtrebbien{_AT_}gmail.com>

Show less