Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit a24d45f

Browse files
committed
Merge branch '3972_fix_illumos'
Signed-off-by: Yury V. Zaytsev <[email protected]>
2 parents 6dd05af + 8f723b8 commit a24d45f

File tree

24 files changed

+204
-152
lines changed

24 files changed

+204
-152
lines changed

autogen.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ cd "$srcdir"
1111
${AUTORECONF:-autoreconf} --verbose --install --force -I m4 ${AUTORECONF_FLAGS}
1212

1313
# Customize the INSTALL file
14-
rm -f INSTALL && ln -s doc/INSTALL
14+
rm -f INSTALL && ln -s doc/INSTALL .
1515

1616
# Generate po/POTFILES.in
17-
${XGETTEXT:-xgettext} --keyword=_ --keyword=N_ --keyword=Q_ --output=- \
17+
if ! xgettext -h 2>&1 | grep -e '--keyword=' >/dev/null ; then
18+
echo "gettext is unable to extract translations, set XGETTEXT to GNU gettext!" >&2
19+
else
20+
${XGETTEXT:-xgettext} --keyword=_ --keyword=N_ --keyword=Q_ --output=- \
1821
`find . -name '*.[ch]'` | ${SED-sed} -ne '/^#:/{s/#://;s/:[0-9]*/\
1922
/g;s/ //g;p;}' | \
2023
grep -v '^$' | sort | uniq >po/POTFILES.in
24+
fi
2125

22-
$srcdir/version.sh "$srcdir"
26+
"$srcdir/version.sh" "$srcdir"
2327

24-
if test -x $srcdir/configure.mc; then
25-
$srcdir/configure.mc "$@"
28+
if test -x "$srcdir/configure.mc"; then
29+
"$srcdir/configure.mc" "$@"
2630
fi

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ tests/lib/mcconfig/Makefile
705705
tests/lib/search/Makefile
706706
tests/lib/strutil/Makefile
707707
tests/lib/vfs/Makefile
708+
tests/lib/vfs/mc.charsets
708709
tests/lib/widget/Makefile
709710
tests/src/Makefile
710711
tests/src/filemanager/Makefile

lib/charsets.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,16 @@ get_codepage_index (const char *id)
267267
gboolean
268268
is_supported_encoding (const char *encoding)
269269
{
270-
gboolean result = FALSE;
271-
guint t;
270+
GIConv coder;
271+
gboolean result;
272272

273-
for (t = 0; t < codepages->len; t++)
274-
{
275-
const char *id;
276-
277-
id = ((codepage_desc *) g_ptr_array_index (codepages, t))->id;
278-
result |= (g_ascii_strncasecmp (encoding, id, strlen (id)) == 0);
279-
}
273+
if (encoding == NULL)
274+
return FALSE;
280275

276+
coder = str_crt_conv_from (encoding);
277+
result = coder != INVALID_CONV;
278+
if (result)
279+
str_close_conv (coder);
281280
return result;
282281
}
283282

@@ -364,6 +363,8 @@ str_nconvert_to_display (const char *str, int len)
364363
return g_string_new (str);
365364

366365
conv = str_crt_conv_from (cp_source);
366+
if (conv == INVALID_CONV)
367+
return g_string_new (str);
367368

368369
buff = g_string_new ("");
369370
str_nconvert (conv, str, len, buff);
@@ -396,6 +397,8 @@ str_nconvert_to_input (const char *str, int len)
396397
return g_string_new (str);
397398

398399
conv = str_crt_conv_to (cp_source);
400+
if (conv == INVALID_CONV)
401+
return g_string_new (str);
399402

400403
buff = g_string_new ("");
401404
str_nconvert (conv, str, len, buff);

lib/strutil/strutil.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,16 @@ static const char *const str_utf8_encodings[] = {
5757

5858
/* standard 8bit encodings, no wide or multibytes characters */
5959
static const char *const str_8bit_encodings[] = {
60-
/* Solaris has different names of Windows 1251 encoding */
61-
#ifdef __sun
62-
"ansi-1251",
63-
"ansi1251",
64-
#else
6560
"cp-1251",
6661
"cp1251",
67-
#endif
62+
/* solaris */
63+
"ansi-1251",
64+
"ansi1251",
6865
"cp-1250",
6966
"cp1250",
7067
"cp-866",
7168
"cp866",
69+
/* glibc */
7270
"ibm-866",
7371
"ibm866",
7472
"cp-850",
@@ -274,7 +272,7 @@ str_crt_conv_from (const char *from_enc)
274272
void
275273
str_close_conv (GIConv conv)
276274
{
277-
if (conv != str_cnv_not_convert)
275+
if (conv != INVALID_CONV && conv != str_cnv_not_convert)
278276
g_iconv_close (conv);
279277
}
280278

lib/utilunix.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,20 @@ canonicalize_pathname_custom (char *path, canon_path_flags_t flags)
920920
{
921921
/* "token/../foo" -> "foo" */
922922
#ifdef HAVE_CHARSET
923-
if ((strncmp (s, VFS_ENCODING_PREFIX, enc_prefix_len) == 0)
924-
&& (is_supported_encoding (s + enc_prefix_len)))
925-
/* special case: remove encoding */
926-
str_move (s, p + 1);
923+
if (strncmp (s, VFS_ENCODING_PREFIX, enc_prefix_len) == 0)
924+
{
925+
char *enc;
926+
927+
enc = vfs_get_encoding (s, -1);
928+
929+
if (is_supported_encoding (enc))
930+
/* special case: remove encoding */
931+
str_move (s, p + 1);
932+
else
933+
str_move (s, p + 4);
934+
935+
g_free (enc);
936+
}
927937
else
928938
#endif /* HAVE_CHARSET */
929939
str_move (s, p + 4);
@@ -947,9 +957,18 @@ canonicalize_pathname_custom (char *path, canon_path_flags_t flags)
947957
if (s == lpath + 1)
948958
s[0] = '\0';
949959
#ifdef HAVE_CHARSET
950-
else if ((strncmp (s, VFS_ENCODING_PREFIX, enc_prefix_len) == 0)
951-
&& (is_supported_encoding (s + enc_prefix_len)))
960+
else if (strncmp (s, VFS_ENCODING_PREFIX, enc_prefix_len) == 0)
952961
{
962+
char *enc;
963+
gboolean ok;
964+
965+
enc = vfs_get_encoding (s, -1);
966+
ok = is_supported_encoding (enc);
967+
g_free (enc);
968+
969+
if (!ok)
970+
goto last;
971+
953972
/* special case: remove encoding */
954973
s[0] = '.';
955974
s[1] = '.';
@@ -966,6 +985,7 @@ canonicalize_pathname_custom (char *path, canon_path_flags_t flags)
966985
#endif /* HAVE_CHARSET */
967986
else
968987
{
988+
last:
969989
if (s >= lpath + url_delim_len
970990
&& strncmp (s - url_delim_len, VFS_PATH_URL_DELIMITER, url_delim_len) == 0)
971991
*s = '\0';

lib/vfs/path.c

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -182,42 +182,6 @@ vfs_canon (const char *path)
182182
return result;
183183
}
184184

185-
/* --------------------------------------------------------------------------------------------- */
186-
187-
#ifdef HAVE_CHARSET
188-
/** get encoding after last #enc: or NULL, if part does not contain #enc:
189-
*
190-
* @param path null-terminated string
191-
* @param len the maximum length of path, where #enc: should be searched
192-
*
193-
* @return newly allocated string.
194-
*/
195-
196-
static char *
197-
vfs_get_encoding (const char *path, ssize_t len)
198-
{
199-
char *semi;
200-
201-
/* try found #enc: */
202-
semi = g_strrstr_len (path, len, VFS_ENCODING_PREFIX);
203-
if (semi == NULL)
204-
return NULL;
205-
206-
if (semi == path || IS_PATH_SEP (semi[-1]))
207-
{
208-
char *slash;
209-
210-
semi += strlen (VFS_ENCODING_PREFIX); /* skip "#enc:" */
211-
slash = strchr (semi, PATH_SEP);
212-
if (slash != NULL)
213-
return g_strndup (semi, slash - semi);
214-
return g_strdup (semi);
215-
}
216-
217-
return vfs_get_encoding (path, semi - path);
218-
}
219-
#endif
220-
221185
/* --------------------------------------------------------------------------------------------- */
222186
/** Extract the hostname and username from the path
223187
*
@@ -896,8 +860,8 @@ vfs_path_element_clone (const vfs_path_element_t *element)
896860
new_element->vfs_prefix = g_strdup (element->vfs_prefix);
897861
#ifdef HAVE_CHARSET
898862
new_element->encoding = g_strdup (element->encoding);
899-
if (vfs_path_element_need_cleanup_converter (element) && new_element->encoding != NULL)
900-
new_element->dir.converter = str_crt_conv_from (new_element->encoding);
863+
if (vfs_path_element_need_cleanup_converter (element) && element->encoding != NULL)
864+
new_element->dir.converter = str_crt_conv_from (element->encoding);
901865
else
902866
new_element->dir.converter = element->dir.converter;
903867
#endif
@@ -1071,6 +1035,39 @@ vfs_prefix_to_class (const char *prefix)
10711035

10721036
#ifdef HAVE_CHARSET
10731037

1038+
/** get encoding after last #enc: or NULL, if part does not contain #enc:
1039+
*
1040+
* @param path null-terminated string
1041+
* @param len the maximum length of path, where #enc: should be searched
1042+
*
1043+
* @return newly allocated string.
1044+
*/
1045+
1046+
char *
1047+
vfs_get_encoding (const char *path, ssize_t len)
1048+
{
1049+
char *semi;
1050+
1051+
/* try found #enc: */
1052+
semi = g_strrstr_len (path, len, VFS_ENCODING_PREFIX);
1053+
if (semi == NULL)
1054+
return NULL;
1055+
1056+
if (semi == path || IS_PATH_SEP (semi[-1]))
1057+
{
1058+
char *slash;
1059+
1060+
semi += strlen (VFS_ENCODING_PREFIX); /* skip "#enc:" */
1061+
slash = strchr (semi, PATH_SEP);
1062+
if (slash != NULL)
1063+
return g_strndup (semi, slash - semi);
1064+
return g_strdup (semi);
1065+
}
1066+
1067+
return vfs_get_encoding (path, semi - path);
1068+
}
1069+
1070+
/* --------------------------------------------------------------------------------------------- */
10741071
/**
10751072
* Check if need cleanup charset converter for vfs_path_element_t
10761073
*

lib/vfs/path.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ void vfs_path_element_free (vfs_path_element_t * element);
8282
struct vfs_class *vfs_prefix_to_class (const char *prefix);
8383

8484
#ifdef HAVE_CHARSET
85+
char *vfs_get_encoding(const char *path, ssize_t len);
8586
gboolean vfs_path_element_need_cleanup_converter (const vfs_path_element_t * element);
8687
vfs_path_t *vfs_path_change_encoding (vfs_path_t * vpath, const char *encoding);
8788
#endif

m4.include/mc-i18n.m4

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,27 @@ AC_DEFUN([mc_I18N],[
1818
have_charset=yes
1919
charset_msg="yes"
2020
21+
AC_CHECK_HEADERS([gnu/libc-version.h])
22+
2123
dnl Solaris has different name of Windows 1251 encoding
2224
case $host_os in
2325
solaris*)
24-
CP1251="ANSI-1251"
26+
ENCODING_CP1251="ANSI-1251"
2527
;;
2628
*)
27-
CP1251="CP1251"
29+
ENCODING_CP1251="CP1251"
2830
;;
2931
esac
3032
31-
AC_SUBST(CP1251)
33+
if test "x$ac_cv_header_gnu_libc_version_h" != "xno"; then
34+
ENCODING_CP866="IBM866"
35+
ENCODING_ISO8859="ISO-8859"
36+
else
37+
ENCODING_CP866="CP866"
38+
ENCODING_ISO8859="ISO8859"
39+
fi
40+
41+
AC_SUBST(ENCODING_CP1251)
42+
AC_SUBST(ENCODING_CP866)
3243
fi
3344
])

misc/mc.charsets.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ASCII 7-bit ASCII
2-
ISO-8859-1 ISO 8859-1
3-
ISO-8859-2 ISO 8859-2
4-
ISO-8859-5 ISO 8859-5
2+
@ENCODING_ISO8859@-1 ISO 8859-1
3+
@ENCODING_ISO8859@-2 ISO 8859-2
4+
@ENCODING_ISO8859@-5 ISO 8859-5
55
CP1250 Windows 1250
6-
@CP1251@ Windows 1251
6+
@ENCODING_CP1251@ Windows 1251
77
CP437 CP 437
88
CP850 CP 850
99
CP852 CP 852
10-
IBM866 CP 866
10+
@ENCODING_CP866@ CP 866
1111
KOI8-R KOI8-R
1212
KOI8-U KOI8-U
1313
UTF-8 UTF-8

src/diffviewer/ydiff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ dview_get_utf (const char *str, int *ch, int *ch_length)
607607
}
608608
else
609609
{
610-
char *next_ch;
610+
const char *next_ch;
611611

612612
/* Calculate UTF-8 char length */
613613
next_ch = g_utf8_next_char (str);

0 commit comments

Comments
 (0)