Hi,

I would like to suggest adding a line to svn --version command to display
the current locale name.

This could be helpful for us receiving or investigating any
encoding-related bugs, and seems generally useful to a part of platform
information.

So, I decided to draft a patch (attached to the email) to implement this
feature. Providing examples of the machine info section of the new svn
--version --verbose command below:

* running on x86_64-microsoft-windows6.2.9200
  - Windows 10 Pro, build 26100 [6.3 Client Multiprocessor Free]
  - locale encoding: CP1252

---

* running on x86_64-unknown-linux-gnu
  - "Debian GNU/Linux 12 (bookworm)" [Linux
6.6.87.1-microsoft-standard-WSL2]
  - locale encoding: UTF-8

---

* running on x86_64-unknown-linux-gnu
  - "Debian GNU/Linux 12 (bookworm)" [Linux
6.6.87.1-microsoft-standard-WSL2]
  - locale encoding: ISO-8859-15

- I didn't yet find a good way to display this part: *en_US*.UTF-8 of
locale info, but I think it's not mandatory for us. So it's fine.

Thoughts?

-- 
Timofei Zhakov
Index: subversion/include/svn_version.h
===================================================================
--- subversion/include/svn_version.h    (revision 1926036)
+++ subversion/include/svn_version.h    (working copy)
@@ -391,6 +391,16 @@
 svn_version_ext_runtime_osname(const svn_version_extended_t *ext_info);
 
 /**
+ * Accessor for svn_version_extended_t.
+ *
+ * @return The name of the current locale character set.
+ *
+ * @since New in 1.15.
+ */
+const char *
+svn_version_ext_locale_encoding(const svn_version_extended_t *ext_info);
+
+/**
  * Dependent library information.
  * Describes the name and versions of known dependencies
  * used by libsvn_subr.
Index: subversion/libsvn_subr/opt_subcommand.c
===================================================================
--- subversion/libsvn_subr/opt_subcommand.c     (revision 1926036)
+++ subversion/libsvn_subr/opt_subcommand.c     (working copy)
@@ -29,6 +29,7 @@
 
 #include <assert.h>
 #include <apr_general.h>
+#include <apr_portable.h>
 
 #include "svn_hash.h"
 #include "svn_cmdline.h"
@@ -491,6 +492,9 @@
                                      svn_version_ext_runtime_osname(info)));
         }
 
+      SVN_ERR(svn_cmdline_printf(pool, _("  - locale encoding: %s\n"),
+                                 svn_version_ext_locale_encoding(info)));
+
       libs = svn_version_ext_linked_libs(info);
       if (libs && libs->nelts)
         {
Index: subversion/libsvn_subr/sysinfo.c
===================================================================
--- subversion/libsvn_subr/sysinfo.c    (revision 1926036)
+++ subversion/libsvn_subr/sysinfo.c    (working copy)
@@ -35,6 +35,7 @@
 #include <apr_thread_proc.h>
 #include <apr_version.h>
 #include <apu_version.h>
+#include <apr_portable.h>
 
 #include "svn_pools.h"
 #include "svn_ctype.h"
@@ -137,6 +138,12 @@
 #endif
 }
 
+const char *
+svn_sysinfo__locale_encoding(apr_pool_t *pool)
+{
+  return apr_os_locale_encoding(pool);
+}
+
 const apr_array_header_t *
 svn_sysinfo__linked_libs(apr_pool_t *pool)
 {
Index: subversion/libsvn_subr/sysinfo.h
===================================================================
--- subversion/libsvn_subr/sysinfo.h    (revision 1926036)
+++ subversion/libsvn_subr/sysinfo.h    (working copy)
@@ -45,6 +45,12 @@
  */
 const char *svn_sysinfo__release_name(apr_pool_t *pool);
 
+/* Return the name of the current locale character set.
+ *
+ * All allocations are done in POOL.
+ */
+const char *svn_sysinfo__locale_encoding(apr_pool_t *pool);
+
 /* Return an array of svn_version_linked_lib_t of descriptions of the
  * link-time and run-time versions of dependent libraries, or NULL of
  * the info is not available.
Index: subversion/libsvn_subr/version.c
===================================================================
--- subversion/libsvn_subr/version.c    (revision 1926036)
+++ subversion/libsvn_subr/version.c    (working copy)
@@ -122,6 +122,7 @@
   const char *copyright;        /* Copyright notice (localized) */
   const char *runtime_host;     /* Runtime canonical host name */
   const char *runtime_osname;   /* Running OS release name */
+  const char *locale_encoding;  /* Encoding of the current locale */
 
   /* Array of svn_version_ext_linked_lib_t describing dependent
      libraries. */
@@ -153,6 +154,7 @@
     {
       info->runtime_host = svn_sysinfo__canonical_host(pool);
       info->runtime_osname = svn_sysinfo__release_name(pool);
+      info->locale_encoding = svn_sysinfo__locale_encoding(pool);
       info->linked_libs = svn_sysinfo__linked_libs(pool);
       info->loaded_libs = svn_sysinfo__loaded_libs(pool);
     }
@@ -197,6 +199,12 @@
   return ext_info->runtime_osname;
 }
 
+const char *
+svn_version_ext_locale_encoding(const svn_version_extended_t *ext_info)
+{
+  return ext_info->locale_encoding;
+}
+
 const apr_array_header_t *
 svn_version_ext_linked_libs(const svn_version_extended_t *ext_info)
 {

Reply via email to