groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] Re: setlocale problem in groff


From: Bruno Haible
Subject: [Groff] Re: setlocale problem in groff
Date: Sat, 12 Aug 2006 18:09:00 +0200
User-agent: KMail/1.9.1

Hello Werner,

> you've added the following code to groff's src/include/lib.h:
> 
>   #ifdef HAVE_SETLOCALE
>   #include <locale.h>
>   #else
>   #define setlocale(category, locale) do {} while(0)
>   #endif
> 
> but this doesn't work if `HAVE_SETLOCALE' isn't defined, because in
> preconv.cpp we have this:
> 
>   setlocale(LC_ALL, "");
>   char *locale = setlocale(LC_CTYPE, NULL);                           // <----
>   if (!locale || !strcmp(locale, "C") || !strcmp(locale, "POSIX"))
>     default_encoding = "latin1";
>   else
>     default_encoding = locale_charset();
> 
> What do you recommend as a fix?

I would introduce a macro that reflects the semantics that you want to
use in preconv.cpp. Let's call it 'getlocale'.

  #ifdef HAVE_SETLOCALE
    #include <locale.h>
    #define getlocale(category) setlocale(category, NULL)
  #else
    #define setlocale(category, locale) (void)(category, locale)
    #define getlocale(category) ((void)(category), "C")
  #endif

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]