diff options
author | Karl Williamson <khw@cpan.org> | 2021-09-13 14:06:42 -0600 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-02-08 15:57:31 +0800 |
commit | 457ba501e6d4253da0c5acc6c45c96c598b3f605 (patch) | |
tree | 769af341ce78ff72c2edc7d49402a238147af1a7 /cygwin | |
parent | a435da2b160255de4884b0d007ef0d9d93ec203b (diff) | |
download | perl-457ba501e6d4253da0c5acc6c45c96c598b3f605.tar.gz |
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
Diffstat (limited to 'cygwin')
-rw-r--r-- | cygwin/cygwin.c | 17 |
1 files changed, 5 insertions, 12 deletions
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"); |