You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2011/01/25 16:34:40 UTC
svn commit: r1063320 - in /subversion/trunk/subversion: include/svn_subst.h
libsvn_subr/deprecated.c libsvn_subr/subst.c svn/lock-cmd.c
svn/propset-cmd.c svn/util.c svnadmin/main.c
tests/libsvn_subr/subst_translate-test.c
Author: julianfoad
Date: Tue Jan 25 15:34:40 2011
New Revision: 1063320
URL: http://svn.apache.org/viewvc?rev=1063320&view=rev
Log:
Extend svn_subst_translate_string2() with another parameter, REPAIR, to allow
the caller to customize whether line ending repairs are performed.
As discussed at:
http://thread.gmane.org/gmane.comp.version-control.subversion.devel/125050
* subversion/include/svn_subst.h
(svn_subst_translate_string2): Add a REPAIR parameter. Update the
documentation of the function.
* subversion/libsvn_subr/subst.c
(svn_subst_translate_string2): Add a REPAIR parameter. Pass the value through
to translate_cstring().
* subversion/libsvn_subr/deprecated.c
(svn_subst_translate_string): Call svn_subst_translate_string2() with REPAIR
set to FALSE.
* subversion/svn/util.c
(svn_cl__edit_string_externally, svn_cl__get_log_message): Call
svn_subst_translate_string2() with REPAIR set to FALSE.
* subversion/svn/propset-cmd.c
(svn_cl__propset): Call svn_subst_translate_string2() with REPAIR set to
FALSE.
* subversion/svn/lock-cmd.c
(get_comment): Call svn_subst_translate_string2() with REPAIR set to FALSE.
* subversion/svnadmin/main.c
(set_revprop): Call svn_subst_translate_string2() with REPAIR set to FALSE.
* subversion/tests/libsvn_subr/subst_translate-test.c
(test_svn_subst_translate_string2): Call svn_subst_translate_string2() with
REPAIR set to FALSE. Also test that inconsistent line endings result in
SVN_ERR_IO_INCONSISTENT_EOL when REPAIR is FALSE.
(test_repairing_svn_subst_translate_string2): New test case that tests a
repairing translation.
(test_funcs): Add test_repairing_svn_subst_translate_string2.
Patch by: Danny Trebbien <dtrebbien{_AT_}gmail.com>
Modified:
subversion/trunk/subversion/include/svn_subst.h
subversion/trunk/subversion/libsvn_subr/deprecated.c
subversion/trunk/subversion/libsvn_subr/subst.c
subversion/trunk/subversion/svn/lock-cmd.c
subversion/trunk/subversion/svn/propset-cmd.c
subversion/trunk/subversion/svn/util.c
subversion/trunk/subversion/svnadmin/main.c
subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c
Modified: subversion/trunk/subversion/include/svn_subst.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_subst.h?rev=1063320&r1=1063319&r2=1063320&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_subst.h (original)
+++ subversion/trunk/subversion/include/svn_subst.h Tue Jan 25 15:34:40 2011
@@ -615,8 +615,10 @@ svn_error_t *svn_subst_translate_string(
* *translated_line_endings to @c TRUE if at least one line ending was
* changed to LF, or to @c FALSE otherwise.
*
- * Recognized line endings are LF, CR, CRLF. If @a value has inconsistent
- * line endings, return @c SVN_ERR_IO_INCONSISTENT_EOL.
+ * If @a value has an inconsistent line ending style, then: if @a repair
+ * is @c FALSE, return @c SVN_ERR_IO_INCONSISTENT_EOL, else if @a repair is
+ * @c TRUE, convert any line ending in @a value to "\n" in
+ * @a *new_value. Recognized line endings are: "\n", "\r", and "\r\n".
*
* Set @a *new_value to the translated string, allocated in @a result_pool.
*
@@ -630,6 +632,7 @@ svn_subst_translate_string2(svn_string_t
svn_boolean_t *translated_line_endings,
const svn_string_t *value,
const char *encoding,
+ svn_boolean_t repair,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
Modified: subversion/trunk/subversion/libsvn_subr/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/deprecated.c?rev=1063320&r1=1063319&r2=1063320&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_subr/deprecated.c Tue Jan 25 15:34:40 2011
@@ -256,7 +256,7 @@ svn_subst_translate_string(svn_string_t
apr_pool_t *pool)
{
return svn_subst_translate_string2(new_value, NULL, NULL, value,
- encoding, pool, pool);
+ encoding, FALSE, pool, pool);
}
svn_error_t *
Modified: subversion/trunk/subversion/libsvn_subr/subst.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/subst.c?rev=1063320&r1=1063319&r2=1063320&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/subst.c (original)
+++ subversion/trunk/subversion/libsvn_subr/subst.c Tue Jan 25 15:34:40 2011
@@ -1863,6 +1863,7 @@ svn_subst_translate_string2(svn_string_t
svn_boolean_t *translated_line_endings,
const svn_string_t *value,
const char *encoding,
+ svn_boolean_t repair,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
@@ -1892,7 +1893,7 @@ svn_subst_translate_string2(svn_string_t
translated_line_endings,
val_utf8,
"\n", /* translate to LF */
- FALSE, /* no repair */
+ repair,
NULL, /* no keywords */
FALSE, /* no expansion */
scratch_pool));
Modified: subversion/trunk/subversion/svn/lock-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/lock-cmd.c?rev=1063320&r1=1063319&r2=1063320&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/lock-cmd.c (original)
+++ subversion/trunk/subversion/svn/lock-cmd.c Tue Jan 25 15:34:40 2011
@@ -74,7 +74,7 @@ get_comment(const char **comment, svn_cl
/* Translate to UTF8/LF. */
SVN_ERR(svn_subst_translate_string2(&comment_string, NULL, NULL,
comment_string, opt_state->encoding,
- pool, pool));
+ FALSE, pool, pool));
*comment = comment_string->data;
return SVN_NO_ERROR;
Modified: subversion/trunk/subversion/svn/propset-cmd.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/propset-cmd.c?rev=1063320&r1=1063319&r2=1063320&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/propset-cmd.c (original)
+++ subversion/trunk/subversion/svn/propset-cmd.c Tue Jan 25 15:34:40 2011
@@ -86,8 +86,8 @@ svn_cl__propset(apr_getopt_t *os,
and LF line endings. All other propvals are taken literally. */
if (svn_prop_needs_translation(pname_utf8))
SVN_ERR(svn_subst_translate_string2(&propval, NULL, NULL, propval,
- opt_state->encoding, scratch_pool,
- scratch_pool));
+ opt_state->encoding, FALSE,
+ scratch_pool, scratch_pool));
else if (opt_state->encoding)
return svn_error_create
(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
Modified: subversion/trunk/subversion/svn/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/util.c?rev=1063320&r1=1063319&r2=1063320&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/util.c (original)
+++ subversion/trunk/subversion/svn/util.c Tue Jan 25 15:34:40 2011
@@ -485,8 +485,8 @@ svn_cl__edit_string_externally(svn_strin
if (as_text)
{
err = svn_subst_translate_string2(edited_contents, FALSE, FALSE,
- *edited_contents, encoding, pool,
- pool);
+ *edited_contents, encoding, FALSE,
+ pool, pool);
if (err)
{
err = svn_error_quick_wrap
@@ -713,7 +713,7 @@ svn_cl__get_log_message(const char **log
log_msg_str->len = log_msg_buf->len;
SVN_ERR_W(svn_subst_translate_string2(&log_msg_str, FALSE, FALSE,
log_msg_str, lmb->message_encoding,
- pool, pool),
+ FALSE, pool, pool),
_("Error normalizing log message to internal format"));
*log_msg = log_msg_str->data;
Modified: subversion/trunk/subversion/svnadmin/main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnadmin/main.c?rev=1063320&r1=1063319&r2=1063320&view=diff
==============================================================================
--- subversion/trunk/subversion/svnadmin/main.c (original)
+++ subversion/trunk/subversion/svnadmin/main.c Tue Jan 25 15:34:40 2011
@@ -1184,7 +1184,7 @@ set_revprop(const char *prop_name, const
prop_value->len = file_contents->len;
SVN_ERR(svn_subst_translate_string2(&prop_value, NULL, NULL, prop_value,
- NULL, pool, pool));
+ NULL, FALSE, pool, pool));
/* Open the filesystem */
SVN_ERR(open_repos(&repos, opt_state->repository_path, pool));
Modified: subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c?rev=1063320&r1=1063319&r2=1063320&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/subst_translate-test.c Tue Jan 25 15:34:40 2011
@@ -66,7 +66,7 @@ test_svn_subst_translate_string2(apr_poo
SVN_ERR(svn_subst_translate_string2(&new_value,
NULL, &translated_line_endings,
- source_string, "ISO-8859-1",
+ source_string, "ISO-8859-1", FALSE,
pool, pool));
SVN_TEST_STRING_ASSERT(new_value->data, t->expected_str);
SVN_TEST_ASSERT(translated_line_endings == t->translated_line_endings);
@@ -76,13 +76,42 @@ test_svn_subst_translate_string2(apr_poo
translated_line_endings = ! t->translated_line_endings;
SVN_ERR(svn_subst_translate_string2(&new_value, &translated_to_utf8,
&translated_line_endings,
- source_string, "ISO-8859-1",
+ source_string, "ISO-8859-1", FALSE,
pool, pool));
SVN_TEST_STRING_ASSERT(new_value->data, t->expected_str);
SVN_TEST_ASSERT(translated_to_utf8 == t->translated_to_utf8);
SVN_TEST_ASSERT(translated_line_endings == t->translated_line_endings);
}
+ /* Test that when REPAIR is FALSE, SVN_ERR_IO_INCONSISTENT_EOL is returned. */
+ {
+ svn_string_t *source_string = svn_string_create(" \r \r\n \n ", pool);
+ svn_string_t *new_value = NULL;
+ svn_error_t *err = svn_subst_translate_string2(&new_value, NULL, NULL,
+ source_string,
+ "ISO-8859-1", FALSE, pool,
+ pool);
+ SVN_TEST_ASSERT(err != SVN_NO_ERROR);
+ SVN_TEST_ASSERT(err->apr_err == SVN_ERR_IO_INCONSISTENT_EOL);
+ svn_error_clear(err);
+ }
+
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+test_repairing_svn_subst_translate_string2(apr_pool_t *pool)
+{
+ {
+ svn_string_t *source_string = svn_string_create(" \r \r\n \n ", pool);
+ svn_string_t *new_value = NULL;
+ SVN_ERR(svn_subst_translate_string2(&new_value, NULL, NULL, source_string,
+ "ISO-8859-1", TRUE, pool, pool));
+ SVN_TEST_ASSERT(new_value != NULL);
+ SVN_TEST_ASSERT(new_value->data != NULL);
+ SVN_TEST_STRING_ASSERT(new_value->data, " \n \n \n ");
+ }
+
return SVN_NO_ERROR;
}
@@ -142,6 +171,8 @@ struct svn_test_descriptor_t test_funcs[
SVN_TEST_NULL,
SVN_TEST_PASS2(test_svn_subst_translate_string2,
"test svn_subst_translate_string2()"),
+ SVN_TEST_PASS2(test_repairing_svn_subst_translate_string2,
+ "test repairing svn_subst_translate_string2()"),
SVN_TEST_PASS2(test_svn_subst_translate_cstring2,
"test svn_subst_translate_cstring2()"),
SVN_TEST_NULL