On Thu, Jul 12, 2007 at 06:32:28PM +0200, Jürgen Spitzmüller wrote:
> Enrico Forestieri wrote:
> > Please, wait a minute. I have another option.
> 
> too late.

No problem. The attached patch should solve the problems related
to sorting according to the locale rules. I think that there is
no other way. When a locale is not installed, normal ordering
through "<" is performed, otherwise the locale rules are obeyed.

The crash you were having with LANG=en_EN was probably due to the
fact that you don't have that locale installed. If you install it,
the crash disappears. This patch accounts for this case, too, i.e.,
if you don't have a locale, you get normal ordering, but after you
install it, you can have that locale ordering.

Only the poor systems which don't have support for wchar_t are left
in the cold. And before you ask, yes this also accounts for the missing
facets in GCC 3.

-- 
Enrico
Index: src/frontends/controllers/frontend_helpers.cpp
===================================================================
--- src/frontends/controllers/frontend_helpers.cpp      (revision 19061)
+++ src/frontends/controllers/frontend_helpers.cpp      (working copy)
@@ -1108,21 +1108,31 @@ class Sorter
                                      LanguagePair, bool>
 {
 public:
-#if 1//defined(__GNUC__) && (!defined(USE_WCHAR_T) || __GNUC__ < 4)
+#if !defined(USE_WCHAR_T) && defined(__GNUC__)
        bool operator()(LanguagePair const & lhs,
                        LanguagePair const & rhs) const {
                return lhs.first < rhs.first;
        }
 #else
-// this is supposed to fix bug 2738, but it is not stable yet
-// see http://bugzilla.lyx.org/show_bug.cgi?id=2738
-       Sorter() : loc_("") {};
+       Sorter() : loc_ok(true)
+       {
+               try {
+                       loc_ = std::locale("");
+               } catch (...) {
+                       loc_ok = false;
+               }
+       };
+
        bool operator()(LanguagePair const & lhs,
                        LanguagePair const & rhs) const {
-               return loc_(lhs.first, rhs.first);
+               if (loc_ok)
+                       return loc_(lhs.first, rhs.first);
+               else
+                       return lhs.first < rhs.first;
        }
 private:
        std::locale loc_;
+       bool loc_ok;
 #endif
 };
 

Reply via email to