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

[PATCH.1] be more tolerant of locale errors

From: Peter Samuelson <peter_at_p12n.org>
Date: 2006-04-21 09:46:20 CEST

[Peter N. Lundblad]
> And in fact I'm wondering if this whole error out on locale error is
> a false protection. Nothing stops the user from running the client
> with the wrong locale, which should be as likely (or more likely?) as
> using a broken ditto.

That's a good point.

> - Set LC_ALL category.
> - If that fails:
> - Set LC_CTYPE category
> - If that fails, print a warning and continue.

That sounds sensible too.

[[[
Make locale handling more forgiving in the clients.

* subversion/libsvn_subr/cmdline.c (svn_cmdline_init): Try setting both
  LC_ALL and LC_CTYPE locale variables, warning only if both fail.
  Do not consider this a fatal error.
]]]

Index: subversion/libsvn_subr/cmdline.c
===================================================================
--- subversion/libsvn_subr/cmdline.c (revisione 19429)
+++ subversion/libsvn_subr/cmdline.c (copia locale)
@@ -104,7 +104,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_ALL, ""))
+ if (!setlocale(LC_ALL, "") &&
+ !setlocale(LC_CTYPE, ""))
     {
       if (error_stream)
         {
@@ -126,12 +127,11 @@
             }
 
           fprintf(error_stream,
- "%s: error: cannot set LC_ALL locale\n"
- "%s: error: environment variable %s is %s\n"
- "%s: error: please check that your locale name is correct\n",
+ "%s: warning: cannot set LC_CTYPE locale\n"
+ "%s: warning: environment variable %s is %s\n"
+ "%s: warning: please check that your locale name is correct\n",
                   progname, progname, *env_var, env_val, progname);
         }
- return EXIT_FAILURE;
     }
 
   /* Initialize the APR subsystem, and register an atexit() function

Received on Fri Apr 21 09:47:07 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.