Hin-Tak Leung <htl10(a)users.sourceforge.net> writes:
> This is the fix to bug 8246 to get HtmlHelpW to work correctly.
> It was first worked on by Andrey Turkin and updated later by me.
Please add a proper log entry describing the change.
> -static inline LPWSTR strdupAtoW(LPCSTR str)
> +static inline LPWSTR strdupnAtoW(LPCSTR str, LONG l)
> {
> LPWSTR ret;
> DWORD len;
> + BOOL zero_pad;
>
> if(!str)
> return NULL;
>
> - len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
> + if (l>0)
> + {
> + LONG i;
> + zero_pad = TRUE;
> + for (i=0;i<l;i++)
> + {
> + if (!str[i])
> + {
> + zero_pad = FALSE;
> + l = i+1;
> + break;
> + }
> + }
> + } else {
> + zero_pad = FALSE;
> + }
> +
> + len = MultiByteToWideChar(CP_ACP, 0, str, l, NULL, 0);
> + if (zero_pad)
> + len++;
This is ugly and unnecessary, MultiByteToWideChar handles embedded nulls
just fine.
--
Alexandre Julliard
julliard(a)winehq.org