From: Tim Kientzle Date: Mon, 29 Dec 2008 00:24:22 +0000 (-0500) Subject: Use MultiByteToWideChar() on Windows instead of mbstowcs(). X-Git-Tag: v2.7.0~539 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6ca04e2f6a25d17f7f6d224c7b70c1ca74bc9fd;p=thirdparty%2Flibarchive.git Use MultiByteToWideChar() on Windows instead of mbstowcs(). I'm not yet convinced about this approach. Microsoft documents mbstowcs(); I'd prefer to avoid platform conditionals. Submitted by: Michihiro NAKAJIMA SVN-Revision: 301 --- diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c index d7aadd799..439112982 100644 --- a/libarchive/archive_entry.c +++ b/libarchive/archive_entry.c @@ -62,6 +62,9 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.55 2008/12/23 05:01:4 #ifdef HAVE_WCHAR_H #include #endif +#ifdef _WIN32 +#include +#endif #include "archive.h" #include "archive_entry.h" @@ -227,9 +230,15 @@ aes_get_wcs(struct aes *aes) w = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t)); if (w == NULL) __archive_errx(1, "No memory for aes_get_wcs()"); +#ifndef _WIN32 r = mbstowcs(w, aes->aes_mbs.s, wcs_length); - w[wcs_length] = 0; +#else + r = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, + aes->aes_mbs.s, (int)aes->aes_mbs.length, w, + (int)wcs_length); +#endif if (r > 0) { + w[r] = 0; aes->aes_set |= AES_SET_WCS; return (aes->aes_wcs = w); }