diff -urN tcsh-6.13.00/config.h.in tcsh/config.h.in --- tcsh-6.13.00/config.h.in 1999-05-11 15:22:46.000000000 +0200 +++ tcsh/config.h.in 2004-07-16 19:49:55.000000000 +0200 @@ -1 +1,19 @@ -/* config.h.in. Generated automatically from configure.in by autoheader. */ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the iconv () interface */ +#undef HAVE_ICONV + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION diff -urN tcsh-6.13.00/configure.in tcsh/configure.in --- tcsh-6.13.00/configure.in 2003-03-12 20:14:50.000000000 +0100 +++ tcsh/configure.in 2004-07-17 01:54:18.474111752 +0200 @@ -261,6 +261,8 @@ AC_SEARCH_LIBS(tgetent, termlib curses termcap) AC_SEARCH_LIBS(gethostbyname, nsl) AC_SEARCH_LIBS(connect, socket) +AC_SEARCH_LIBS([iconv], [iconv], [AC_DEFINE([HAVE_ICONV], [1], + [Define to 1 if you have the iconv () interface])]) dnl This is not good enough; we need sockaddr_storage too. dnl See whether we can use IPv6 related functions diff -urN tcsh-6.13.00/nls/C/charset tcsh/nls/C/charset --- tcsh-6.13.00/nls/C/charset 2004-02-23 16:04:08.000000000 +0100 +++ tcsh/nls/C/charset 2004-07-17 02:16:24.186572824 +0200 @@ -1 +1,3 @@ $ codeset=US-ASCII +$set 255 +1 US-ASCII diff -urN tcsh-6.13.00/nls/et/charset tcsh/nls/et/charset --- tcsh-6.13.00/nls/et/charset 2004-02-23 16:04:08.000000000 +0100 +++ tcsh/nls/et/charset 2004-07-17 02:16:27.741032464 +0200 @@ -1 +1,3 @@ $ codeset=ISO-8859-1 +$set 255 +1 ISO-8859-1 diff -urN tcsh-6.13.00/nls/finnish/charset tcsh/nls/finnish/charset --- tcsh-6.13.00/nls/finnish/charset 2004-02-23 16:04:09.000000000 +0100 +++ tcsh/nls/finnish/charset 2004-07-17 02:16:34.898944296 +0200 @@ -1 +1,3 @@ $ codeset=ISO-8859-1 +$set 255 +1 ISO-8859-1 diff -urN tcsh-6.13.00/nls/french/charset tcsh/nls/french/charset --- tcsh-6.13.00/nls/french/charset 2004-02-23 16:04:09.000000000 +0100 +++ tcsh/nls/french/charset 2004-07-17 02:16:39.592230808 +0200 @@ -1 +1,3 @@ $ codeset=ISO-8859-1 +$set 255 +1 ISO-8859-1 diff -urN tcsh-6.13.00/nls/german/charset tcsh/nls/german/charset --- tcsh-6.13.00/nls/german/charset 2004-02-23 16:04:09.000000000 +0100 +++ tcsh/nls/german/charset 2004-07-17 02:16:40.647070448 +0200 @@ -1 +1,3 @@ $ codeset=ISO-8859-1 +$set 255 +1 ISO-8859-1 diff -urN tcsh-6.13.00/nls/greek/charset tcsh/nls/greek/charset --- tcsh-6.13.00/nls/greek/charset 2004-02-23 16:04:09.000000000 +0100 +++ tcsh/nls/greek/charset 2004-07-17 02:16:41.545933800 +0200 @@ -1 +1,3 @@ $ codeset=ISO-8859-7 +$set 255 +1 ISO-8859-7 diff -urN tcsh-6.13.00/nls/italian/charset tcsh/nls/italian/charset --- tcsh-6.13.00/nls/italian/charset 2004-02-23 16:04:09.000000000 +0100 +++ tcsh/nls/italian/charset 2004-07-17 02:16:42.464794112 +0200 @@ -1 +1,3 @@ $ codeset=ISO-8859-1 +$set 255 +1 ISO-8859-1 diff -urN tcsh-6.13.00/nls/ja/charset tcsh/nls/ja/charset --- tcsh-6.13.00/nls/ja/charset 2004-02-23 16:04:10.000000000 +0100 +++ tcsh/nls/ja/charset 2004-07-17 02:16:43.342660656 +0200 @@ -1 +1,3 @@ $ codeset=EUC-JP +$set 255 +1 EUC-JP diff -urN tcsh-6.13.00/nls/Makefile tcsh/nls/Makefile --- tcsh-6.13.00/nls/Makefile 2004-02-21 21:34:26.000000000 +0100 +++ tcsh/nls/Makefile 2004-07-16 19:09:58.000000000 +0200 @@ -2,7 +2,7 @@ SUBDIRS= C et finnish french german greek italian ja pl russian \ spanish ukrainian #GENCAT= gencat --new -#CHARSET= charset +CHARSET= charset GENCAT= gencat catalogs: diff -urN tcsh-6.13.00/nls/pl/charset tcsh/nls/pl/charset --- tcsh-6.13.00/nls/pl/charset 2004-02-23 16:04:10.000000000 +0100 +++ tcsh/nls/pl/charset 2004-07-17 02:16:44.124541792 +0200 @@ -1 +1,3 @@ $ codeset=ISO-8859-2 +$set 255 +1 ISO-8859-2 diff -urN tcsh-6.13.00/nls/russian/charset tcsh/nls/russian/charset --- tcsh-6.13.00/nls/russian/charset 2004-02-23 16:04:10.000000000 +0100 +++ tcsh/nls/russian/charset 2004-07-17 02:16:44.827434936 +0200 @@ -1 +1,3 @@ $ codeset=KOI8-R +$set 255 +1 KOI8-R diff -urN tcsh-6.13.00/nls/spanish/charset tcsh/nls/spanish/charset --- tcsh-6.13.00/nls/spanish/charset 2004-02-23 16:04:10.000000000 +0100 +++ tcsh/nls/spanish/charset 2004-07-17 02:16:45.685304520 +0200 @@ -1 +1,3 @@ $ codeset=ISO-8859-1 +$set 255 +1 ISO-8859-1 diff -urN tcsh-6.13.00/nls/ukrainian/charset tcsh/nls/ukrainian/charset --- tcsh-6.13.00/nls/ukrainian/charset 2004-02-23 16:04:11.000000000 +0100 +++ tcsh/nls/ukrainian/charset 2004-07-17 02:16:46.448188544 +0200 @@ -1 +1,3 @@ $ codeset=KOI8-U +$set 255 +1 KOI8-U diff -urN tcsh-6.13.00/sh.c tcsh/sh.c --- tcsh-6.13.00/sh.c 2004-02-21 21:34:24.000000000 +0100 +++ tcsh/sh.c 2004-07-17 02:29:55.143288664 +0200 @@ -2387,7 +2387,7 @@ { #ifdef NLS_BUGS #ifdef NLS_CATALOGS - (void)catclose(catd); + nlsclose(); #endif /* NLS_CATALOGS */ #endif /* NLS_BUGS */ @@ -2462,7 +2462,7 @@ * because messages will stop working on the parent too. */ if (child == 0) - (void) catclose(catd); + nlsclose(); #endif /* NLS_CATALOGS */ #ifdef WINNT_NATIVE nt_cleanup(); diff -urN tcsh-6.13.00/sh.decls.h tcsh/sh.decls.h --- tcsh-6.13.00/sh.decls.h 2004-03-21 17:48:14.000000000 +0100 +++ tcsh/sh.decls.h 2004-07-17 01:57:10.879902088 +0200 @@ -33,6 +33,11 @@ #ifndef _h_sh_decls #define _h_sh_decls +#ifdef HAVE_ICONV +#include +#include +#endif + /* * sh.c */ @@ -178,7 +183,12 @@ #if defined(FILEC) && defined(TIOCSTI) extern int sortscmp __P((Char **, Char **)); #endif + +#ifdef HAVE_ICONV +extern char *iconv_catgets __P((nl_catd, int, int, const char *)); +#endif extern void nlsinit __P((void)); +extern void nlsclose __P((void)); extern int t_pmatch __P((Char *, Char *, Char **, int)); /* diff -urN tcsh-6.13.00/sh.func.c tcsh/sh.func.c --- tcsh-6.13.00/sh.func.c 2004-05-13 17:23:39.000000000 +0200 +++ tcsh/sh.func.c 2004-07-17 02:16:08.605941440 +0200 @@ -41,6 +41,10 @@ #include "nt.const.h" #endif /* WINNT_NATIVE */ +#ifdef HAVE_ICONV +#include +#endif + /* * C shell */ @@ -1379,16 +1383,16 @@ # ifdef LC_COLLATE (void) setlocale(LC_COLLATE, ""); # endif +# ifdef LC_CTYPE + (void) setlocale(LC_CTYPE, ""); /* for iscntrl */ +# endif /* LC_CTYPE */ # ifdef NLS_CATALOGS # ifdef LC_MESSAGES (void) setlocale(LC_MESSAGES, ""); # endif /* LC_MESSAGES */ - (void) catclose(catd); + nlsclose(); nlsinit(); # endif /* NLS_CATALOGS */ -# ifdef LC_CTYPE - (void) setlocale(LC_CTYPE, ""); /* for iscntrl */ -# endif /* LC_CTYPE */ # ifdef SETLOCALEBUG dont_free = 0; # endif /* SETLOCALEBUG */ @@ -1412,7 +1416,7 @@ #ifdef NLS_CATALOGS if (eq(vp, STRNLSPATH)) { - (void) catclose(catd); + nlsclose(); nlsinit(); } #endif @@ -1571,16 +1575,16 @@ # ifdef LC_COLLATE (void) setlocale(LC_COLLATE, ""); # endif +# ifdef LC_CTYPE + (void) setlocale(LC_CTYPE, ""); /* for iscntrl */ +# endif /* LC_CTYPE */ # ifdef NLS_CATALOGS # ifdef LC_MESSAGES (void) setlocale(LC_MESSAGES, ""); # endif /* LC_MESSAGES */ - (void) catclose(catd); + nlsclose(); nlsinit(); # endif /* NLS_CATALOGS */ -# ifdef LC_CTYPE - (void) setlocale(LC_CTYPE, ""); /* for iscntrl */ -# endif /* LC_CTYPE */ # ifdef SETLOCALEBUG dont_free = 0; # endif /* SETLOCALEBUG */ @@ -1613,7 +1617,7 @@ #endif /* COLOR_LS_F */ #ifdef NLS_CATALOGS else if (eq(name, STRNLSPATH)) { - (void) catclose(catd); + nlsclose(); nlsinit(); } #endif @@ -2435,6 +2439,56 @@ flush(); } +#ifdef HAVE_ICONV +iconv_t catgets_iconv; /* Or (iconv_t)-1 */ + +char * +iconv_catgets(catd, set_id, msg_id, s) +nl_catd catd; +int set_id, msg_id; +const char *s; +{ + static char *buf; /* = NULL; */ + static size_t buf_size; /* = 0; */ + + char *orig, *src, *dest; + size_t src_size, dest_size; + + orig = catgets(catd, set_id, msg_id, s); + if (catgets_iconv == (iconv_t)-1 || orig == s) + return orig; + src = orig; + src_size = strlen (src) + 1; + dest = buf; + while (src_size != 0) { + dest_size = buf + buf_size - dest; + if (iconv(catgets_iconv, &src, &src_size, &dest, &dest_size) + == (size_t)-1) { + switch (errno) { + case E2BIG: + { + char *p; + + if (buf_size == 0) + buf_size = 32; + p = xrealloc (buf, 2 * buf_size); + if (p == NULL) + return orig; + buf_size *= 2; + dest = p + (dest - buf); + buf = p; + break; + } + + case EILSEQ: case EINVAL: default: + return orig; + } + } + } + return buf; +} +#endif + void nlsinit() { @@ -2445,6 +2499,11 @@ xsnprintf((char *)catalog, sizeof(catalog), "tcsh.%s", short2str(varval(STRcatalog))); catd = catopen(catalog, MCLoadBySet); +#ifdef HAVE_ICONV + /* catgets (), not CGETS, the charset name should be in ASCII anyway. */ + catgets_iconv = iconv_open (nl_langinfo (CODESET), + catgets(catd, 255, 1, "ASCII")); +#endif /* HAVE_ICONV */ #endif /* NLS_CATALOGS */ #ifdef WINNT_NATIVE nls_dll_init(); @@ -2455,3 +2514,15 @@ editinit(); /* init the editor messages */ terminit(); /* init the termcap messages */ } + +void +nlsclose() +{ +#ifdef HAVE_ICONV + if (catgets_iconv != (iconv_t)-1) { + iconv_close (catgets_iconv); + catgets_iconv = (iconv_t)-1; + } +#endif /* HAVE_ICONV */ + catclose(catd); +} diff -urN tcsh-6.13.00/sh.h tcsh/sh.h --- tcsh-6.13.00/sh.h 2004-02-21 21:34:25.000000000 +0100 +++ tcsh/sh.h 2004-07-17 01:50:28.439082392 +0200 @@ -35,6 +35,10 @@ #include "config.h" +#ifdef HAVE_ICONV +#include +#endif + #ifndef HAVE_QUAD #ifdef __GNUC__ #define HAVE_QUAD 1 @@ -1245,7 +1249,12 @@ # define MCLoadBySet 0 # endif EXTERN nl_catd catd; -# define CGETS(b, c, d) catgets(catd, b, c, d) +# ifdef HAVE_ICONV +EXTERN iconv_t catgets_iconv; /* Or (iconv_t)-1 */ +# define CGETS(b, c, d) iconv_catgets(catd, b, c, d) +# else +# define CGETS(b, c, d) catgets(catd, b, c, d) +# endif # define CSAVS(b, c, d) strsave(CGETS(b, c, d)) # else # define CGETS(b, c, d) d diff -urN tcsh-6.13.00/sh.misc.c tcsh/sh.misc.c --- tcsh-6.13.00/sh.misc.c 2003-03-12 20:14:51.000000000 +0100 +++ tcsh/sh.misc.c 2004-07-17 02:30:01.477325744 +0200 @@ -260,7 +260,7 @@ #ifdef NLS_BUGS #ifdef NLS_CATALOGS - (void)catclose(catd); + nlsclose(); #endif /* NLS_CATALOGS */ #endif /* NLS_BUGS */ #ifdef YPBUGS diff -urN tcsh-6.13.00/sh.set.c tcsh/sh.set.c --- tcsh-6.13.00/sh.set.c 2004-03-21 17:48:14.000000000 +0100 +++ tcsh/sh.set.c 2004-07-17 02:04:17.022118624 +0200 @@ -192,7 +192,7 @@ #endif #ifdef NLS_CATALOGS else if (eq(vp, STRcatalog)) { - (void) catclose(catd); + nlsclose(); nlsinit(); } #if defined(FILEC) && defined(TIOCSTI) @@ -779,7 +779,7 @@ update_dspmbyte_vars(); #endif #ifdef NLS_CATALOGS - (void) catclose(catd); + nlsclose(); nlsinit(); #endif /* NLS_CATALOGS */ }