Author: rinrab
Date: Mon May 26 14:58:30 2025
New Revision: 1925827

URL: http://svn.apache.org/viewvc?rev=1925827&view=rev
Log:
On the 'utf8-cmdline-prototype' branch: convert opt_arg to utf8 once
in the beginning of argument handling loop instead of doing this conversion
while handling every argument.

This is transitional code to convert them straight to utf8 from platform
dependent encoding.

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=1925827&r1=1925826&r2=1925827&view=diff
==============================================================================
--- subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c (original)
+++ subversion/branches/utf8-cmdline-prototype/subversion/svn/svn.c Mon May 26 
14:58:30 2025
@@ -2308,13 +2308,17 @@ sub_main(int *exit_code,
           return SVN_NO_ERROR;
         }
 
+      if (opt_arg != NULL)
+        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
+      else
+        utf8_opt_arg = NULL;
+
       /* Stash the option code in an array before parsing it. */
       APR_ARRAY_PUSH(received_opts, int) = opt_id;
 
       switch (opt_id) {
       case 'l':
         {
-          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
           err = svn_cstring_atoi(&opt_state.limit, utf8_opt_arg);
           if (err)
             {
@@ -2337,7 +2341,6 @@ sub_main(int *exit_code,
         {
           apr_array_header_t *change_revs;
 
-          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
           change_revs = svn_cstring_split(utf8_opt_arg, ", \n\r\t\v", TRUE,
                                           pool);
 
@@ -2366,7 +2369,6 @@ sub_main(int *exit_code,
         break;
       case 'r':
         opt_state.used_revision_arg = TRUE;
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         if (svn_opt_parse_revision_to_range(opt_state.revision_ranges,
                                             utf8_opt_arg, pool) != 0)
           {
@@ -2395,7 +2397,6 @@ sub_main(int *exit_code,
         /* We read the raw file content here.  We will convert it to UTF-8
          * later (if it's a log/lock message or an svn:* prop value),
          * according to the value of the '--encoding' option. */
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         SVN_ERR(svn_stringbuf_from_file2(&(opt_state.filedata),
                                          utf8_opt_arg, pool));
         reading_file_from_stdin = (strcmp(utf8_opt_arg, "-") == 0);
@@ -2405,7 +2406,6 @@ sub_main(int *exit_code,
         {
           svn_stringbuf_t *buffer, *buffer_utf8;
 
-          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
           SVN_ERR(svn_stringbuf_from_file2(&buffer, utf8_opt_arg, pool));
           SVN_ERR(svn_utf_stringbuf_to_utf8(&buffer_utf8, buffer, pool));
           opt_state.targets = svn_cstring_split(buffer_utf8->data, "\n\r",
@@ -2434,7 +2434,6 @@ sub_main(int *exit_code,
         opt_state.file_size_unit = SVN_CL__SIZE_UNIT_BASE_2;
         break;
       case opt_depth:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.depth = svn_depth_from_word(utf8_opt_arg);
         if (opt_state.depth == svn_depth_unknown
             || opt_state.depth == svn_depth_exclude)
@@ -2447,7 +2446,6 @@ sub_main(int *exit_code,
           }
         break;
       case opt_set_depth:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.set_depth = svn_depth_from_word(utf8_opt_arg);
         /* svn_depth_exclude is okay for --set-depth. */
         if (opt_state.set_depth == svn_depth_unknown)
@@ -2463,12 +2461,10 @@ sub_main(int *exit_code,
         opt_state.version = TRUE;
         break;
       case opt_auth_username:
-        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_username,
-                                        opt_arg, pool));
+        opt_state.auth_username = apr_pstrdup(pool, utf8_opt_arg);
         break;
       case opt_auth_password:
-        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.auth_password,
-                                        opt_arg, pool));
+        opt_state.auth_password = apr_pstrdup(pool, utf8_opt_arg);
         break;
       case opt_auth_password_from_stdin:
         read_pass_from_stdin = TRUE;
@@ -2498,7 +2494,6 @@ sub_main(int *exit_code,
         opt_state.trust_server_cert_unknown_ca = TRUE;
         break;
       case opt_trust_server_cert_failures:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         SVN_ERR(svn_cmdline__parse_trust_options(
                       &opt_state.trust_server_cert_unknown_ca,
                       &opt_state.trust_server_cert_cn_mismatch,
@@ -2532,8 +2527,7 @@ sub_main(int *exit_code,
         opt_state.relocate = TRUE;
         break;
       case 'x':
-        SVN_ERR(svn_utf_cstring_to_utf8(&opt_state.extensions,
-                                        opt_arg, pool));
+        opt_state.extensions = apr_pstrdup(pool, utf8_opt_arg);
         break;
       case opt_diff_cmd:
         opt_state.diff.diff_cmd = apr_pstrdup(pool, opt_arg);
@@ -2553,15 +2547,12 @@ sub_main(int *exit_code,
             return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                                     _("Can't specify -c with --old"));
           }
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.old_target = apr_pstrdup(pool, utf8_opt_arg);
         break;
       case opt_new_cmd:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.new_target = apr_pstrdup(pool, utf8_opt_arg);
         break;
       case opt_config_dir:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         SVN_ERR(svn_dirent_internal_style_safe(&opt_state.config_dir, NULL,
                                                utf8_opt_arg, pool, pool));
         break;
@@ -2571,7 +2562,6 @@ sub_main(int *exit_code,
                    apr_array_make(pool, 1,
                                   sizeof(svn_cmdline__config_argument_t*));
 
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         SVN_ERR(svn_cmdline__parse_config_option(opt_state.config_options,
                                                  utf8_opt_arg, "svn: ", pool));
         break;
@@ -2582,7 +2572,6 @@ sub_main(int *exit_code,
         opt_state.no_autoprops = TRUE;
         break;
       case opt_native_eol:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         if ( !strcmp("LF", utf8_opt_arg) || !strcmp("CR", utf8_opt_arg) ||
              !strcmp("CRLF", utf8_opt_arg))
           opt_state.native_eol = utf8_opt_arg;
@@ -2606,7 +2595,6 @@ sub_main(int *exit_code,
         opt_state.drop = TRUE;
         break;
       case opt_changelist:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         if (utf8_opt_arg[0] == '\0')
           {
             return svn_error_create(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
@@ -2639,7 +2627,6 @@ sub_main(int *exit_code,
         opt_state.use_merge_history = TRUE;
         break;
       case opt_accept:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.accept_which = svn_cl__accept_from_word(utf8_opt_arg);
         if (opt_state.accept_which == svn_cl__accept_invalid)
           return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
@@ -2647,7 +2634,6 @@ sub_main(int *exit_code,
                                    utf8_opt_arg);
         break;
       case opt_show_revs:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.show_revs = svn_cl__show_revs_from_word(utf8_opt_arg);
         if (opt_state.show_revs == svn_cl__show_revs_invalid)
           return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
@@ -2662,7 +2648,6 @@ sub_main(int *exit_code,
         break;
       case opt_strip:
         {
-          SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
           err = svn_cstring_atoi(&opt_state.strip, utf8_opt_arg);
           if (err)
             {
@@ -2711,7 +2696,6 @@ sub_main(int *exit_code,
         opt_state.diff.properties_only = TRUE;
         break;
       case opt_search:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         SVN_ERR(svn_utf__xfrm(&utf8_opt_arg, utf8_opt_arg,
                               strlen(utf8_opt_arg), TRUE, TRUE, &buf));
         add_search_pattern_group(&opt_state,
@@ -2719,7 +2703,6 @@ sub_main(int *exit_code,
                                  pool);
         break;
       case opt_search_and:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         SVN_ERR(svn_utf__xfrm(&utf8_opt_arg, utf8_opt_arg,
                               strlen(utf8_opt_arg), TRUE, TRUE, &buf));
         add_search_pattern_to_latest_group(&opt_state,
@@ -2746,8 +2729,7 @@ sub_main(int *exit_code,
         opt_state.pin_externals = TRUE;
         break;
       case opt_show_item:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
-        opt_state.show_item = utf8_opt_arg;
+        opt_state.show_item = apr_pstrdup(pool, utf8_opt_arg);
         break;
       case opt_adds_as_modification:
         opt_state.adds_as_modification = TRUE;
@@ -2757,14 +2739,12 @@ sub_main(int *exit_code,
         break;
       case opt_viewspec:
         opt_state.viewspec = TRUE;
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         SVN_ERR(viewspec_from_word(&opt_state.viewspec, utf8_opt_arg));
         break;
       case opt_compatible_version:
         SVN_ERR(parse_compatible_version(&opt_state, opt_arg, pool));
         break;
       case opt_store_pristine:
-        SVN_ERR(svn_utf_cstring_to_utf8(&utf8_opt_arg, opt_arg, pool));
         opt_state.store_pristine = svn_tristate__from_word(utf8_opt_arg);
         if (opt_state.store_pristine == svn_tristate_unknown)
           return svn_error_createf(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,


Reply via email to