[PATCH 1/3] [cmd] Convert the set /a tests to validate better

Frédéric Delanoy frederic.delanoy at gmail.com
Thu Dec 13 20:01:43 CST 2012


On Fri, Dec 14, 2012 at 2:59 AM, Frédéric Delanoy
<frederic.delanoy at gmail.com> wrote:
> On Thu, Dec 13, 2012 at 10:59 PM, Ann and Jason Edmeades
> <jason at edmeades.me.uk> wrote:
>> The tests previously set a variable which was not checked until
>> the subsequent test completed (as env vars are expanded as the
>> line is read, meaning a sequence of set /a var=x & echo %var%
>> echos the contents before the set is executed). In addition when
>> multiple variables are involved in the calculation, only the
>> first one was being checked, and this is changed to check all
>> variables involved in the calculation.
>>
> +
> +REM Check the variables are set to the expected value and clear their contents
> +:check_vars
> +if not "%1"=="" (
> +  if "%1"=="%WINE_var1%" (
> +    echo WINE_var1 correctly %1
> +  ) else (
> +    echo ERROR: WINE_var1 incorrectly %WINE_var1% [%1]
> +  )
> +)
> +if not "%2"=="" (
> +  if "%2"=="%WINE_var2%" (
> +    echo WINE_var2 correctly %2
> +  ) else (
> +    echo ERROR: WINE_var2 incorrectly %WINE_var2% [%2]
> +  )
> +)
> +if not "%3"=="" (
> +  if "%3"=="%WINE_var3%" (
> +    echo WINE_var3 correctly %1
> +  ) else (
> +    echo ERROR: WINE_var3 incorrectly %WINE_var3% [%3]
> +  )
> +)
>
> A couple comments:
>
> 1. I don't really like hardcoding a variable name in a function... Why
> not using something like:
> set /a var=1 +2 & call :compute var
> set /a foo=8, bar=foo+1 & call :compute foo bar
>
> goto :end
> :compute

Note "compute" is probably a bad name, "display" might be better to
describe the purpose of the routine.

Frédéric



More information about the wine-devel mailing list