On Wed, May 28, 2025 at 4:02 PM Branko Čibej <br...@apache.org> wrote:

> On 28. 5. 25 14:31, rin...@apache.org wrote:
>
> Author: rinrab
> Date: Wed May 28 12:31:55 2025
> New Revision: 1925902
>
> URL: http://svn.apache.org/viewvc?rev=1925902&view=rev
> Log:
> On the 'utf8-cmdline-prototype' branch: avoid double coping of arguments
> after encoding conversion.
>
> This is a follow-up to r1925836.
>
> * subversion/svn/svn.c
>   (--diff-cmd, --merge-cmd, --editor-cmd): Ditto.
>
> Modified:
>     subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c
>
> 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=1925902&r1=1925901&r2=1925902&view=diff
> ==============================================================================
> --- subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c (original)
> +++ subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c Wed May 
> 28 12:31:55 2025
> @@ -2521,19 +2521,19 @@ sub_main(int *exit_code,
>          opt_state.extensions = apr_pstrdup(pool, utf8_opt_arg);
>          break;
>        case opt_diff_cmd:
> -        SVN_ERR(svn_utf_cstring_from_utf8(&opt_arg, utf8_opt_arg, pool));
> -        opt_state.diff.diff_cmd = apr_pstrdup(pool, opt_arg);
> +        SVN_ERR(svn_utf_cstring_from_utf8(&opt_state.diff.diff_cmd,
> +                                          utf8_opt_arg, pool));
>          break;
>
>
> Double conversions again. You already have opt_arg in the correct native
> encoding, except you don't know if it's in the pool, so all you need is
> this:
>
>     opt_state.diff.diff_cmd = apr_pstrdup(pool, opt_arg);
>
>
> The other two are the same.
>
> -- Brane
>
>
opt_arg is NULL since r1925836, so the encoding has to be converted back to
cstring for --*-cmd arguments.

That's all due to this change:

       /* Parse the next option. */
-      apr_status_t apr_err = apr_getopt_long(os, svn_cl__options, &opt_id,
-                                             *&opt_arg*);
+      apr_status_t apr_err = apr_getopt_long(os, svn_cl__options,
+                                             &opt_id, *&utf8_opt_arg*);

-- 
Timofei Zhakov

Reply via email to