[3/3] gdi32: Return the correct value from GetTextFace.

Alexandre Julliard julliard at winehq.org
Sat Jun 21 04:35:43 CDT 2008


Dan Hipschman <dsh at linux.ucla.edu> writes:

>  INT WINAPI GetTextFaceA( HDC hdc, INT count, LPSTR name )
>  {
> -    INT res = GetTextFaceW(hdc, 0, NULL);
> -    LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, res * 2 );
> -    GetTextFaceW( hdc, res, nameW );
> -
>      if (name)
>      {
> -        if (count && !WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count, NULL, NULL))
> +        LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, count * sizeof nameW[0] );
> +        INT res = GetTextFaceW( hdc, count, nameW );
> +        if (count && res)
> +        {
> +            WideCharToMultiByte( CP_ACP, 0, nameW, -1, name, count, NULL, NULL);
>              name[count-1] = 0;
> -        res = strlen(name);
> +        }
> +        HeapFree( GetProcessHeap(), 0, nameW );
> +        /* GetTextFaceA does NOT include the nul byte in the return count.  */
> +        return res ? res - 1 : 0;
>      }
>      else
> -        res = WideCharToMultiByte( CP_ACP, 0, nameW, -1, NULL, 0, NULL, NULL);
> -    HeapFree( GetProcessHeap(), 0, nameW );
> -    return res;
> +        return GetTextFaceW(hdc, 0, NULL);
>  }

This is wrong, you can't return the W length from the A function.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list