[Libreoffice] duplicateif in vcl/source/gdi/outdev3.cxx

Eike Rathke ooo at erack.de
Tue Sep 13 14:25:28 PDT 2011


Hi julien2412,

On Tuesday, 2011-09-13 13:03:41 -0700, julien2412 wrote:

> Here's another "duplicateif" detected by cppcheck (thanks to Jesse's report
> ;-) )in vcl/source/gdi/outdev3.cxx (line 1999) :
>         if( nMatchType & IMPL_FONT_ATTR_OTHERSTYLE )
>         {
>             if( !(nMatchType & IMPL_FONT_ATTR_OTHERSTYLE) )
>                 nTestMatch -= 10000;
>         }
>         else if( nMatchType & IMPL_FONT_ATTR_OTHERSTYLE )
>             nTestMatch -= 10000;

I'd call that a triplicateif.. actually doing nothing.

> I tried to find from when it's been there but after 5 minutes of searching
> in gitk, I gave up.
> (if someone knows a quick way to find at which commit a specific change has
> been made... )

git log -G is your friend.

git log -G 'nMatchType.+IMPL_FONT_ATTR_OTHERSTYLE' vcl/source/gdi/outdev3.cxx

leads to
git show 4b2ab50308532bd070d9af4ef3d4893256cbe931

a CWS integration consisting of
git show c34627e6c9722436a2c2627f4f52b4b2ddf0d95a
and a following
git show ddb0bc2ec0f4e65168003549cd15000b4c0b8aea


> Could someone explain the logic of all this ? First I thought about a typo
> but even with 1 typo, it means nothing.

The original intent of that construct, even when seen with the removed
code in between, isn't really clear to me, but the negated condition
looks like a copy&paste error from the code that was removed in commit
ddb0bc2ec0f4e65168003549cd15000b4c0b8aea, with

// IMPL_FONT_ATTR_OTHERSTYLE    - OldStyle, ... so negativ points

I conclude that indeed a negative weight should be added, so

    if (nMatchType & IMPL_FONT_ATTR_OTHERSTYLE)
        nTestMatch -= 10000;

looks right to me.

  Eike

-- 
 PGP/OpenPGP/GnuPG encrypted mail preferred in all private communication.
 Key ID: 0x293C05FD - 997A 4C60 CE41 0149 0DB3  9E96 2F1A D073 293C 05FD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110913/fc51a27d/attachment-0001.pgp>


More information about the LibreOffice mailing list