[PATCH] winecfg: Add trackbar to set screen resolution in graphics tab (try 2)

Alexandre Julliard julliard at winehq.org
Mon Jul 30 08:21:17 CDT 2007


Nigel Liang <ncliang at gmail.com> writes:

> +/* Utility functions to convert between WCHAR and long */
> +long wcstolong(WCHAR * wcs)
> +{
> +    int i;
> +    long lRet = 0;
> +    BOOL bNeg = FALSE;
> +
> +    for (i = 0; wcs[i] != '\0'; i++) {
> +        if (i == 0 && wcs[i] == '-') {
> +            bNeg = TRUE;
> +            continue;
> +        }
> +
> +        lRet = lRet * 10 + (wcs[i] - '0');
> +    }
> +    return (bNeg ? -lRet : lRet);
> +}
> +
> +WCHAR *longtow(long num, WCHAR *wcs)
> +{
> +    static const WCHAR str[] = { '%', 'l', 'd', 0 };
> +    wsprintfW(wcs, str, num);
> +    return wcs;
> +}

That's ugly. You should avoid using long if not really necessary,
since it doesn't have the same size in MSVC. You shouldn't name a
function wcs something since that's what wchar_t functions use. In any
case we already have atoiW for that purpose. Also I don't think
wrapping wsprintf is needed.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list