Question about sc/source/core/tool/interpr2.cxx and lcl_GetArabicValue

Markus Mohrhard markus.mohrhard at googlemail.com
Sun Dec 30 09:24:24 PST 2012


Hey,

>
> Cppcheck reported this:
> [sc/source/core/tool/interpr2.cxx:2656]: (style) The scope of the variable
> 'bIsDec2' can be reduced
>
> Here are the lines:
>    2651         while( bValid && (nCharIndex < nCharCount) )
>    2652         {
>    2653             sal_uInt16 nDigit1 = 0;
>    2654             sal_uInt16 nDigit2 = 0;
>    2655             bool bIsDec1 = false;
>    2656             bool bIsDec2 = false;
>    2657             bValid = lcl_GetArabicValue( aRoman.GetChar( nCharIndex
> ), nDigit1, bIsDec1 );
>    2658             if( bValid && (nCharIndex + 1 < nCharCount) )
>    2659                 bValid = lcl_GetArabicValue( aRoman.GetChar(
> nCharIndex + 1 ), nDigit2, bIsDec2 );
>
> But in fact, on the contrary of "bIsDec1" , "bIsDec2" isn't used in the rest
> of the loop.
> So either, bIsDec2 is useless and can just be replaced by "false", or
> something is wrong here.
>

bIsDec2 can't be removed since the method requires a non const
reference. However cppcheck is right that the scope of bIsDec2 can be
reduced. You can move it into the the same scope as the call to
lcl_GetArabicValue.

Regards,
Markus


More information about the LibreOffice mailing list