Author: rinrab
Date: Mon May 26 16:56:57 2025
New Revision: 1925832
URL: http://svn.apache.org/viewvc?rev=1925832&view=rev
Log:
On the 'utf8-cmdline-prototype' branch: add a version of svn_opt_parse_revprop()
that assumes that revprop_spec is already converted to utf8, test it, and use
in the command line instead of the old one. At this point no functionality has
been changed.
* subversion/include/svn_opt.h
(svn_opt_parse_revprop_utf8): Declare symbol.
* subversion/libsvn_subr/opt.c
(svn_opt_parse_revprop_utf8): Copy implementation from svn_opt_parse_revprop,
but remove encoding conversion.
(svn_opt_parse_revprop): Implement through svn_opt_parse_revprop_utf8().
* subversion/svn/svn.c
* subversion/svnbench/svnbench.c
* subversion/svnmucc/svnmucc.c
(sub_main): Use new function.
* subversion/tests/libsvn_subr/opt-test.c
(test_svn_opt_parse_revprop): New test.
(test_funcs): Run the test.
### TODO: maybe deprecate svn_opt_parse_revprop?
Modified:
subversion/branches/utf8-cmdline-prototype/subversion/include/svn_opt.h
subversion/branches/utf8-cmdline-prototype/subversion/libsvn_subr/opt.c
subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c
subversion/branches/utf8-cmdline-prototype/subversion/svnbench/svnbench.c
subversion/branches/utf8-cmdline-prototype/subversion/svnmucc/svnmucc.c
subversion/branches/utf8-cmdline-prototype/subversion/tests/libsvn_subr/opt-test.c
Modified:
subversion/branches/utf8-cmdline-prototype/subversion/include/svn_opt.h
URL:
http://svn.apache.org/viewvc/subversion/branches/utf8-cmdline-prototype/subversion/include/svn_opt.h?rev=1925832&r1=1925831&r2=1925832&view=diff
==============================================================================
--- subversion/branches/utf8-cmdline-prototype/subversion/include/svn_opt.h
(original)
+++ subversion/branches/utf8-cmdline-prototype/subversion/include/svn_opt.h Mon
May 26 16:56:57 2025
@@ -677,6 +677,16 @@ svn_error_t *
svn_opt_parse_revprop(apr_hash_t **revprops, const char *revprop_spec,
apr_pool_t *pool);
+/**
+ * Similar to svn_opt_parse_revprop() but assumes that revprop_spec_utf8 is
+ * already utf8 encoded.
+ *
+ * @since New in 1.15.
+ */
+svn_error_t *
+svn_opt_parse_revprop_utf8(apr_hash_t **revprop_table_p,
+ const char *revprop_spec_utf8,
+ apr_pool_t *pool);
/**
* If no targets exist in @a *targets, add `.' as the lone target.
Modified:
subversion/branches/utf8-cmdline-prototype/subversion/libsvn_subr/opt.c
URL:
http://svn.apache.org/viewvc/subversion/branches/utf8-cmdline-prototype/subversion/libsvn_subr/opt.c?rev=1925832&r1=1925831&r2=1925832&view=diff
==============================================================================
--- subversion/branches/utf8-cmdline-prototype/subversion/libsvn_subr/opt.c
(original)
+++ subversion/branches/utf8-cmdline-prototype/subversion/libsvn_subr/opt.c Mon
May 26 16:56:57 2025
@@ -1071,26 +1071,38 @@ svn_error_t *
svn_opt_parse_revprop(apr_hash_t **revprop_table_p, const char *revprop_spec,
apr_pool_t *pool)
{
+ const char *revprop_spec_utf8;
+
+ SVN_ERR(svn_utf_cstring_to_utf8(&revprop_spec_utf8, revprop_spec, pool));
+
+ return svn_error_trace(svn_opt_parse_revprop_utf8(revprop_table_p,
+ revprop_spec_utf8, pool));
+}
+
+svn_error_t *
+svn_opt_parse_revprop_utf8(apr_hash_t **revprop_table_p,
+ const char *revprop_spec_utf8, apr_pool_t *pool)
+{
const char *sep, *propname;
svn_string_t *propval;
- if (! *revprop_spec)
+ if (!*revprop_spec_utf8)
return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("Revision property pair is empty"));
- if (! *revprop_table_p)
+ if (!*revprop_table_p)
*revprop_table_p = apr_hash_make(pool);
- sep = strchr(revprop_spec, '=');
+ sep = strchr(revprop_spec_utf8, '=');
if (sep)
{
- propname = apr_pstrndup(pool, revprop_spec, sep - revprop_spec);
- SVN_ERR(svn_utf_cstring_to_utf8(&propname, propname, pool));
+ propname =
+ apr_pstrndup(pool, revprop_spec_utf8, sep - revprop_spec_utf8);
propval = svn_string_create(sep + 1, pool);
}
else
{
- SVN_ERR(svn_utf_cstring_to_utf8(&propname, revprop_spec, pool));
+ propname = apr_pstrdup(pool, revprop_spec_utf8);
propval = svn_string_create_empty(pool);
}
Modified: subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c
URL:
http://svn.apache.org/viewvc/subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c?rev=1925832&r1=1925831&r2=1925832&view=diff
==============================================================================
--- subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c (original)
+++ subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c Mon May 26
16:56:57 2025
@@ -2615,8 +2615,8 @@ sub_main(int *exit_code,
opt_state.no_revprops = TRUE;
break;
case opt_with_revprop:
- SVN_ERR(svn_opt_parse_revprop(&opt_state.revprop_table,
- opt_arg, pool));
+ SVN_ERR(svn_opt_parse_revprop_utf8(&opt_state.revprop_table,
+ utf8_opt_arg, pool));
break;
case opt_parents:
opt_state.parents = TRUE;
Modified:
subversion/branches/utf8-cmdline-prototype/subversion/svnbench/svnbench.c
URL:
http://svn.apache.org/viewvc/subversion/branches/utf8-cmdline-prototype/subversion/svnbench/svnbench.c?rev=1925832&r1=1925831&r2=1925832&view=diff
==============================================================================
--- subversion/branches/utf8-cmdline-prototype/subversion/svnbench/svnbench.c
(original)
+++ subversion/branches/utf8-cmdline-prototype/subversion/svnbench/svnbench.c
Mon May 26 16:56:57 2025
@@ -632,8 +632,9 @@ sub_main(int *exit_code,
opt_state.no_revprops = TRUE;
break;
case opt_with_revprop:
- SVN_ERR(svn_opt_parse_revprop(&opt_state.revprop_table,
- opt_arg, pool));
+ SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+ SVN_ERR(svn_opt_parse_revprop_utf8(&opt_state.revprop_table,
+ utf8_opt_arg, pool));
break;
case 'g':
opt_state.use_merge_history = TRUE;
Modified:
subversion/branches/utf8-cmdline-prototype/subversion/svnmucc/svnmucc.c
URL:
http://svn.apache.org/viewvc/subversion/branches/utf8-cmdline-prototype/subversion/svnmucc/svnmucc.c?rev=1925832&r1=1925831&r2=1925832&view=diff
==============================================================================
--- subversion/branches/utf8-cmdline-prototype/subversion/svnmucc/svnmucc.c
(original)
+++ subversion/branches/utf8-cmdline-prototype/subversion/svnmucc/svnmucc.c Mon
May 26 16:56:57 2025
@@ -610,7 +610,8 @@ sub_main(int *exit_code,
}
break;
case with_revprop_opt:
- SVN_ERR(svn_opt_parse_revprop(&revprops, arg, pool));
+ SVN_ERR(svn_utf_cstring_to_utf8(&opt_arg, arg, pool));
+ SVN_ERR(svn_opt_parse_revprop_utf8(&revprops, opt_arg, pool));
break;
case 'X':
SVN_ERR(svn_utf_cstring_to_utf8(&extra_args_file, arg, pool));
Modified:
subversion/branches/utf8-cmdline-prototype/subversion/tests/libsvn_subr/opt-test.c
URL:
http://svn.apache.org/viewvc/subversion/branches/utf8-cmdline-prototype/subversion/tests/libsvn_subr/opt-test.c?rev=1925832&r1=1925831&r2=1925832&view=diff
==============================================================================
---
subversion/branches/utf8-cmdline-prototype/subversion/tests/libsvn_subr/opt-test.c
(original)
+++
subversion/branches/utf8-cmdline-prototype/subversion/tests/libsvn_subr/opt-test.c
Mon May 26 16:56:57 2025
@@ -27,6 +27,7 @@
#include "../svn_test.h"
#include "svn_opt.h"
+#include "svn_hash.h"
#include "private/svn_opt_private.h"
@@ -263,6 +264,32 @@ test_svn_opt_parse_change_to_range(apr_p
return SVN_NO_ERROR;
}
+static svn_error_t *
+test_svn_opt_parse_revprop(apr_pool_t *pool)
+{
+#define UNICODE_TEST_STRING "\xf0\x9f\x91\x89\xf0\x9f\x91\x88"
+
+ apr_hash_t *hash = apr_hash_make(pool);
+ svn_string_t *val;
+
+ apr_hash_clear(hash);
+ SVN_ERR(svn_opt_parse_revprop(&hash, "name=val", pool));
+ val = apr_hash_get(hash, "name", APR_HASH_KEY_STRING);
+ SVN_TEST_STRING_ASSERT(val->data, "val");
+
+ apr_hash_clear(hash);
+ SVN_ERR(svn_opt_parse_revprop_utf8(&hash, "name=val", pool));
+ val = apr_hash_get(hash, "name", APR_HASH_KEY_STRING);
+ SVN_TEST_STRING_ASSERT(val->data, "val");
+
+ apr_hash_clear(hash);
+ SVN_ERR(svn_opt_parse_revprop_utf8(&hash, "name=" UNICODE_TEST_STRING,
pool));
+ val = apr_hash_get(hash, "name", APR_HASH_KEY_STRING);
+ SVN_TEST_STRING_ASSERT(val->data, UNICODE_TEST_STRING);
+
+ return SVN_NO_ERROR;
+}
+
/* The test table. */
@@ -277,6 +304,8 @@ static struct svn_test_descriptor_t test
"test svn_opt_args_to_target_array2"),
SVN_TEST_PASS2(test_svn_opt_parse_change_to_range,
"test svn_opt_parse_change_to_range"),
+ SVN_TEST_PASS2(test_svn_opt_parse_revprop,
+ "test test_svn_opt_parse_revprop"),
SVN_TEST_NULL
};