From 76a5f70f5bc7d3cdfad79bec2616b886e1f32a08 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 7 Jul 2019 16:27:53 +0300 Subject: [PATCH] Ticket #3992: improve support of Windows 1251 encoding on Solaris. Signed-off-by: Andrew Borodin --- configure.ac | 1 + lib/strutil/strutil.c | 6 ++++++ m4.include/mc-i18n.m4 | 12 ++++++++++++ misc/Makefile.am | 13 ++++++------- misc/{mc.charsets => mc.charsets.in} | 2 +- 5 files changed, 26 insertions(+), 8 deletions(-) rename misc/{mc.charsets => mc.charsets.in} (89%) diff --git a/configure.ac b/configure.ac index 19d1a76be..f516048a6 100644 --- a/configure.ac +++ b/configure.ac @@ -566,6 +566,7 @@ contrib/dist/pkginfo contrib/dist/prototype misc/Makefile +misc/mc.charsets misc/mc.menu misc/mcedit.menu misc/skins/Makefile diff --git a/lib/strutil/strutil.c b/lib/strutil/strutil.c index 03702df99..fe6323721 100644 --- a/lib/strutil/strutil.c +++ b/lib/strutil/strutil.c @@ -55,8 +55,14 @@ static const char *const str_utf8_encodings[] = { /* standard 8bit encodings, no wide or multibytes characters */ static const char *const str_8bit_encodings[] = { + /* Solaris has different names of Windows 1251 encoding */ +#ifdef __sun + "ansi-1251", + "ansi1251", +#else "cp-1251", "cp1251", +#endif "cp-1250", "cp1250", "cp-866", diff --git a/m4.include/mc-i18n.m4 b/m4.include/mc-i18n.m4 index dd10d0002..724ca5d26 100644 --- a/m4.include/mc-i18n.m4 +++ b/m4.include/mc-i18n.m4 @@ -22,5 +22,17 @@ AC_DEFUN([mc_I18N],[ AC_DEFINE(HAVE_CHARSET, 1, [Define to enable charset selection and conversion]) have_charset=yes charset_msg="yes" + + dnl Solaris has different name of Windows 1251 encoding + case $host_os in + solaris*) + CP1251="ANSI-1251" + ;; + *) + CP1251="CP1251" + ;; + esac + + AC_SUBST(CP1251) fi ]) diff --git a/misc/Makefile.am b/misc/Makefile.am index 7d005b272..1a10582ed 100644 --- a/misc/Makefile.am +++ b/misc/Makefile.am @@ -8,17 +8,20 @@ noinst_DATA = xterm.ad pkgdata_DATA = \ mc.lib -if CHARSET -pkgdata_DATA += mc.charsets -endif SCRIPTS_IN = \ mc.menu.in \ mcedit.menu.in +if CHARSET +SCRIPTS_IN += mc.charsets.in +endif SCRIPTS_OUT = \ mc.menu \ mcedit.menu +if CHARSET +SCRIPTS_OUT += mc.charsets +endif LIBFILES_CONST = \ filehighlight.ini \ @@ -47,10 +50,6 @@ EXTRA_DIST = \ $(SCRIPTS_IN) \ $(noinst_DATA) \ $(pkgdata_DATA) -#if CHARSET is defined, mc.charsets is already here -if !CHARSET -EXTRA_DIST += mc.charsets -endif install-data-hook: cd $(DESTDIR)$(cfgdir) && rm -f mc.keymap && $(LN_S) mc.default.keymap mc.keymap diff --git a/misc/mc.charsets b/misc/mc.charsets.in similarity index 89% rename from misc/mc.charsets rename to misc/mc.charsets.in index 47c68ff2d..50921b033 100644 --- a/misc/mc.charsets +++ b/misc/mc.charsets.in @@ -3,7 +3,7 @@ ISO-8859-1 ISO 8859-1 ISO-8859-2 ISO 8859-2 ISO-8859-5 ISO 8859-5 CP1250 Windows 1250 -CP1251 Windows 1251 +@CP1251@ Windows 1251 CP437 CP 437 CP850 CP 850 CP852 CP 852