X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fwidechar%2Fwidechars.c;h=d05ba98a8265fa5ad53d852f159ccc9488017034;hp=c86b8a0660597fa037edbc4088700e8fd312f387;hb=f67a188e71a0e6f80c1c45e50e7a7449c2d7bfb3;hpb=286b1e1135a99a4dd5844e5d45af42098155fab5 diff --git a/ncurses/widechar/widechars.c b/ncurses/widechar/widechars.c index c86b8a06..d05ba98a 100644 --- a/ncurses/widechar/widechars.c +++ b/ncurses/widechar/widechars.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2012 Free Software Foundation, Inc. * + * Copyright 2018,2020 Thomas E. Dickey * + * Copyright 2012,2013 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -30,9 +31,9 @@ #if USE_WIDEC_SUPPORT -MODULE_ID("$Id: widechars.c,v 1.4 2012/12/02 01:50:59 tom Exp $") +MODULE_ID("$Id: widechars.c,v 1.9 2020/08/29 16:22:03 juergen Exp $") -#if defined(__MINGW32__) +#if (defined(_NC_WINDOWS)) && !defined(_NC_MSC) /* * MinGW has wide-character functions, but they do not work correctly. */ @@ -46,9 +47,9 @@ _nc_mbtowc(wchar_t *pwc, const char *s, size_t n) if (s != 0 && n != 0) { /* - * MultiByteToWideChar() can decide to return more than one wide-character. - * We want only one. Ignore any trailing null, both in the initial count - * and in the conversion. + * MultiByteToWideChar() can decide to return more than one + * wide-character. We want only one. Ignore any trailing null, both + * in the initial count and in the conversion. */ count = 0; for (try = 1; try <= (int) n; ++try) { @@ -67,6 +68,7 @@ _nc_mbtowc(wchar_t *pwc, const char *s, size_t n) result = -1; } else { wchar_t actual[2]; + memset(&actual, 0, sizeof(actual)); count = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s, @@ -146,6 +148,6 @@ _nc_wctomb(char *s, wchar_t wc) return result; } -#endif /* __MINGW32__ */ +#endif /* _NC_WINDOWS */ #endif /* USE_WIDEC_SUPPORT */