[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] be more tolerant of locale errors

From: Peter Samuelson <peter_at_p12n.org>
Date: 2006-04-21 06:22:30 CEST

A Debian user complains [1] that subversion refuses to run when his
locale is broken. (In the present instance it is apparently the fault
of something else in Debian, not his own fault.) Now, I know why
Subversion insists on getting a valid locale - it is handling user
data, including filenames, and wants to be sure it is converting to and
from the correct character set.

  [1] http://bugs.debian.org/363893

But that did get me thinking: if that reasoning is correct, it only
applies to LC_CTYPE; if other locale variables (LC_MESSAGES, for
localised output messages, LC_COLLATE, for sort order) are unusable,
those should be mere warnings rather than errors.

Thus the subversion clients would be a little more robust against
problems with the user's environment. Does anyone else think that this
would be a Good Thing?

NOTE: This patch is untested - I guess it's more for illustration than
to apply directly. I'll test it Real Soon Now.

[[[
Make locale setting in the client a bit more forgiving.

* subversion/libsvn_subr/cmdline.c (svn_cmdline_init): Set LC_CTYPE
  separately from LC_ALL, and if LC_ALL fails, do not consider it to be
  a fatal error.
]]]

Index: subversion/libsvn_subr/cmdline.c
===================================================================
--- subversion/libsvn_subr/cmdline.c (revisione 19429)
+++ subversion/libsvn_subr/cmdline.c (copia locale)
@@ -55,6 +55,7 @@
 {
   apr_status_t status;
   apr_pool_t *pool;
+ svn_boolean_t lc_ctype_ok = FALSE;
 
 #ifndef WIN32
   {
@@ -104,6 +105,8 @@
   /* C programs default to the "C" locale. But because svn is supposed
      to be i18n-aware, it should inherit the default locale of its
      environment. */
+ if (setlocale(LC_CTYPE, ""))
+ lc_ctype_ok = TRUE;
   if (!setlocale(LC_ALL, ""))
     {
       if (error_stream)
@@ -130,8 +133,13 @@
                   "%s: error: environment variable %s is %s\n"
                   "%s: error: please check that your locale name is correct\n",
                   progname, progname, *env_var, env_val, progname);
+ if (lc_ctype_ok)
+ fprintf(error_stream,
+ "%s: LC_CTYPE was set successfully, continuing\n",
+ progname);
         }
- return EXIT_FAILURE;
+ if (!lc_ctype_ok)
+ return EXIT_FAILURE;
     }
 
   /* Initialize the APR subsystem, and register an atexit() function

Received on Fri Apr 21 06:23:02 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.