Fix wgetnstr with PDC_WIDE

Casting an array of wchar_t to wint_t * works as intended only if
wchar_t and wint_t have the same size. If they don't, wgetnstr will
not work. Cast the elements to wchar_t instead.
This commit is contained in:
Ray Chason
2022-09-27 22:58:37 -04:00
parent 2fa0f10dd8
commit 41707e0202

View File

@@ -72,12 +72,17 @@ int wgetnstr(WINDOW *win, char *str, int n)
{
#ifdef PDC_WIDE
wchar_t wstr[MAXLINE + 1];
wint_t wintstr[MAXLINE + 1];
int i;
if (n < 0 || n > MAXLINE)
n = MAXLINE;
if (wgetn_wstr(win, (wint_t *)wstr, n) == ERR)
if (wgetn_wstr(win, wintstr, n) == ERR)
return ERR;
for (i = 0; i < n; ++i) {
wstr[i] = (wchar_t)wintstr[i];
}
return PDC_wcstombs(str, wstr, n);
#else