[Libreoffice] [LibreOffice][PATCH] Fixes Compiler Warning

Kenneth Venken kenneth.venken at gmail.com
Fri Oct 15 15:11:43 PDT 2010


Jan Holesovsky schreef op vr 15-10-2010 om 22:18 [+0200]:
> Hi Kenneth,
> 
> On 2010-10-15 at 21:10 +0200, Kenneth Venken wrote:
> 
> > Fixes a compiler warning: "suggest parentheses around && within || "
> > I also improved the readability of the code a bit.
> 
> The change you did silents the warning by doing what the compiler would
> do; but is that really what was the intention there?
> 
> (aComplexLanguageLB.GetSavedValue() !=
> aComplexLanguageLB.GetSelectEntryPos())
> 
> is evaluated regardless the aCTLSupportCB.IsChecked() state - is that
> intentional, can you please check?
> 
Thank you for making me think about the code. I now see why
'warning-free code' is listed under 'slightly more interesting
hacks'. ;)

Correct expression has to be: 
aCTLSupportCB.IsChecked() && 
          (aCTLSupportCB.GetSavedValue() != STATE_CHECK || 
           aComplexLanguageLB.GetSavedValue() !=
aComplexLanguageLB.GetSelectEntryPos())

because sequence checking should only be turned on for certain languages
like Thai, Laotian, Khmer or Vietnamese and only when CTL is enabled.
So, if CTL support is checked, we only need to check for sequence
checking if: previously the CTL support was unchecked or the CTL was
checked but the language has changed.

This compiler warning uncovered a small bug because the old version
would run the code inside the if-statement even when it didn't have to.
Luckily it would always run the code when it had to as well.

*patch attached*

> Thank you,
> Kendy
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: compiler_warning_parentheses_2.diff
Type: text/x-patch
Size: 924 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20101016/0685482e/attachment-0001.bin>


More information about the LibreOffice mailing list