From 457ba501e6d4253da0c5acc6c45c96c598b3f605 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 13 Sep 2021 14:06:42 -0600 Subject: cygwin.c: Call wide_to_utf8() There are two places that do the same thing as wide_to_utf8(), in different ways. Use the single, common function --- cygwin/cygwin.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'cygwin') diff --git a/cygwin/cygwin.c b/cygwin/cygwin.c index da62c95162..0e4b105da4 100644 --- a/cygwin/cygwin.c +++ b/cygwin/cygwin.c @@ -317,14 +317,8 @@ XS(XS_Cygwin_win_to_posix_path) err = cygwin_conv_path(what, wpath, wbuf, newlen); wlen = newlen; } - /* utf16_to_utf8(*p, *d, bytlen, *newlen) */ - posix_path = (char *) safemalloc(wlen*3); - Perl_utf16_to_utf8(aTHX_ (U8*)&wpath, (U8*)posix_path, wlen*2, &len); - /* - wlen = wcsrtombs(NULL, (const wchar_t **)&wbuf, wlen, NULL); - posix_path = (char *) safemalloc(wlen+1); - wcsrtombs(posix_path, (const wchar_t **)&wbuf, wlen, NULL); - */ + + posix_path = wide_to_utf8(wpath); safefree(wpath); safefree(wbuf); @@ -408,10 +402,9 @@ XS(XS_Cygwin_posix_to_win_path) err = cygwin_conv_path(what, wpath, wbuf, newlen); wlen = newlen; } - /* also see utf8.c: Perl_utf16_to_utf8() or Encoding::_bytes_to_utf8(sv, "UCS-2BE"); */ - wlen = wcsrtombs(NULL, (const wchar_t **)&wbuf, wlen, NULL); - win_path = (char *) safemalloc(wlen+1); - wcsrtombs(win_path, (const wchar_t **)&wbuf, wlen, NULL); + + win_path = wide_to_utf8(wpath); + if (oldlocale) setlocale(LC_CTYPE, oldlocale); else setlocale(LC_CTYPE, "C"); -- cgit v1.2.1