lynx-dev
[Top][All Lists]
Advanced

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

[Lynx-dev] lynx iconv for Solaris


From: Takao Fujiwara - Tokyo S/W Center
Subject: [Lynx-dev] lynx iconv for Solaris
Date: Tue, 23 Dec 2008 01:11:43 +0900
User-agent: Thunderbird 2.0.0.12 (X11/20080326)

Hi,

I'm attaching the patch to work Solaris iconv with lynx.

Solaris iconv is implemented in libc so I modified CF_ARG_ENABLE(japanese-utf8) 
in configure.in however autoconf doesn't work. AC_DEFINE() needs three
arguments to work autoconf.

To support the return values of nl_langinfo() on Solaris, I added several 
encodings in UCGetLYhndl_byMIME().

--- lynx2-8-6/configure.in.orig 2008-12-22 10:30:12.393958000 +0900
+++ lynx2-8-6/configure.in      2008-12-22 13:30:27.155245000 +0900
@@ -725,7 +725,14 @@ CF_ARG_ENABLE(japanese-utf8,
 AC_MSG_RESULT($use_ja_utf8)
 if test $use_ja_utf8 != no ; then
        AC_DEFINE(EXP_JAPANESEUTF8_SUPPORT)
+       case $ac_cv_target in
+       *solaris*)
+       AC_CHECK_FUNCS( iconv_open )
+       ;;
+       *)
        AC_CHECK_LIB(iconv,libiconv_open)
+       ;;
+       esac
 fi
 
 AC_MSG_CHECKING(if color-style code should be used)
--- lynx2-8-6/configure.orig    2008-12-22 10:30:23.379499000 +0900
+++ lynx2-8-6/configure 2008-12-22 13:31:04.883234000 +0900
@@ -5661,7 +5661,7 @@ fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
     if test "$am_cv_func_iconv" != yes; then
       am_save_LIBS="$LIBS"
-      LIBS="$LIBS -liconv"
+      LIBS="$LIBS"
       cat >conftest.$ac_ext <<_ACEOF
 #line 5666 "configure"
 #include "confdefs.h"
@@ -18564,7 +18564,7 @@ if test "${ac_cv_lib_iconv_libiconv_open
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-liconv  $LIBS"
+LIBS="$LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 #line 18569 "configure"
 #include "confdefs.h"
@@ -18575,11 +18575,11 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char libiconv_open ();
+char iconv_open ();
 int
 main ()
 {
-libiconv_open ();
+iconv_open ();
   ;
   return 0;
 }
@@ -18612,7 +18612,7 @@ if test $ac_cv_lib_iconv_libiconv_open =
 #define HAVE_LIBICONV 1
 EOF
 
-  LIBS="-liconv $LIBS"
+  LIBS="$LIBS"
 
 fi
 
--- lynx2-8-6/src/UCdomap.c.orig        2008-12-22 10:38:58.096800000 +0900
+++ lynx2-8-6/src/UCdomap.c     2008-12-22 20:19:57.052909000 +0900
@@ -936,8 +936,8 @@ int UCTransUniCharStr(char *outbuf,
     }
     if (isdefault || trydefault) {
 #ifdef EXP_JAPANESEUTF8_SUPPORT
-       if ((strcmp(LYCharSet_UC[charset_out].MIMEname, "shift_jis") == 0) ||
-           (strcmp(LYCharSet_UC[charset_out].MIMEname, "euc-jp") == 0)) {
+       if (LYCharSet_UC[charset_out].codepage == 0 &&
+           LYCharSet_UC[charset_out].codepoints == 0) {
            iconv_t cd;
            char str[3], *pin, *pout;
            size_t inleft, outleft;
@@ -952,6 +952,20 @@ int UCTransUniCharStr(char *outbuf,
            HTSprintf0(&tocode, "%s//TRANSLIT", 
LYCharSet_UC[charset_out].MIMEname);
            cd = iconv_open(tocode, "UTF-16BE");
            FREE(tocode)
+           if (cd == (iconv_t)-1) {
+               HTSprintf0(&tocode, "%s", LYCharSet_UC[charset_out].MIMEname);
+               cd = iconv_open(tocode, "UTF-16BE");
+
+               if (cd == (iconv_t)-1) {
+                   CTRACE((tfp,
+                       "Warning: Cannot transcode form charset %s to %s!\n",
+                       "UTF-16BE", tocode));
+                   FREE(tocode);
+                   goto DEFAULT_CONVERSION;
+               }
+
+               FREE(tocode);
+           }
                rc = iconv(cd, &pin, &inleft, &pout, &outleft);
            iconv_close(cd);
            if ((pout - outbuf) == 3) {
@@ -965,6 +979,7 @@ int UCTransUniCharStr(char *outbuf,
                return (strlen(outbuf));
            }
        }
+DEFAULT_CONVERSION:
 #endif
        rc = conv_uni_to_str(outbuf, buflen, unicode, 1);
        if (rc >= 0)
@@ -1484,14 +1499,19 @@ int UCGetLYhndl_byMIME(const char *value
        return UCGetLYhndl_byMIME("utf-8");
     }
 #endif
+    if (!strncasecomp(value, "iso", 3) && !strncmp (value + 3, "8859", 4)) {
+       return getLYhndl_byCP("iso-", value + 3);
+    }
 #if !NO_CHARSET_euc_jp
-    if (!strcasecomp(value, "x-euc-jp")) {
+    if (!strcasecomp(value, "x-euc-jp") ||
+        !strcasecomp(value, "eucjp")) {
        return UCGetLYhndl_byMIME("euc-jp");
     }
 #endif
 #if !NO_CHARSET_shift_jis
     if ((!strcasecomp(value, "x-shift-jis")) ||
-       (!strcasecomp(value, "x-sjis"))) {
+       (!strcasecomp(value, "x-sjis")) ||
+       (!strcasecomp(value, "pck"))) {
        return UCGetLYhndl_byMIME("shift_jis");
     }
 #endif
@@ -1538,6 +1558,11 @@ int UCGetLYhndl_byMIME(const char *value
        return UCGetLYhndl_byMIME("windows-1252");
     }
 #endif
+#if !NO_CHARSET_windows_1251
+    if (!strcasecomp(value, "ansi-1251")) {
+       return UCGetLYhndl_byMIME("windows-1251");
+    }
+#endif
 #if !NO_CHARSET_windows_1250
     if (!strcasecomp(value, "iso-8859-2-windows-latin-2") ||
        !strcasecomp(value, "cp1250") ||

reply via email to

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