The R Project SVN R

Rev

Rev 41833 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

The main problems we found were with the use of iconv

1) On Solaris 8 this finds iconv, but as it does not use the same charset
names as glibc/libiconv's iconv, it does not work.

2) On Windows we have a load-on-demand iconv, and no shipped iconv.h.

So we modified the iconv references to use our extra test and to use Riconv.


Since we do not use relocation (and it was not easy to get to compile on
Windows) we have removed it, as well as OS/2 compatibility.  Also, we
do not install or use locale.alias, and charset.alias is compiled in
(via charsetalias.h) rather than read at runtime.


Since the packages will need libintl.h, we need to install it.  We also
need to ensure that we get our version and not, e.g. the Solaris version.

Since this is made with visibility hidden, we need to add visibility
to some entry points.

On Windows we needed to override the way the locale_charset is found,
and map some Windows locale names to XPG ones.

BDR

diff -u intl/dcigettext.c ../extra/intl/dcigettext.c
--- intl/dcigettext.c   2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/dcigettext.c  2007-05-12 07:16:44.000000000 +0100
@@ -260,6 +260,9 @@
   size_t translation_length;
 
   /* Pointer to the string in question.  */
+#ifdef __GNUC__
+  __extension__
+#endif
   char msgid[ZERO];
 };
 
@@ -1055,6 +1058,7 @@
         entry does not exist or if this does not contain the 'charset='
         information, we will assume the charset matches the one the
         current locale and we don't have to perform any conversion.  */
+# if 0
 # ifdef _LIBC
      convd->conv = (__gconv_t) -1;
 # else
@@ -1062,6 +1066,11 @@
      convd->conv = (iconv_t) -1;
 #  endif
 # endif
+# endif
+
+#if defined(HAVE_ICONV) && defined(ICONV_LATIN1)
+     convd->conv = (void *) -1;
+#endif
      {
        char *nullentry;
        size_t nullentrylen;
@@ -1118,7 +1127,7 @@
            convd->conv = (__gconv_t) -1;
              }
 # else
-#  if HAVE_ICONV
+#if defined(HAVE_ICONV) && defined(ICONV_LATIN1)
            /* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
               we want to use transliteration.  */
 #   if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \
@@ -1133,13 +1142,13 @@
            memcpy (tmp + len, "//TRANSLIT", 10 + 1);
            outcharset = tmp;
 
-           convd->conv = iconv_open (outcharset, charset);
+           convd->conv = Riconv_open (outcharset, charset);
 
            freea (outcharset);
              }
            else
 #   endif
-             convd->conv = iconv_open (outcharset, charset);
+             convd->conv = Riconv_open (outcharset, charset);
 #  endif
 # endif
 
@@ -1153,6 +1162,7 @@
    }
 
       if (
+#if 0
 # ifdef _LIBC
      convd->conv != (__gconv_t) -1
 # else
@@ -1160,6 +1170,13 @@
      convd->conv != (iconv_t) -1
 #  endif
 # endif
+#endif
+#if defined(HAVE_ICONV) && defined(ICONV_LATIN1)
+     convd->conv != (void *) -1
+#else
+     0
+#endif
+
      )
    {
      /* We are supposed to do a conversion.  First allocate an
@@ -1248,8 +1265,8 @@
            goto resize_freemem;
 
          outleft = freemem_size - sizeof (size_t);
-         if (iconv (convd->conv,
-                (ICONV_CONST char **) &inptr, &inleft,
+         if (Riconv (convd->conv,
+                &inptr, &inleft,
                 &outptr, &outleft)
              != (size_t) (-1))
            {
@@ -1503,6 +1520,13 @@
      locale_defaulted = 1;
    }
     }
+#  ifdef WIN32
+  /* Need to translate some Windows locale names */
+  if(strcmp(locale, "chs") == 0) locale = "zh_CN";
+  if(strcmp(locale, "chinese") == 0) locale = "zh_TW";
+  if(strcmp(locale, "cht") == 0) locale = "zh_TW";
+  if(strcmp(locale, "ptb") == 0) locale = "pt_BR";
+#  endif
 # endif
 #endif
 
Only in ../extra/intl: dcngettext.o
diff -u intl/dgettext.c ../extra/intl/dgettext.c
--- intl/dgettext.c 2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/dgettext.c    2007-05-12 05:55:38.000000000 +0100
@@ -46,7 +46,10 @@
 
 /* Look up MSGID in the DOMAINNAME message catalog of the current
    LC_MESSAGES locale.  */
-char *
+#ifdef HAVE_VISIBILITY_ATTRIBUTE
+__attribute__ ((visibility ("default")))
+#endif
+char * 
 DGETTEXT (const char *domainname, const char *msgid)
 {
   return DCGETTEXT (domainname, msgid, LC_MESSAGES);
diff -u intl/finddomain.c ../extra/intl/finddomain.c
--- intl/finddomain.c   2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/finddomain.c  2007-05-12 05:26:42.000000000 +0100
@@ -67,7 +67,9 @@
   const char *territory;
   const char *codeset;
   const char *normalized_codeset;
+#ifdef NOT_USED
   const char *alias_value;
+#endif
   int mask;
 
   /* LOCALE can consist of up to four recognized parts for the XPG syntax:
@@ -120,6 +122,7 @@
       /* NOTREACHED */
     }
 
+#ifdef NOT_USED /* R change */
   /* See whether the locale value is an alias.  If yes its value
      *overwrites* the alias name.  No test for the original value is
      done.  */
@@ -139,6 +142,7 @@
       memcpy (locale, alias_value, len);
 #endif
     }
+#endif
 
   /* Now we determine the single parts of the locale name.  First
      look for the language.  Termination symbols are `_', '.', and `@'.  */
@@ -175,9 +179,12 @@
    }
     }
 
+
+#ifdef NOT_USED
   /* The room for an alias was dynamically allocated.  Free it now.  */
   if (alias_value != NULL)
     free (locale);
+#endif
 
   /* The space for normalized_codeset is dynamically allocated.  Free it.  */
   if (mask & XPG_NORM_CODESET)
diff -u intl/gettext.c ../extra/intl/gettext.c
--- intl/gettext.c  2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/gettext.c 2007-05-12 05:56:24.000000000 +0100
@@ -51,6 +51,9 @@
 /* Look up MSGID in the current default message catalog for the current
    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
    text).  */
+#ifdef HAVE_VISIBILITY_ATTRIBUTE
+__attribute__ ((visibility ("default")))
+#endif
 char *
 GETTEXT (const char *msgid)
 {
diff -u intl/gettextP.h ../extra/intl/gettextP.h
--- intl/gettextP.h 2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/gettextP.h    2007-05-12 04:02:42.000000000 +0100
@@ -26,7 +26,7 @@
 # include "../iconv/gconv_int.h"
 #else
 # if HAVE_ICONV
-#  include <iconv.h>
+# include <R_ext/Riconv.h>
 # endif
 #endif
 
@@ -136,7 +136,7 @@
   __gconv_t conv;
 #else
 # if HAVE_ICONV
-  iconv_t conv;
+  void * conv;
 # endif
 #endif
   /* The table of translated strings after charset conversion.  */
@@ -201,6 +201,9 @@
   struct binding *next;
   char *dirname;
   char *codeset;
+#ifdef __GNUC__
+  __extension__ 
+#endif
   char domainname[ZERO];
 };
 
diff -u intl/localcharset.c ../extra/intl/localcharset.c
--- intl/localcharset.c 2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/localcharset.c    2007-05-15 13:36:08.000000000 +0100
@@ -19,7 +19,9 @@
 
 /* Written by Bruno Haible <bruno@clisp.org>.  */
 
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
 
 /* Specification.  */
 #include "localcharset.h"
@@ -65,10 +67,12 @@
 # define relocate(pathname) (pathname)
 #endif
 
+#if 0
 /* Get LIBDIR.  */
 #ifndef LIBDIR
 # include "configmake.h"
 #endif
+#endif
 
 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
   /* Win32, Cygwin, OS/2, DOS */
@@ -112,6 +116,9 @@
   if (cp == NULL)
     {
 #if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
+/* we convert charset.alias to a header file at compile time */
+#include "charsetalias.h"
+#if 0
       FILE *fp;
       const char *dir;
       const char *base = "charset.alias";
@@ -209,7 +216,7 @@
 
       if (file_name != NULL)
    free (file_name);
-
+#endif
 #else
 
 # if defined VMS
diff -u intl/localename.c ../extra/intl/localename.c
--- intl/localename.c   2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/localename.c  2007-05-12 04:28:12.000000000 +0100
@@ -1142,7 +1142,7 @@
    switch (sub)
      {
      case SUBLANG_BENGALI_INDIA: return "bn_IN";
-     case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
+          // case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
      }
    return "bn";
       case LANG_BULGARIAN: return "bg_BG";
@@ -1356,7 +1356,7 @@
    switch (sub)
      {
      case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */
-     case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */
+     // case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */
      }
    return "pa";
       case LANG_RHAETO_ROMANCE: return "rm_CH";
@@ -1364,7 +1364,7 @@
    switch (sub)
      {
      case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO";
-     case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD";
+     // case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD";
      }
    return "ro";
       case LANG_RUSSIAN:
diff -u intl/ngettext.c ../extra/intl/ngettext.c
--- intl/ngettext.c 2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/ngettext.c    2007-05-12 07:34:56.000000000 +0100
@@ -53,6 +53,9 @@
 /* Look up MSGID in the current default message catalog for the current
    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
    text).  */
+#ifdef HAVE_VISIBILITY_ATTRIBUTE
+__attribute__ ((visibility ("default")))
+#endif
 char *
 NGETTEXT (const char *msgid1, const char *msgid2, unsigned long int n)
 {
diff -u intl/printf-args.c ../extra/intl/printf-args.c
--- intl/printf-args.c  2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/printf-args.c 2007-05-12 06:30:01.000000000 +0100
@@ -16,7 +16,9 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
    USA.  */
 
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
 
 /* Specification.  */
 #include "printf-args.h"
diff -u intl/printf-parse.c ../extra/intl/printf-parse.c
--- intl/printf-parse.c 2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/printf-parse.c    2007-05-12 06:29:52.000000000 +0100
@@ -16,7 +16,9 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
    USA.  */
 
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
 
 /* Specification.  */
 #if WIDE_CHAR_VERSION
diff -u intl/vasnprintf.c ../extra/intl/vasnprintf.c
--- intl/vasnprintf.c   2006-11-27 17:02:00.000000000 +0000
+++ ../extra/intl/vasnprintf.c  2007-05-12 06:30:18.000000000 +0100
@@ -23,7 +23,9 @@
 # define _GNU_SOURCE    1
 #endif
 
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
 #ifndef IN_LIBINTL
 # include <alloca.h>
 #endif