Skip to content

Commit 8c49866

Browse files
committed
Merge branch 'master' into release-1.11
2 parents e7c5fc4 + fc8d387 commit 8c49866

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

dsbmd.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <libusb20.h>
4444
#include <libutil.h>
4545
#include <limits.h>
46+
#include <locale.h>
4647
#include <login_cap.h>
4748
#include <paths.h>
4849
#include <pthread.h>
@@ -1634,8 +1635,10 @@ ssystem(uid_t uid, const char *cmd)
16341635
static int
16351636
set_msdosfs_locale(const char *locale, struct iovec **iov, size_t *iovlen)
16361637
{
1638+
char *prev_locale;
16371639
const char *cs;
16381640

1641+
prev_locale = setlocale(LC_CTYPE, NULL);
16391642
if (modfind("msdosfs_iconv") == -1) {
16401643
if (errno != ENOENT) {
16411644
logprint("modfind(msdosfs_iconv) failed.");
@@ -1650,17 +1653,25 @@ set_msdosfs_locale(const char *locale, struct iovec **iov, size_t *iovlen)
16501653
logprintx("Invalid locale string '%s'", locale);
16511654
return (-1);
16521655
}
1656+
if (setlocale(LC_CTYPE, locale) == NULL)
1657+
die("setlocale(%s)", locale);
16531658
locale = kiconv_quirkcs(cs + 1, KICONV_VENDOR_MICSFT);
1659+
if (kiconv_add_xlat16_cspairs(ENCODING_UNICODE, locale) != 0 &&
1660+
errno != EEXIST)
1661+
die("kiconv_add_xlat16_cspairs(ENCODING_UNICODE)");
16541662
if (kiconv_add_xlat16_cspair(locale, locale,
16551663
KICONV_FROM_UPPER | KICONV_LOWER) != 0) {
16561664
logprint("kiconv_add_xlat16_cspair()");
1665+
if (prev_locale != NULL)
1666+
setlocale(LC_CTYPE, prev_locale);
16571667
return (-1);
16581668
}
16591669
extend_iovec(iov, iovlen, "cs_win", ENCODING_UNICODE);
16601670
extend_iovec(iov, iovlen, "cs_local", locale);
16611671
extend_iovec(iov, iovlen, "cs_dos", locale);
16621672
extend_iovec(iov, iovlen, "kiconv", "");
1663-
1673+
if (prev_locale != NULL)
1674+
setlocale(LC_CTYPE, prev_locale);
16641675
return (0);
16651676
}
16661677

0 commit comments

Comments
 (0)