Author: rinrab
Date: Tue May 27 23:15:25 2025
New Revision: 1925892

URL: http://svn.apache.org/viewvc?rev=1925892&view=rev
Log:
On the 'utf8-cmdline-prototype' branch: utf8-ize svnlook program 🧑‍💻

* subversion/svnlook/svnlook.c
  (print_diff_tree): Don't convert diff_options to utf8 twice.
  (sub_main): Convert args straight to utf8, remove in-place conversions,
   and handle the other arguments as utf8.

Modified:
    subversion/branches/utf8-cmdline-prototype/subversion/svnlook/svnlook.c

Modified: 
subversion/branches/utf8-cmdline-prototype/subversion/svnlook/svnlook.c
URL: 
http://svn.apache.org/viewvc/subversion/branches/utf8-cmdline-prototype/subversion/svnlook/svnlook.c?rev=1925892&r1=1925891&r2=1925892&view=diff
==============================================================================
--- subversion/branches/utf8-cmdline-prototype/subversion/svnlook/svnlook.c 
(original)
+++ subversion/branches/utf8-cmdline-prototype/subversion/svnlook/svnlook.c Tue 
May 27 23:15:25 2025
@@ -998,9 +998,8 @@ print_diff_tree(svn_stream_t *out_stream
                   diff_cmd_argv = apr_palloc(pool,
                                              diff_cmd_argc * sizeof(char *));
                   for (i = 0; i < diff_cmd_argc; i++)
-                    SVN_ERR(svn_utf_cstring_to_utf8(&diff_cmd_argv[i],
-                              APR_ARRAY_IDX(c->diff_options, i, const char *),
-                              pool));
+                    diff_cmd_argv[i] = apr_pstrdup(
+                        pool, APR_ARRAY_IDX(c->diff_options, i, const char *));
                 }
 
               /* Print diff header. */
@@ -2487,7 +2486,7 @@ sub_main(int *exit_code,
   /* Check library versions */
   SVN_ERR(check_lib_versions());
 
-  SVN_ERR(svn_cmdline__get_cstring_argv(&argv, argc, cmdline_argv, pool));
+  SVN_ERR(svn_cmdline__get_utf8_argv(&argv, argc, cmdline_argv, pool));
 
   /* Initialize the FS library. */
   SVN_ERR(svn_fs_initialize(pool));
@@ -2510,10 +2509,10 @@ sub_main(int *exit_code,
   os->interleave = 1;
   while (1)
     {
-      const char *opt_arg;
+      const char *utf8_opt_arg;
 
       /* Parse the next option. */
-      apr_err = apr_getopt_long(os, options_table, &opt_id, &opt_arg);
+      apr_err = apr_getopt_long(os, options_table, &opt_id, &utf8_opt_arg);
       if (APR_STATUS_IS_EOF(apr_err))
         break;
       else if (apr_err)
@@ -2529,17 +2528,17 @@ sub_main(int *exit_code,
       switch (opt_id)
         {
         case 'r':
-          SVN_ERR(svn_revnum_parse(&opt_state.rev, opt_arg, NULL));
+          SVN_ERR(svn_revnum_parse(&opt_state.rev, utf8_opt_arg, NULL));
           break;
 
         case 't':
-          opt_state.txn = opt_arg;
+          opt_state.txn = apr_pstrdup(pool, utf8_opt_arg);
           break;
 
         case 'M':
           {
             apr_uint64_t sz_val;
-            SVN_ERR(svn_cstring_atoui64(&sz_val, opt_arg));
+            SVN_ERR(svn_cstring_atoui64(&sz_val, utf8_opt_arg));
 
             opt_state.memory_cache_size = 0x100000 * sz_val;
           }
@@ -2580,8 +2579,6 @@ sub_main(int *exit_code,
 
         case 'l':
           {
-            const char *utf8_opt_arg;
-            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)
               {
@@ -2617,7 +2614,7 @@ sub_main(int *exit_code,
           break;
 
         case 'x':
-          opt_state.extensions = opt_arg;
+          opt_state.extensions = apr_pstrdup(pool, utf8_opt_arg);
           break;
 
         case svnlook__ignore_properties:
@@ -2629,7 +2626,7 @@ sub_main(int *exit_code,
           break;
 
         case svnlook__diff_cmd:
-          opt_state.diff_cmd = opt_arg;
+          opt_state.diff_cmd = apr_pstrdup(pool, utf8_opt_arg);
           break;
 
         case svnlook__show_inherited_props:
@@ -2698,10 +2695,8 @@ sub_main(int *exit_code,
         }
       else
         {
-          const char *first_arg;
+          const char *first_arg = os->argv[os->ind++];
 
-          SVN_ERR(svn_utf_cstring_to_utf8(&first_arg, os->argv[os->ind++],
-                                          pool));
           subcommand = svn_opt_get_canonical_subcommand3(cmd_table, first_arg);
           if (subcommand == NULL)
             {
@@ -2738,12 +2733,7 @@ sub_main(int *exit_code,
 
       /* Get the repository. */
       if (os->ind < os->argc)
-        {
-          SVN_ERR(svn_utf_cstring_to_utf8(&repos_path,
-                                          os->argv[os->ind++],
-                                          pool));
-          repos_path = svn_dirent_internal_style(repos_path, pool);
-        }
+        repos_path = svn_dirent_internal_style(os->argv[os->ind++], pool);
 
       if (repos_path == NULL)
         {
@@ -2768,18 +2758,14 @@ sub_main(int *exit_code,
 
       /* Get next arg (arg1), if any. */
       if (os->ind < os->argc)
-        {
-          SVN_ERR(svn_utf_cstring_to_utf8(&arg1, os->argv[os->ind++], pool));
-          arg1 = svn_dirent_internal_style(arg1, pool);
-        }
+        arg1 = svn_dirent_internal_style(os->argv[os->ind++], pool);
+
       opt_state.arg1 = arg1;
 
       /* Get next arg (arg2), if any. */
       if (os->ind < os->argc)
-        {
-          SVN_ERR(svn_utf_cstring_to_utf8(&arg2, os->argv[os->ind++], pool));
-          arg2 = svn_dirent_internal_style(arg2, pool);
-        }
+        arg2 = svn_dirent_internal_style(os->argv[os->ind++], pool);
+
       opt_state.arg2 = arg2;
     }
 


Reply via email to