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

Julien Nabet serval2412 at yahoo.fr
Sun Dec 30 12:29:41 PST 2012


On 30/12/2012 18:24, Markus Mohrhard wrote:
> 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.
Ok, I've followed your piece of advice, here's the commit 
http://cgit.freedesktop.org/libreoffice/core/commit/?id=2fbd64cef870568da1479a03f6ea778bab68a09b

Thank you Markus.

Julien


More information about the LibreOffice mailing list