Joost Verburg wrote:
> Abdelrazak Younes wrote:
>> Try to launch "lyx.exe -dbg any" to see how far it goes. Peter did you
>> try the debug mode compilation? It would help resolving this crash.

Yes, the debugger points me to a setlocale call, see below.

> Now it all compiles quickly and without errors, but lyx.exe still
> crashes immediately. Even with "-dbg any" no output is shown. Could you
> please try again whether you can get it to work with both Qt4 and LyX
> compiled with MSVC 2005?

When lyx is compiled with ENABLE_NLS it uses in message.C
the LC_MESSAGES macro, which is not defined by msvc.

But in intl/libintl.h it is set to an dummy value:

/* The LC_MESSAGES locale category is the category used by the functions
   gettext() and dgettext().  It is specified in POSIX, but not in ANSI C.
   On systems that don't define it, use an arbitrary value instead.
   On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
   then includes <libintl.h> (i.e. this file!) and then only defines
   LC_MESSAGES.  To avoid a redefinition warning, don't define LC_MESSAGES
   in this case.  */
#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && 
defined __sun))
# define LC_MESSAGES 1729
#endif


Using setlocal with an to msvc unknown value aborts immediately the program.

A first fix is to test on LC_MESSAGES and to
guard the call with HAVE_LC_MESSAGES:

Index: src/messages.C
===================================================================
--- src/messages.C      (revision 14054)
+++ src/messages.C      (working copy)
@@ -90,7 +90,10 @@
                : lang_(l)
        {
                if ( lang_.empty() ) {
-                       char const * lc_msgs = setlocale(LC_MESSAGES, NULL);
+                       char const * lc_msgs = 0;
+#ifdef HAVE_LC_MESSAGES
+                       lc_msgs = setlocale(LC_MESSAGES, NULL);
+#endif
                        lang_ = lc_msgs ? lc_msgs : "";
                }
                // strip off any encoding suffix, i.e., assume 8-bit po files
@@ -117,8 +120,9 @@
                                        lang = "C";
                        }
                }
-
+#ifdef HAVE_LC_MESSAGES
                char const * lc_msgs = setlocale(LC_MESSAGES, lang_.c_str());
+#endif
                // setlocale fails (returns NULL) if the corresponding locale
                // is not installed.
                // On windows (mingw) it always returns NULL.
@@ -164,7 +168,9 @@
                boost::smatch sub;
                if (regex_match(translated, sub, reg))
                        translated = sub.str(1);
+#ifdef HAVE_LC_MESSAGES
                setlocale(LC_MESSAGES, lang.c_str());
+#endif
                setlocale(LC_CTYPE, oldCTYPE.c_str());
                return translated;
        }



In message.C there is already a disabled LC_MESSAGES-free code.
I've tried it but the std::message of msvc uses only 2 parameters.


Peter

Reply via email to